summaryrefslogtreecommitdiffstats
path: root/projects
diff options
context:
space:
mode:
authorRobert Schwebel <r.schwebel@pengutronix.de>2005-05-13 08:09:20 +0000
committerRobert Schwebel <r.schwebel@pengutronix.de>2005-05-13 08:09:20 +0000
commit02480e8b4ce96f7a01cdd4706af4ec1fcec4304c (patch)
treef7a2e3fe3ed2303b811da54aac547653298c09c3 /projects
parentd1f327a3b80d49d09d3cb47a006aad0e0ac6af9f (diff)
downloadptxdist-02480e8b4ce96f7a01cdd4706af4ec1fcec4304c.tar.gz
ptxdist-02480e8b4ce96f7a01cdd4706af4ec1fcec4304c.tar.xz
get hostname from bootloader
git-svn-id: https://svn.pengutronix.de/svn/ptxdist/trunks/ptxdist-0.7-trunk@2611 33e552b5-05e3-0310-8538-816dae2090ed
Diffstat (limited to 'projects')
-rw-r--r--projects/generic/etc/init.d/networking36
1 files changed, 31 insertions, 5 deletions
diff --git a/projects/generic/etc/init.d/networking b/projects/generic/etc/init.d/networking
index ebccb9fe6..6f35d3dcf 100644
--- a/projects/generic/etc/init.d/networking
+++ b/projects/generic/etc/init.d/networking
@@ -2,10 +2,15 @@
# some interesting variables
eth0_current_mac=`ifconfig eth0 | sed -n 's/^.*HWaddr \([0-9A-Za-z:]*\).*/\1/p'`
-eth0_ip=`cat /proc/cmdline | sed -n 's/.*ip=\([^:]*\):.*/\1/gp'`
+eth0_cmdline=`sed -e 's/^.*ip=\([^[:space:]]*\).*$/\1/g' /proc/cmdline`
+eth0_ip=`echo $eth0_cmdline | awk -F':' '{print $1}'`
+eth0_hostname=`echo $eth0_cmdline | awk -F':' '{print $5}'`
+etc_hostname=`cat /etc/hostname`
+#
# check if eth0 is uninitialized and needs to be set up with
# MAC address
+#
echo -n "eth0: mac address state: ";
@@ -18,15 +23,36 @@ else
echo "initialized [$eth0_mac]"
fi
+#
+# check if hostname is consistent with bootloader
+#
+
+if [ "$etc_hostname" != "$eth0_hostname" ]; then
+ echo -n "setting /etc/hostname to $eth0_hostname..."
+ mount_state=`mount | grep root | sed -n 's/^.*(\(r.\),.*$/\1/p'`
+ echo -n "mounting rw..."
+ mount /dev/root / -o remount,rw
+ echo -n "writing..."
+ echo "$eth0_hostname" > /etc/hostname
+ echo -n "mounting ro..."
+ mount /dev/root / -o remount,$mount_state
+ echo "done."
+fi
+hostname -F /etc/hostname
+
+#
# check if we are already listed in /etc/hosts
-# FIXME: put this into deployment script
+#
-hostname=`hostname`
-if [ -z "`grep $hostname /etc/hosts`" ]; then
- echo "adding $hostname to /etc/hosts"
+if [ -z "`grep $eth0_hostname /etc/hosts`" ]; then
+ echo -n "adding $eth0_hostname to /etc/hosts..."
mount_state=`mount | grep root | sed -n 's/^.*(\(r.\),.*$/\1/p'`
+ echo -n "mounting rw..."
mount /dev/root / -o remount,rw
+ echo -n "writing..."
echo `ifconfig eth0 | sed -n '/addr:/s/ [^r]*..//gp'` `hostname` >> /etc/hosts
+ echo -n "mounting ro..."
mount /dev/root / -o remount,$mount_state
+ echo "done"
fi