2010-12-14 07:15:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#(C)IBM Corp
|
|
|
|
#
|
|
|
|
|
2010-12-16 09:36:17 +00:00
|
|
|
# create /etc/sysconfig/network-scripts/
|
2012-03-26 08:39:51 +00:00
|
|
|
pmatch ()
|
|
|
|
{
|
|
|
|
case $1 in
|
|
|
|
$2) return 0;; # zero return code means string matched by pattern
|
|
|
|
esac
|
|
|
|
|
|
|
|
return 1 # non-zero return code means string not matched by pattern
|
|
|
|
}
|
|
|
|
|
2010-12-16 09:36:17 +00:00
|
|
|
for i in `/bin/cat /proc/cmdline`; do
|
|
|
|
KEY=`/bin/echo $i | /bin/awk -F= '{print $1}'`
|
|
|
|
if [ "$KEY" = "ifname" ]; then
|
|
|
|
ifname=`/bin/echo $i | /bin/awk -F= '{print $2}'`
|
|
|
|
MACX=${ifname#*:}
|
|
|
|
ETHX=${ifname%:$MACX*}
|
|
|
|
break
|
|
|
|
elif [ "$KEY" = "netdev" ]; then
|
2011-02-28 10:21:26 +00:00
|
|
|
ETHX=`/bin/echo $i | /bin/awk -F= '{print $2}'`
|
2012-03-27 02:58:24 +00:00
|
|
|
MACX=`/sbin/ip link show $ETHX | /bin/grep ether | /bin/awk '{print $2}'`
|
2010-12-16 09:36:17 +00:00
|
|
|
break
|
|
|
|
elif [ "$KEY" = "BOOTIF" ]; then
|
2011-02-28 10:21:26 +00:00
|
|
|
MACX=`/bin/echo $i | /bin/awk -F= '{print $2}'`
|
|
|
|
ETHX=`/sbin/ifconfig | /bin/grep -i $MACX | /bin/awk '{print $1}'`
|
2010-12-16 09:36:17 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "$MACX" ] && [ ! -z "$ETHX" ]; then
|
2012-03-27 02:58:24 +00:00
|
|
|
if (pmatch $OSVER "sles*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then
|
|
|
|
CONFFILE=$MNTDIR/etc/sysconfig/network/ifcfg-$ETHX
|
|
|
|
fi
|
|
|
|
if (pmatch $OSVER "fedora*") || (pmatch $OSVER "rhel6*") || (pmatch $OSVER "rhels6*") || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ];then
|
|
|
|
CONFFILE=$MNTDIR/etc/sysconfig/network-scripts/ifcfg-$ETHX
|
|
|
|
fi
|
|
|
|
if [ ! -e $CONFFILE ]; then
|
|
|
|
/bin/touch $CONFFILE
|
2010-12-16 09:36:17 +00:00
|
|
|
fi
|
2012-03-27 02:58:24 +00:00
|
|
|
echo "DEVICE=$ETHX" > $CONFFILE
|
|
|
|
echo "BOOTPROTO=dhcp" >> $CONFFILE
|
|
|
|
echo "HWADDR=$MACX" >> $CONFFILE
|
|
|
|
echo "ONBOOT=yes" >> $CONFFILE
|
2010-12-16 09:36:17 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2010-12-14 07:15:45 +00:00
|
|
|
for i in `cat /proc/cmdline`; do
|
|
|
|
KEY=`echo $i | awk -F= '{print $1}'`
|
|
|
|
if [ "$KEY" = "dump" ]; then
|
|
|
|
DUMP=`echo $i |awk -F= '{print $2}'`
|
|
|
|
if [ ! -z "$XCAT" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
elif [ "$KEY" = "XCAT" ]; then
|
|
|
|
XCAT=`echo $i |awk -F= '{print $2}'`
|
|
|
|
if [ ! -z "$DUMP" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -z "$DUMP" ]; then
|
|
|
|
# parse "dump=<proto>://<nfsserver_IP>/<directory>"
|
|
|
|
KDPATH=${DUMP#*:}
|
|
|
|
KDPROTO=${DUMP%:$KDPATH*}
|
|
|
|
|
|
|
|
KDPATH=${KDPATH/\/\//}
|
|
|
|
KDIP=`echo $KDPATH | cut -d'/' -f1`
|
|
|
|
KDPATH=${KDPATH/$KDIP/}
|
|
|
|
|
|
|
|
# if "dump=<proto>:///<directory>", use $xcatmaster as the default NFS server
|
|
|
|
if [ -z $KDIP ]; then
|
|
|
|
KDIP=${XCAT%:*}
|
|
|
|
fi
|
|
|
|
|
|
|
|
# workaround for RHEL6
|
2011-04-20 08:40:40 +00:00
|
|
|
# the $KDIP:$KDPATH directory will be used to generate the initrd for kdump service
|
2012-03-28 07:12:18 +00:00
|
|
|
MOUNTPATH=""
|
2012-04-23 03:14:19 +00:00
|
|
|
if (pmatch $OSVER "*6\.*" ); then
|
2012-03-28 07:12:18 +00:00
|
|
|
MOUNTPATH="/tmp"
|
|
|
|
else
|
|
|
|
MOUNTPATH="/var/tmp"
|
|
|
|
fi
|
|
|
|
/bin/mount $KDIP:$KDPATH $MOUNTPATH
|
2010-12-14 07:15:45 +00:00
|
|
|
|
2012-03-26 08:39:51 +00:00
|
|
|
if [ "$KDPROTO" = "nfs" ]; then
|
|
|
|
if (pmatch $OSVER "sles*") || (pmatch $OSVER "suse*") || [ -f /etc/SuSE-release ]; then
|
2012-03-26 15:04:36 +00:00
|
|
|
KDPATH=${KDPATH//\//\\\/}
|
|
|
|
KDPATH="nfs:\/\/${KDIP}${KDPATH}"
|
2012-03-28 10:04:56 +00:00
|
|
|
sed -i "s/^KDUMP_SAVEDIR=.*$/KDUMP_SAVEDIR=\"${KDPATH}\"/" /etc/sysconfig/kdump
|
2012-05-10 04:20:51 +00:00
|
|
|
sed -i "s/^KDUMP_COPY_KERNEL=.*$/KDUMP_COPY_KERNEL=no/" /etc/sysconfig/kdump
|
|
|
|
#change the mount and remount shell scripts' name, workaround for kdump on stateless node
|
|
|
|
oldmount=`ls /lib/mkinitrd/boot/*-mount.sh`
|
|
|
|
oldremount=`ls /lib/mkinitrd/boot/*-remount.sh`
|
|
|
|
mv $oldmount ${oldmount}.bak
|
|
|
|
mv $oldremount ${oldremount}.bak
|
2012-03-26 08:39:51 +00:00
|
|
|
/etc/init.d/boot.kdump restart
|
2012-05-10 04:20:51 +00:00
|
|
|
mv ${oldmount}.bak $oldmount
|
|
|
|
mv ${oldremount}.bak $oldremount
|
2012-03-26 08:39:51 +00:00
|
|
|
else
|
|
|
|
if (pmatch $OSVER "fedora*") || (pmatch $OSVER "rhel6*") || (pmatch $OSVER "rhels6*") || [ -f /etc/fedora-release ] || [ -f /etc/redhat-release ];then
|
|
|
|
echo "net $KDIP:$KDPATH" > /etc/kdump.conf
|
|
|
|
/etc/init.d/kdump restart
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2010-12-14 07:15:45 +00:00
|
|
|
|
2012-03-28 07:12:18 +00:00
|
|
|
/bin/umount $MOUNTPATH
|
2010-12-14 07:15:45 +00:00
|
|
|
else
|
|
|
|
/bin/echo "The kdump server is not configured"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|