xcat-core/xCAT/postscripts/runxcatpost
2013-10-17 02:20:12 -07:00

74 lines
2.4 KiB
Bash

#!/bin/bash
if [ ! -f "/opt/xcat/xcatdsklspost" ];then
echo "sysclone require /opt/xcat/xcatdsklspost, but it can not be found. return error!"
exit 1
fi
if [ -f "/opt/xcat/xcatinfo" ];then
rm -f "/opt/xcat/xcatinfo"
fi
#some modification to the xcatdsklspost, only download scripts
line_num=`sed -n -e '/postbootscripts-start-here.*postbootscripts-end-here.*run_ps/=' /opt/xcat/xcatdsklspost | tail -n 1`
line_num=`sed -n -e "$line_num,$ {/echo.*TMP.*>.*mypostscript/=}" /opt/xcat/xcatdsklspost | head -n 1`
sed -n -e "1,${line_num}p" /opt/xcat/xcatdsklspost > /tmp/xcatsysclonepost
echo "cd /" >> /tmp/xcatsysclonepost
chmod +x /tmp/xcatsysclonepost
/tmp/xcatsysclonepost
if [ -x /usr/bin/openssl ]; then
USEOPENSSLFORXCAT=1 #Though this is the only method going forward, flag to allow backward compatibility with 2.2 generated netboot images
export USEOPENSSLFORXCAT
fi
. /opt/xcat/xcatinfo
XCATSERVER="$XCATSERVER:3001"
export XCATSERVER
cd /xcatpost/
#save the postboot scripts to /xcatpost/mypostscript.post
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript`
echo "$TMP" > /xcatpost/mypostscript.post
chmod 755 /xcatpost/mypostscript.post
#create the post init
cp -f /xcatpost/xcatpostinit1 /etc/init.d/xcatpostinit1
chmod 755 /etc/init.d/xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc3.d/S84xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc4.d/S84xcatpostinit1
ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc5.d/S84xcatpostinit1
cp -f /xcatpost/xcatinstallpost /opt/xcat/xcatinstallpost
cat >> /opt/xcat/xcatinstallpost << EOF
if [ -f /xcatpost/mypostscript.post ]; then
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
fi
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
chkconfig xcatpostinit1 off
fi
EOF
chmod 755 /opt/xcat/xcatinstallpost
ls /etc | grep -i suse
if [ $? -eq 0 ];then
/sbin/insserv -p /etc/init.d xcatpostinit1
fi
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript`
echo "$TMP" > /xcatpost/mypostscript
chmod +x /xcatpost/mypostscript
/xcatpost/mypostscript
TMP=`sed "/postscripts-start-here/,/postscripts-end-here/ d" /xcatpost/mypostscript`
echo "$TMP" > /tmp/xcatenv
. /tmp/xcatenv
/xcatpost/addsiteyum
if [ -z "$NODESTATUS" ] || [ "$NODESTATUS" != "0" -a "$NODESTATUS" != "N" -a "$NODESTATUS" != "n" ]; then
/xcatpost/updateflag.awk $MASTER 3002
fi