xcat-core/xCAT/postscripts/runxcatpost

72 lines
2.3 KiB
Plaintext
Raw Normal View History

#!/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
2013-10-17 09:21:02 +00:00
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
2013-10-17 09:21:02 +00:00
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
/xcatpost/updateflag.awk $MASTER 3002