diff options
author | Mystery Man <unknown@mandriva.org> | 2003-08-20 07:37:27 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2003-08-20 07:37:27 +0000 |
commit | 7f2ac73888b8ef372ea597049981b27e7d810ac2 (patch) | |
tree | 354132889b63bbe5f446cb82869b3c3367135a80 /rescue/tree/ka/setup_network.sh | |
parent | 327bd24f8e4291bd1882de1990dd7339f781a9cb (diff) | |
download | drakx-7f2ac73888b8ef372ea597049981b27e7d810ac2.tar drakx-7f2ac73888b8ef372ea597049981b27e7d810ac2.tar.gz drakx-7f2ac73888b8ef372ea597049981b27e7d810ac2.tar.bz2 drakx-7f2ac73888b8ef372ea597049981b27e7d810ac2.tar.xz drakx-7f2ac73888b8ef372ea597049981b27e7d810ac2.zip |
This commit was manufactured by cvs2svn to create branch 'MDKC_1_0'.topic/MDKC_1_0
Diffstat (limited to 'rescue/tree/ka/setup_network.sh')
-rwxr-xr-x | rescue/tree/ka/setup_network.sh | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/rescue/tree/ka/setup_network.sh b/rescue/tree/ka/setup_network.sh new file mode 100755 index 000000000..89ddd2c91 --- /dev/null +++ b/rescue/tree/ka/setup_network.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# this script setups the network on the cloned system +# puts a correct hostname +# changes the IP if static -- for only ONE device (dunno what will happen with multiple NICs) +# needs the file /ka/hostnames + + +curdir=`pwd` + +ip=`/sbin/ifconfig | grep -v 127.0.0.1 | grep "inet addr" | sed 's/^.*inet addr:\([^ ]*\) .*$/\1/g'` +ip=`echo $ip | tr . _` +echo -n "Setting hostname: " +hostname $ip + + +# current hostname has been set up in rc.sysinit +ip=`hostname | tr _ .` + +echo My IP is $ip +cd /ka + +# the sed command will remove unwanted spaces +if test -f hostnames ; then + myname=`cat hostnames | sed -e 's/ / /g' -e 's/ *$//' | grep " $ip\$" | cut -d ' ' -f 1` + nbfound=`echo "$myname" | wc -l` +fi + +if [ $nbfound -ne 1 ] || [ -z "$myname" ]; then + # try DNS + echo IP not found in /ka/hostnames, Trying DNS + myname=`host $ip | grep "domain name" | cut -d " " -f 5 | sed 's/\.$//g' ` +# myname=`nslookup $ip | grep ^Name: | tail -n +2 | head -n 1 | sed 's/Name: *//'` +fi + +if [ -z "$myname" ]; then + myname=`hostname` + echo WARNING:HOSTNAME NOT FOUND +fi + +echo My hostname is $myname + +# change hostname in the network file +old=/mnt/disk/etc/sysconfig/network.beforeka +new=/mnt/disk/etc/sysconfig/network + +rm -f "$old" +mv "$new" "$old" +cat "$old" | grep -v ^HOSTNAME= > "$new" +echo "HOSTNAME=$myname" >> "$new" + +# assume first NIC is the gatewaydev (right ? wrong ?) +#firstnic=`grep ^GATEWAYDEV "$new" | cut -d = -f 2 | tr -d \"` +#echo GATEWAYDEV=$firstnic + +# see if IP has to be written +#proto=`grep ^BOOTPROTO /mnt/disk/etc/sysconfig/network-scripts/ifcfg-$firstnic | cut -d = -f 2 | tr -d \"` +#echo PROTO=$proto +#if [ "$proto" != "dhcp" ]; then +# # proto is static, write the new IP in the config file +# old=/mnt/disk/etc/sysconfig/network-scripts/ifcfg-$firstnic.beforeka +# new=/mnt/disk/etc/sysconfig/network-scripts/ifcfg-$firstnic +# +# rm -f "$old" +# mv "$new" "$old" +# cat "$old" | grep -v ^IPADDR= > "$new" +# echo IPADDR=$ip >> "$new" +#fi + +cd $curdir |