Tiny Core Base > TCB Q&A Forum
How to set hostname to DNS name
(1/1)
fow0ryl:
Hello,
I would like to run some thin clients with TC and rdesktop.
The hostname used by TC should be the same as the name provided by the DHCP Server.
My idea is to run ifconfig to get the ip of the machine. Then run a nslookup to find out the hostname.
This hostname could be used to change /etc/hostname and set by "hostname -F /etc/hostname.
But what's the right place to do that?
I could set a hostname in bootlocal. This works i.e when using the mac address to set a unique hostname.
But the network connection isn't established as that time, so I can't get the dns name.
And how to run the functions as root? /etc/hostname can't be changed as user...
Henning
Rich:
Hi fow0ryl
There are a couple different ways to do this. One way is to set up a script called HostSetup.sh containing:
--- Code: ---#!/bin/sh
SEC=60
touch /home/tc/NoNetwork # Set the error flag
while [ $SEC -gt 0 ] ; do
ifconfig | grep -q "Bcast" && break || sleep 1 # Break if the network is up, otherwise sleep for 1 second
echo -ne "Waiting for IP $((SEC--)) \r" # This echo is not required for normal use
done
if [ $SEC -gt 0 ]
then # We only execute this section if $SEC is greater than zero
# Add your commands here.
rm /home/tc/NoNetwork # Clear the error flag
fi
--- End code ---
Add a line to bootlocal containing:
--- Code: ---HostSetup.sh &
--- End code ---
This will launch the script in the background where it will wait for the network to come and then execute any required
commands. If the network does not come up, a file called /home/tc/NoNetwork will be left behind to indicate that.
fow0ryl:
Hello,
thank you very much.
Setting up the hostname is working fine now.
Henning
Rich:
Hi fow0ryl
Glad to hear it worked out for you.
Navigation
[0] Message Index
Go to full version