bug 3817: sysclone support rhels 5.9

This commit is contained in:
xq2005 2013-10-14 03:46:53 -07:00
parent 53dc1cde81
commit 7fc282011b
2 changed files with 49 additions and 28 deletions

View File

@ -624,6 +624,11 @@ sub sysclone_getimg{
my $masterscript = $sysclone_home . "/scripts" . "/$osimage.master";
my $rc = `sed -i "s/shutdown -r now/reboot -f/g" $masterscript`;
#on redhat5 and centos5, the fs inode size must be 128
my $node_osver = getOsVersion($node);
if ( $node_osver =~ /rh.*5.*/ || $node_osver =~ /centos5.*/ ) {
`sed -i "s/mke2fs/mke2fs -I 128/g" $masterscript`
}
return 0;
}
@ -671,6 +676,8 @@ sub sysclone_createosimgdef{
# only update a few attributes which are meanless for sysclone
$osimgdef{$osimage}{provmethod} = "sysclone";
$osimgdef{$osimage}{template} = "";
$osimgdef{$osimage}{otherpkglist} = "";
$osimgdef{$osimage}{pkglist} = "";
}
} else {
$createnew = 1;
@ -746,6 +753,19 @@ sub getOsVersion {
#elsif (-f "/etc/fedora-release") { $os = 'rhfc' }
$os = $os . $version;
}
elsif (grep (/CentOS/, @lines)) {
$os = "centos";
$version = $lines[0];
$version =~ s/[^0-9]*([0-9.]+).*/$1/;
$os = $os . $version;
}
elsif (grep (/Fedora/, @lines)) {
$os = "fedora";
$version = $lines[0];
$version =~ s/[^0-9]*([0-9.]+).*/$1/;
$os = $os . $version;
}
return $os;
}

View File

@ -9,44 +9,45 @@ fi
hostname $HOSTNAME
device_name=''
str_mac=''
for str_temp in `cat /proc/cmdline`;do
echo $str_temp | grep -i 'BOOTIF'
if [ $? -eq 0 ];then
str_mac=`echo $str_temp | awk -F= '{print $2}' | sed -r 's/^01-//' | tr '-' ':' | tr 'a-z' 'A-Z'`
device_name=`ifconfig -a | grep -i $str_mac | awk '{print $1}' | head -n 1`
fi
done
if [ -z "$device_name" ];then
device_name=$DEVICE
str_mac=`ifconfig $device_name|grep -i HWaddr|awk '{print $5}'`
fi
str_cfg_file=''
if [ -d "/etc/sysconfig/network-scripts/" ];then
#redhat
str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$DEVICE"
rm -f /etc/sysconfig/network-scripts/ifcfg-*
str_cfg_file="/etc/sysconfig/network-scripts/ifcfg-$device_name"
sed -i "s/HOSTNAME=.*/HOSTNAME=$HOSTNAME/g" /etc/sysconfig/network
if [ -f $str_cfg_file ];then
echo "Old ifcfg-$DEVICE is:"
cat $str_cfg_file
HWADDR=`ifconfig $DEVICE|grep HWaddr|awk '{print $5}'`
sed -i "s/HWADDR=.*/HWADDR="$HWADDR"/g" $str_cfg_file
sed -i "s/UUID=.*//g" $str_cfg_file
else
echo "DEVICE=\"$DEVICE\"" > $str_cfg_file
echo "BOOTPROTO=\"dhcp\"" >> $str_cfg_file
echo "NM_CONTROLLED=\"yes\"" >> $str_cfg_file
echo "ONBOOT=\"yes\"" >> $str_cfg_file
fi
echo "DEVICE=\"$device_name\"" > $str_cfg_file
echo "BOOTPROTO=\"dhcp\"" >> $str_cfg_file
echo "NM_CONTROLLED=\"yes\"" >> $str_cfg_file
echo "HWADDR=$str_mac" >> $str_cfg_file
echo "ONBOOT=\"yes\"" >> $str_cfg_file
elif [ -d "/etc/sysconfig/network/" ];then
#suse
str_cfg_file="/etc/sysconfig/network/ifcfg-$DEVICE"
rm -f /etc/sysconfig/network/ifcfg-*
str_cfg_file="/etc/sysconfig/network/ifcfg-$device_name"
echo "$HOSTNAME" > /etc/HOSTNAME
if [ -f $str_cfg_file ];then
echo "Old ifcfg-$DEVICE is:"
cat $str_cfg_file
HWADDR=`ifconfig $DEVICE|grep HWaddr|awk '{print $5}'`
sed -i "s/HWADDR=.*/HWADDR=$HWADDR/g" $str_cfg_file
sed -i "s/UUID=.*//g" $str_cfg_file
else
echo "DEVICE=\"$DEVICE\"" > $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> $str_cfg_file
fi
echo "DEVICE=\"$device_name\"" > $str_cfg_file
echo "HWADDR=$str_mac" >> $str_cfg_file
echo "BOOTPROTO=dhcp" >> $str_cfg_file
echo "STARTMODE=onboot" >> $str_cfg_file
echo "DHCLIENT_PRIMARY_DEVICE=yes" >> $str_cfg_file
else
#ubuntu
echo "Does not support ubuntu."
exit 1
fi
echo "New ifcfg-$DEVICE is:"
cat $str_cfg_file