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
 

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

reply to topic new topic new poll
Topic: Set Hostname from boot params, hacked knoppix-autoconfig< Next Oldest | Next Newest >
henk1955 Offline





Group: Members
Posts: 249
Joined: June 2004
Posted: Dec. 06 2004,15:10 QUOTE

i have hacked the knoppix-autoconfig file( for use on a remastered dsl) to allow the use of a bootparam to set the hostname to something else the "box"

1. add a # infront of the line:
 hostname box
2. add the following lines just below the lines:
# / must be read-write in any case, starting from here
mount -o remount,rw / 2>/dev/null
Code Sample

# Set hostname
HOSTNAME="$(getbootparam host 2>/dev/null)"
[ -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


this is what it does.
1. find the host param from the bootparams
2. remove the old /etc/hostname file with "box" in it.
3. create a new /etc/hostname with the new hostname
4. use the /etc/hostname file to set hostname
5. remove /etc/hosts file with the "127.0.0.1 box localhost" in it
6. create a new /etc/hosts with the new hostname in it


--------------
You have a Q or just want to chat?
Come to #damnsmalllinux on irc.freenode.net!
Open 24/7

dell latitude c640 p4@1.6Ghz 256Mb DSL0.9.1-remaster
asus p4p800-vm p4@2.8Ghz HT / celeron@2.4Ghz 512Mb DSL0.9.1-remaster (alsadebs.dsl)
ABit BE6 celeron@466 256Mb DSL0.9.1-remaster (xawtv)
Back to top
Profile PM WEB MSN 
Caspar_s
Unregistered






Posted: Dec. 18 2004,15:14 QUOTE

Ummm, so where do you put this?
Back to top
clacker Offline





Group: Members
Posts: 570
Joined: June 2004
Posted: Dec. 18 2004,16:41 QUOTE

henk1955, very nice work.  I like how you pulled the new name right off the boot prompt.  I think you might consider skipping over your code if the user doesn't enter a hostname at the prompt with an if statement.  That way if anything changes in DSL your script will be OK.
Back to top
Profile PM 
2 replies since Dec. 06 2004,15:10 < Next Oldest | Next Newest >

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

 
reply to topic new topic new poll
Quick Reply: Set Hostname from boot params

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