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
|
|
|
|
#
|
|
|
|
|
2014-06-10 15:54:31 +00:00
|
|
|
|
|
|
|
str_dir_name=`dirname $0`
|
|
|
|
|
|
|
|
. $str_dir_name/xcatlib.sh
|
|
|
|
|
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
|
2012-11-14 17:04:40 +00:00
|
|
|
MACX=`/bin/echo $i | /bin/awk -F= '{print $2}'|sed -e s/^01-// -e s/-/:/g`
|
2014-06-13 14:37:18 +00:00
|
|
|
#ETHX=`/sbin/ifconfig | /bin/grep -i $MACX | /bin/awk '{print $1}'`
|
2014-06-18 07:43:21 +00:00
|
|
|
ETHX=`/sbin/ip -oneline link show |/bin/grep -i $MACX |/bin/awk -F ":" '{print $2}'|/bin/grep -o "[^ ]\+\( \+[^ ]\+\)*"`
|
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-05-25 06:58:40 +00:00
|
|
|
if (pmatch $ETHX "hf*") ; then
|
|
|
|
IP=`/sbin/ifconfig $ETHX | /bin/grep -i "inet addr" | awk '{print $2}' | awk -F: '{print $2}'`
|
|
|
|
MASK=`/sbin/ifconfig $ETHX | /bin/grep -i "inet addr" | awk '{print $4}' | awk -F: '{print $2}'`
|
|
|
|
echo "DEVICE=$ETHX" > $CONFFILE
|
|
|
|
echo "BOOTPROTO=static" >> $CONFFILE
|
|
|
|
echo "HWADDR=$MACX" >> $CONFFILE
|
|
|
|
echo "ONBOOT=yes" >> $CONFFILE
|
|
|
|
echo "IPADDR=$IP" >> $CONFFILE
|
|
|
|
echo "NETMASK=$MASK" >> $CONFFILE
|
|
|
|
else
|
|
|
|
echo "DEVICE=$ETHX" > $CONFFILE
|
|
|
|
echo "BOOTPROTO=dhcp" >> $CONFFILE
|
|
|
|
echo "HWADDR=$MACX" >> $CONFFILE
|
|
|
|
echo "ONBOOT=yes" >> $CONFFILE
|
|
|
|
fi
|
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}'`
|
2012-05-25 07:10:40 +00:00
|
|
|
if [ ! -z "$XCAT" ]; then
|
|
|
|
break
|
|
|
|
fi
|
2010-12-14 07:15:45 +00:00
|
|
|
elif [ "$KEY" = "XCAT" ]; then
|
|
|
|
XCAT=`echo $i |awk -F= '{print $2}'`
|
2012-05-25 07:10:40 +00:00
|
|
|
if [ ! -z "$DUMP" ]; then
|
|
|
|
break
|
|
|
|
fi
|
2010-12-14 07:15:45 +00:00
|
|
|
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
|
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-11-09 10:13:20 +00:00
|
|
|
if (pmatch $OSVER "*10*"); then
|
|
|
|
#run mkinitrd to generater the kdump-init base
|
2012-11-14 17:04:40 +00:00
|
|
|
if (pmatch $ARCH "x86*"); then
|
|
|
|
/sbin/mkinitrd -m "nfs tg3 bnx2 bnx2x e1000 e1000e igb mlx_en be2net af_packet firmware_class"
|
|
|
|
else
|
|
|
|
/sbin/mkinitrd -m "nfs be2net e1000e ibmveth igb firmware_class tg3 e1000"
|
|
|
|
fi
|
2012-11-09 10:13:20 +00:00
|
|
|
/bin/mkdir -p /var/tmp/tempinit
|
|
|
|
cd /boot/
|
|
|
|
KDUMPINIT=`ls initrd-*-kdump`
|
|
|
|
/bin/cp /boot/${KDUMPINIT} /var/tmp/tempinit/
|
|
|
|
#change to the /var/tmp/tempinit/ directory
|
|
|
|
cd /var/tmp/tempinit/
|
|
|
|
/bin/zcat ${KDUMPINIT} | /bin/cpio -id
|
|
|
|
/bin/rm -f ${KDUMPINIT}
|
2012-11-15 06:02:28 +00:00
|
|
|
/bin/mkdir -p ./var/lib/dhcpcd/
|
|
|
|
/bin/mkdir -p ./lib/udev/devices/
|
|
|
|
if (pmatch $ARCH "ppc*"); then
|
|
|
|
/bin/mkdir -p ./lib/power6/
|
|
|
|
/bin/mkdir -p ./lib/power7/
|
|
|
|
fi
|
2012-11-14 17:04:40 +00:00
|
|
|
/bin/cp -r /lib/udev/devices/* ./lib/udev/devices/
|
|
|
|
for file in "/sbin/ifconfig /usr/bin/clear /bin/touch /bin/grep /sbin/dhcpcd /sbin/ip /bin/awk /bin/makedumpfile"
|
|
|
|
do
|
|
|
|
for line in `ldd $file`
|
|
|
|
do
|
|
|
|
if [ ${line:0:1} = "/" ]; then
|
|
|
|
line=`echo $line | grep -v :`
|
|
|
|
if [ $line ];then
|
|
|
|
if [ ! -e .$line ];then
|
|
|
|
/bin/cp -L $line .$line
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
/bin/cp $file "./bin/"
|
|
|
|
done
|
2012-11-09 10:13:20 +00:00
|
|
|
|
|
|
|
#modify the original init to support dump to an nfs server
|
|
|
|
cat > ./bin/dumpfile << EOF
|
|
|
|
#!/bin/bash
|
|
|
|
if [ -e /proc/vmcore ];then
|
|
|
|
/bin/touch /var/lib/dhcpcd/dhcpcd-$ETHX.info
|
2012-11-14 17:04:40 +00:00
|
|
|
for i in 1 2 3 4 5 6 7 8 9 10
|
|
|
|
do
|
2012-11-09 10:13:20 +00:00
|
|
|
/bin/dhcpcd $ETHX
|
2012-11-14 17:04:40 +00:00
|
|
|
/bin/sleep 2
|
|
|
|
temp=\`/bin/ifconfig | /bin/grep inet\`
|
|
|
|
if [ -n "\$temp" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
echo -e "Failed to acquire address, retrying"
|
2012-11-09 10:13:20 +00:00
|
|
|
done
|
|
|
|
|
2012-11-14 17:04:40 +00:00
|
|
|
if [ -z "\$temp" ];then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2012-11-09 10:13:20 +00:00
|
|
|
HOSTNAME=`hostname`
|
|
|
|
|
|
|
|
/bin/mkdir /mnt
|
|
|
|
/bin/mount -t nfs -o nolock ${KDIP}:${KDPATH} /mnt
|
2012-11-15 08:51:36 +00:00
|
|
|
if [ -e /mnt/$HOSTNAME ];then
|
|
|
|
/bin/rm -f /mnt/$HOSTNAME
|
|
|
|
fi
|
2012-11-09 10:13:20 +00:00
|
|
|
/bin/makedumpfile -c /proc/vmcore /mnt/$HOSTNAME
|
|
|
|
/bin/umount -l /mnt
|
|
|
|
/sbin/reboot -d -f
|
|
|
|
fi
|
|
|
|
EOF
|
|
|
|
chmod a+x ./bin/dumpfile
|
|
|
|
/bin/sed -i "s/^# No multipath support/ \/bin\/dumpfile\n/" ./init
|
|
|
|
/bin/rm -f /boot/${KDUMPINIT}
|
|
|
|
/usr/bin/find . | cpio -H newc -o|gzip -9 -c - > /boot/${KDUMPINIT}
|
|
|
|
cd /
|
|
|
|
/bin/rm -rf "/var/tmp/tempinit"
|
2014-06-10 15:54:31 +00:00
|
|
|
#service kdump restart
|
|
|
|
restartservice kdump
|
2012-11-09 10:13:20 +00:00
|
|
|
else
|
|
|
|
/bin/mount -o nolock $KDIP:$KDPATH $MOUNTPATH
|
|
|
|
KDTEMPPATH=${KDPATH//\//\\\/}
|
|
|
|
KDTEMPPATH="nfs:\/\/${KDIP}${KDTEMPPATH}\/${NODE}"
|
|
|
|
sed -i "s/^KDUMP_SAVEDIR=.*$/KDUMP_SAVEDIR=\"${KDTEMPPATH}\"/" /etc/sysconfig/kdump
|
|
|
|
sed -i "s/^KDUMP_COPY_KERNEL=.*$/KDUMP_COPY_KERNEL=\"no\"/" /etc/sysconfig/kdump
|
|
|
|
sed -i "s/^KDUMP_PRESCRIPT=.*$/KDUMP_PRESCRIPT=\"\/tmp\/createdir\"/" /etc/sysconfig/kdump
|
|
|
|
sed -i "s/^KDUMP_REQUIRED_PROGRAMS=.*$/KDUMP_REQUIRED_PROGRAMS=\"\/tmp\/createdir\"/" /etc/sysconfig/kdump
|
|
|
|
TEMPDELAY=$(($RANDOM%30))
|
|
|
|
#work around for the kdump on sles 11.2
|
|
|
|
echo "/bin/mkdir -p /root/tmp/" > /tmp/createdir
|
|
|
|
#following 5 lines is the work around for kdump on multiply nodes
|
|
|
|
echo "/bin/sleep ${TEMPDELAY}" >> /tmp/createdir
|
|
|
|
echo "/bin/mount -o nolock ${KDIP}:${KDPATH} /tmp" >> /tmp/createdir
|
|
|
|
echo "/bin/mkdir -p /tmp/${NODE}" >> /tmp/createdir
|
|
|
|
echo "/bin/sleep ${TEMPDELAY}" >> /tmp/createdir
|
|
|
|
echo "/bin/umount /tmp" >> /tmp/createdir
|
|
|
|
/bin/chmod 777 /tmp/createdir
|
|
|
|
#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
|
|
|
|
/etc/init.d/boot.kdump restart
|
|
|
|
mv ${oldmount}.bak $oldmount
|
|
|
|
mv ${oldremount}.bak $oldremount
|
|
|
|
fi
|
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
|
2012-11-09 10:13:20 +00:00
|
|
|
/bin/mount -o nolock $KDIP:$KDPATH $MOUNTPATH
|
2012-03-26 08:39:51 +00:00
|
|
|
echo "net $KDIP:$KDPATH" > /etc/kdump.conf
|
2012-05-25 07:10:40 +00:00
|
|
|
echo "link_delay 180" >> /etc/kdump.conf
|
2014-06-10 15:54:31 +00:00
|
|
|
#/etc/init.d/kdump restart
|
|
|
|
restartservice kdump
|
2012-03-26 08:39:51 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
2010-12-14 07:15:45 +00:00
|
|
|
|
2012-06-16 01:41:46 +00:00
|
|
|
/bin/umount -l $MOUNTPATH
|
2010-12-14 07:15:45 +00:00
|
|
|
else
|
|
|
|
/bin/echo "The kdump server is not configured"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|