Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (2) </ [1] 2 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: setting hostname with liveCD?< Next Oldest | Next Newest >
vinoloco Offline





Group: Members
Posts: 14
Joined: Mar. 2005
Posted: Mar. 21 2005,03:38 QUOTE

Anyone know how to set the hostname on a live CD "toram" and have it and have it backed up?  Manual modifications work fine but files like /etc/hosts and /etc/init.d/knoppix-autoconfig can't be modified and saved through "backup" because they are linked.  Any ideas?

  -- vino
Back to top
Profile PM 
cbagger01 Offline





Group: Members
Posts: 4264
Joined: Oct. 2003
Posted: Mar. 21 2005,17:07 QUOTE

You can create a short shell script that is located in /etc/init.d that will autorun.

This script can delete the symlinks and either

replace them with a new hostname OR

prompt the user to enter a hostname and then replace the file with the new hostname.

Then you can tar this script up into a *.tar.gz or a *.dsl file.
Back to top
Profile PM 
vinoloco Offline





Group: Members
Posts: 14
Joined: Mar. 2005
Posted: Mar. 22 2005,03:52 QUOTE

OK Cbagger01.  Thanks for the tip.  I'll try this out and see if it works.

  -- vino
Back to top
Profile PM 
henk.1955 Offline





Group: Members
Posts: 41
Joined: Feb. 2005
Posted: Mar. 22 2005,09:20 QUOTE

*.tar.gz, *.dsl and *.uci are loaded at boottime with the /etc/rcS.d/S01dsl-config. this is a link to /KNOPPIX/etc/init.d/dsl-config.
So if you want a script to run at boottime: you can put it in in /etc/init.d and have links in /etc/rc2.d/,
/etc/rc3.d/,/etc/rc4.d/,/etc/rc5.d/ to the script.
then tar.gz the script and the links. ( does not have to be a *.dsl, /etc is writeable as it in minirt24 which is the root).
put the script where mydsl= finds it.

example:
/etc/init.d/echo_hostname
Code Sample
#!/bin/bash

. /etc/init.d/dsl-functions

CMDLINE="$(cat /proc/cmdline)"

# get hostname from bootparams

HOSTNAME="$(getbootparam hostname 2>/dev/null)"

echo "hostname=$HOSTNAME."

ln -sf /etc/init.d/echo_hostname /etc/rc2.d/S01echo_hostname
ln -sf /etc/init.d/echo_hostname /etc/rc3.d/S01echo_hostname
ln -sf /etc/init.d/echo_hostname /etc/rc4.d/S01echo_hostname
ln -sf /etc/init.d/echo_hostname /etc/rc5.d/S01echo_hostname

The links in the /etc/rc2.d .. /etc/rc5.d make sure the script is run no matter what runlevel you choise.
the S01 in the linkname defines the order in which the scripts are run S01 first S99 last

Now if you look in /etc/rc2.d to etc/rc5.d you see they have:
S49dsl-restore ( this untars the backup.tar.gz)
S99bootlocal   ( this runs the /opt/bootlocal.sh)

i think it is much easier add:
Code Sample
. /etc/init.d/dsl-functions

CMDLINE="$(cat /proc/cmdline)"

# Set hostname
HOSTNAME="$(getbootparam hostname 2>/dev/null)"

echo "hostname=$HOSTNAME."

[ -n "$HOSTNAME" ] || HOSTNAME="box"
rm -f /etc/hostname
echo $HOSTNAME >/etc/hostname
/etc/init.d/hostname.sh
rm -f /etc/hosts
cat >/etc/hosts <<EOT
127.0.0.1 $HOSTNAME localhost

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

EOT

echo "hostname set"

to /opt/bootlocal.sh
or put this code in a script, call the script from bootlocal.sh
then add them to filetool.lst to have them backedup
Back to top
Profile PM WEB 
vinoloco
Unregistered






Posted: Mar. 26 2005,07:14 QUOTE

Henk.1955:

Thanks for the input.  With a little bit of tweaking for my setup this worked fine.  Maybe we should put this in the "how to" section since this question comes up a lot?

    -- vino
Back to top
8 replies since Mar. 21 2005,03:38 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (2) </ [1] 2 >/
reply to topic new topic new poll
Quick Reply: setting hostname with liveCD?

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code