From dc6c986f4b070b5775a8228c8243e34c3a6cef9b Mon Sep 17 00:00:00 2001 From: linggao Date: Thu, 1 Nov 2012 21:04:26 +0000 Subject: [PATCH] added postscript setuppostbootscripts to support value change for site.runbootscripts. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14208 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Schema.pm | 4 +- .../share/xcat/install/scripts/post.xcat | 8 +-- xCAT/postscripts/setuppostbootscripts | 71 +++++++++++++++++++ 3 files changed, 78 insertions(+), 5 deletions(-) create mode 100755 xCAT/postscripts/setuppostbootscripts diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index c9922408e..ef9ee9bf3 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -922,7 +922,9 @@ site => { " runbootscripts: If set to 'yes' the scripts listed in the postbootscripts\n". " attribute in the osimage and postscripts tables will be run during\n". " each reboot of stateful (diskful) nodes. This attribute has no\n". - " effect on stateless and statelite nodes.\n\n". + " effect on stateless and statelite nodes. Please run the following\n" . + " command after you change the value of this attribute: \n". + " 'updatenode -P setuppostbootscripts'\n\n". " syspowerinterval: For system p CECs, this is the number of seconds the rpower\n". " command will wait between performing the action for each CEC.\n". " For system x IPMI servers, this is the number of seconds the\n". diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index fdce3991a..d0c12602f 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -139,16 +139,16 @@ cat >/etc/init.d/xcatpostinit1 << 'EOF' #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit1# EOF chmod 755 /etc/init.d/xcatpostinit1 -ln -s /etc/init.d/xcatpostinit1 /etc/rc3.d/S84xcatpostinit1 -ln -s /etc/init.d/xcatpostinit1 /etc/rc4.d/S84xcatpostinit1 -ln -s /etc/init.d/xcatpostinit1 /etc/rc5.d/S84xcatpostinit1 +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 mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost << 'EOF' #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# EOF chmod 755 /opt/xcat/xcatinstallpost -chkconfig --add xcatpostinit1 +chkconfig xcatpostinit1 on #create the dskls post cat >/opt/xcat/xcatdsklspost << 'EOF' diff --git a/xCAT/postscripts/setuppostbootscripts b/xCAT/postscripts/setuppostbootscripts new file mode 100755 index 000000000..21cb3df25 --- /dev/null +++ b/xCAT/postscripts/setuppostbootscripts @@ -0,0 +1,71 @@ +#!/bin/sh +# IBM(c) 2012 EPL license http://www.eclipse.org/legal/epl-v10.html + +#------------------------------------------------------------------------------- +#=head1 setuppostbootscripts +#=head2 This command setup the node so that when the node reboots, +# the postbootscripts will be run or not depending on the +# site.runbootscripts setting. +# If site.runbootscripts is 'yes', then the scripts defined by +# postscripts.postbootscripts will be run when the node reboots. +#=cut +#------------------------------------------------------------------------------- + +#only works for diskful nodes +if [ "$NODESETSTATE" = "netboot" -o \ + "$NODESETSTATE" = "statelite" -o \ + "$NODESETSTATE" = "diskless" -o \ + "$NODESETSTATE" = "dataless" ]; then + echo "Nothng to do for stateless and statelite node." + exit 0 +fi + +#create /opt/xcat directory if not exist +if [ ! -d "/opt/xcat" ]; then + mkdir -p /opt/xcat +fi + +#copy the necessary files +rsync /xcatpost/xcatdsklspost /opt/xcat/xcatdsklspost +rsync /xcatpost/xcatinstallpost /opt/xcat/xcatinstallpost +rsync /xcatpost/xcatpostinit1 /etc/init.d/xcatpostinit1 +chmod 755 /etc/init.d/xcatpostinit1 + +if [ ! -f "/etc/rc.d/rc3.d/S84xcatpostinit1" ]; then + ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc3.d/S84xcatpostinit1 +fi +if [ ! -f "/etc/rc.d/rc4.d/S84xcatpostinit1" ]; then + ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc4.d/S84xcatpostinit1 +fi +if [ ! -f "/etc/rc.d/rc5.d/S84xcatpostinit1" ]; then + ln -s /etc/init.d/xcatpostinit1 /etc/rc.d/rc5.d/S84xcatpostinit1 +fi + +#put correct info in /opt/xcat/xcatinfo +infofile="/opt/xcat/xcatinfo" +if [ ! -f $infofile ]; then + echo "XCATSERVER=$MASTER" > $infofile + echo "REBOOT=TRUE" >> $infofile +else + value=`grep XCATSERVER $infofile` + if [[ -n $value ]]; then + sed -i "s/^XCATSERVER=.*$/XCATSERVER=$MASTER/" $infofile + else + echo "XCATSERVER=$MASTER" >> $infofile + fi + value=`grep REBOOT $infofile` + if [[ -n $value ]]; then + sed -i "s/^REBOOT=.*$/REBOOT=TRUE/" $infofile + else + echo REBOOT=TRUE >> $infofile + fi +fi +#enable/disable the running of postscripts according to site.runbootscripts +if [[ "$RUNBOOTSCRIPTS" = "yes" ]]; then + output=`chkconfig xcatpostinit1 on 2>&1 > /dev/null` +else + output=`chkconfig xcatpostinit1 off 2>&1 > /dev/null` +fi + +exit 0 +