2013-05-13 07:54:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
. /tmp/post-install/variables.txt
|
|
|
|
|
2013-08-20 09:09:46 +00:00
|
|
|
#delete the udev rule in the image
|
|
|
|
rule_file=`ls /etc/udev/rules.d/*net_persistent_names.rules`
|
|
|
|
if [ -n "$rule_file" ];then
|
|
|
|
rm -f $rule_file
|
|
|
|
fi
|
|
|
|
|
2013-05-13 07:54:44 +00:00
|
|
|
echo "Updating hostname to $HOSTNAME"
|
|
|
|
sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
|
|
|
|
|
|
|
|
hostname $HOSTNAME
|
|
|
|
|
2013-08-20 09:09:46 +00:00
|
|
|
str_cfg_file=''
|
|
|
|
if [ -d "/etc/sysconfig/network-scripts/" ];then
|
|
|
|
#redhat
|
|
|
|
str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$DEVICE"
|
|
|
|
elif [ -d "/etc/sysconfig/network/" ];then
|
|
|
|
#suse
|
|
|
|
str_cfg_file="/etc/sysconfig/network/ifcfg-$DEVICE"
|
|
|
|
else
|
|
|
|
#ubuntu
|
|
|
|
str_cfg_file="/etc/network/interfaces.d/$DEVICE"
|
|
|
|
fi
|
|
|
|
|
2013-05-13 07:54:44 +00:00
|
|
|
echo "Old ifcfg-$DEVICE is:"
|
2013-08-20 09:09:46 +00:00
|
|
|
cat $str_cfg_file
|
2013-05-13 07:54:44 +00:00
|
|
|
|
|
|
|
HWADDR=`ifconfig $DEVICE|grep HWaddr|awk '{print $5}'`
|
2013-08-20 09:09:46 +00:00
|
|
|
sed -i "s/HWADDR=.*/HWADDR="$HWADDR"/g" $str_cfg_file
|
|
|
|
sed -i "s/UUID=.*//g" $str_cfg_file
|
2013-05-13 07:54:44 +00:00
|
|
|
|
|
|
|
echo "New ifcfg-$DEVICE is:"
|
2013-08-20 09:09:46 +00:00
|
|
|
cat $str_cfg_file
|