From a525edd2fc9f68d39ce2be07afd3df8fd2b69743 Mon Sep 17 00:00:00 2001 From: linggao Date: Fri, 10 Jul 2009 18:34:09 +0000 Subject: [PATCH] moved the xCAT postscripts to init.d process for full install for SLES git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3755 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Template.pm | 34 +++++---- .../share/xcat/install/scripts/post.sles | 68 +++++------------- .../xcat/install/scripts/post.sles.iscsi | 68 +++++------------- .../share/xcat/install/scripts/post.sles11 | 69 ++++--------------- .../xcat/install/scripts/post.sles11.iscsi | 62 ++++------------- xCAT/postscripts/xcatdsklspost | 7 -- xCAT/postscripts/xcatpostinit | 4 +- 7 files changed, 86 insertions(+), 226 deletions(-) diff --git a/perl-xCAT/xCAT/Template.pm b/perl-xCAT/xCAT/Template.pm index 48512b204..56b8e8e74 100644 --- a/perl-xCAT/xCAT/Template.pm +++ b/perl-xCAT/xCAT/Template.pm @@ -64,7 +64,7 @@ sub subvars { $doneincludes=1; if ($inc =~ /#INCLUDE:[^#]+#/) { $doneincludes=0; - $inc =~ s/#INCLUDE:([^#]+)#/includefile($1)/eg; + $inc =~ s/#INCLUDE:([^#]+)#/includefile($1, 0)/eg; } } #ok, now do everything else.. @@ -74,6 +74,8 @@ sub subvars { $inc =~ s/#CRYPT:([^:]+):([^:]+):([^#]+)#/crydb($1,$2,$3)/eg; $inc =~ s/#XCATVAR:([^#]+)#/envvar($1)/eg; $inc =~ s/#ENV:([^#]+)#/envvar($1)/eg; + $inc =~ s/#INCLUDE_NOP:([^#]+)#/includefile($1,1)/eg; + if ($tmplerr) { close ($outh); return $tmplerr; @@ -84,23 +86,29 @@ sub subvars { } sub includefile { - my $file = shift; - my $text = ""; + my $file = shift; + my $special=shift; + my $text = ""; unless ($file =~ /^\//) { $file = $idir."/".$file; } - open(INCLUDE,$file) || \ - return "#INCLUDEBAD:cannot open $file#"; + open(INCLUDE,$file) || \ + return "#INCLUDEBAD:cannot open $file#"; + + while() { + $text .= "$_"; + } + + close(INCLUDE); + + if ($special) { + $text =~ s/\$/\\\$/g; + $text =~ s/`/\\`/g; + } - while() { - $text .= "$_"; - } - - close(INCLUDE); - - chomp($text); - return($text); + chomp($text); + return($text); } sub command diff --git a/xCAT-server/share/xcat/install/scripts/post.sles b/xCAT-server/share/xcat/install/scripts/post.sles index ad9a89b04..398688451 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles +++ b/xCAT-server/share/xcat/install/scripts/post.sles @@ -51,59 +51,23 @@ HOSTNAME=$(hostname -s) echo $HOSTNAME /sbin/portmap -export MASTER_IP=#XCATVAR:XCATMASTER# -export MASTER_IPS=#XCATVAR:XCATMASTER# -export MASTER="#XCATVAR:XCATMASTER#" -# -# This script has not yet been updated to work with service nodes -# -for i in $(seq 1 20) -do - GOTIT=0 - for i in $MASTER_IPS - do - #mount -r $i:/install/postscripts /xcatpost - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts - if [ "$?" = "0" ] - then - if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit - exit 1 - fi - XCATSERVER=$i:3001 - export XCATSERVER - mv $i/postscripts /xcatpost - rm -rf $i - chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - while [ -z "$MYCONT" ]; do - let SLI=$RANDOM%10+10 - sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - done - chmod +x /tmp/mypostscript - GOTIT=1 - break - fi - done - if [ "$GOTIT" = "1" ] - then - break - fi - RAND=$(perl -e 'print int(rand(5)). "\n"') - sleep $RAND -done -PATH=/xcatpost:$PATH -export PATH -/tmp/mypostscript -updateflag.awk $MASTER 3002 -cd / -/xcatpost/#TABLE:nodelist:$NODE:node# -rm -Rf /xcatpost -rm -f /tmp/mypostscript -rmdir /xcatpost +cat >/etc/init.d/xcatpostinit << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit# +EOF +chmod 755 /etc/init.d/xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc3.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc4.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc5.d/S84xcatpostinit + +mkdir -p /opt/xcat +cat >/opt/xcat/xcatdsklspost << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost# +chkconfig xcatpostinit off +EOF +chmod 755 /opt/xcat/xcatdsklspost + +chkconfig --add xcatpostinit ]]> diff --git a/xCAT-server/share/xcat/install/scripts/post.sles.iscsi b/xCAT-server/share/xcat/install/scripts/post.sles.iscsi index 13dbf85d0..9da81a82f 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles.iscsi +++ b/xCAT-server/share/xcat/install/scripts/post.sles.iscsi @@ -25,59 +25,23 @@ HOSTNAME=$(hostname -s) echo $HOSTNAME /sbin/portmap -export MASTER_IP=#XCATVAR:XCATMASTER# -export MASTER_IPS=#XCATVAR:XCATMASTER# -export MASTER="#XCATVAR:XCATMASTER#" -# -# This script has not yet been updated to work with service nodes -# -for i in $(seq 1 20) -do - GOTIT=0 - for i in $MASTER_IPS - do - #mount -r $i:/install/postscripts /xcatpost - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts - if [ "$?" = "0" ] - then - if [ ! -x /usr/bin/openssl ]; then #Stop if no openssl to help the next bit - exit 1 - fi - XCATSERVER=$i:3001 - export XCATSERVER - mv $i/postscripts /xcatpost - rm -rf $i - chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - while [ -z "$MYCONT" ]; do - let SLI=$RANDOM%10+10 - sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - done - chmod +x /tmp/mypostscript - GOTIT=1 - break - fi - done - if [ "$GOTIT" = "1" ] - then - break - fi - RAND=$(perl -e 'print int(rand(5)). "\n"') - sleep $RAND -done -PATH=/xcatpost:$PATH -export PATH -/tmp/mypostscript -updateflag.awk $MASTER 3002 -cd / -/xcatpost/#TABLE:nodelist:$NODE:node# -rm -Rf /xcatpost -rm -f /tmp/mypostscript -rmdir /xcatpost +cat >/etc/init.d/xcatpostinit << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit# +EOF +chmod 755 /etc/init.d/xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc3.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc4.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc5.d/S84xcatpostinit + +mkdir -p /opt/xcat +cat >/opt/xcat/xcatdsklspost << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost# +chkconfig xcatpostinit off +EOF +chmod 755 /opt/xcat/xcatdsklspost + +chkconfig --add xcatpostinit ]]> diff --git a/xCAT-server/share/xcat/install/scripts/post.sles11 b/xCAT-server/share/xcat/install/scripts/post.sles11 index 96b639aed..398688451 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles11 +++ b/xCAT-server/share/xcat/install/scripts/post.sles11 @@ -51,62 +51,23 @@ HOSTNAME=$(hostname -s) echo $HOSTNAME /sbin/portmap -export MASTER_IP=#XCATVAR:XCATMASTER# -export MASTER_IPS=#XCATVAR:XCATMASTER# -export MASTER="#XCATVAR:XCATMASTER#" -# -# This script has not yet been updated to work with service nodes -# -for i in $(seq 1 20) -do - GOTIT=0 - for i in $MASTER_IPS - do - #mount -r $i:/install/postscripts /xcatpost - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts +cat >/etc/init.d/xcatpostinit << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit# +EOF +chmod 755 /etc/init.d/xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc3.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc4.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc5.d/S84xcatpostinit - if [ "$?" = "0" ] - then - if [ -x /usr/bin/openssl ]; then - XCATSERVER=$i:3001 - export XCATSERVER - else - exit 1 - fi - fi - mv $i/postscripts /xcatpost - rm -rf $i - chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - while [ -z "$MYCONT" ]; do - let SLI=$RANDOM%10+10 - sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - done - chmod +x /tmp/mypostscript - GOTIT=1 - break - fi - done - if [ "$GOTIT" = "1" ] - then - break - fi - RAND=$(perl -e 'print int(rand(5)). "\n"') - sleep $RAND -done -PATH=/xcatpost:$PATH -export PATH -/tmp/mypostscript -updateflag.awk $MASTER 3002 -cd / -/xcatpost/#TABLE:nodelist:$NODE:node# -rm -Rf /xcatpost -rm -f /tmp/mypostscript -rmdir /xcatpost +mkdir -p /opt/xcat +cat >/opt/xcat/xcatdsklspost << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost# +chkconfig xcatpostinit off +EOF +chmod 755 /opt/xcat/xcatdsklspost + +chkconfig --add xcatpostinit ]]> diff --git a/xCAT-server/share/xcat/install/scripts/post.sles11.iscsi b/xCAT-server/share/xcat/install/scripts/post.sles11.iscsi index 1e0bfe439..7e4a4b96d 100644 --- a/xCAT-server/share/xcat/install/scripts/post.sles11.iscsi +++ b/xCAT-server/share/xcat/install/scripts/post.sles11.iscsi @@ -35,54 +35,22 @@ echo "$MASTER:/install /install nfs timeo=14,intr 1 2" >>/etc/fstab # check the arch for nodetype NODE_ARCH=#TABLE:nodetype:$NODE:arch# -# -# This script has not yet been updated to work with service nodes -# -for i in $(seq 1 20) -do - GOTIT=0 - for i in $MASTER_IPS - do - #mount -r $i:/install/postscripts /xcatpost - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/postscripts - wget -l inf -N -r --waitretry=10 --random-wait --retry-connrefused -t 0 -T 60 ftp://$i/post/otherpkgs/sles11/$NODE_ARCH +cat >/etc/init.d/xcatpostinit << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatpostinit# +EOF +chmod 755 /etc/init.d/xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc3.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc4.d/S84xcatpostinit +ln -s /etc/init.d/xcatpostinit /etc/init.d/rc5.d/S84xcatpostinit - if [ "$?" = "0" ] - then - XCATSERVER=$i:3001 - export XCATSERVER - mv $i/postscripts /xcatpost - rm -rf $i - chmod +x /xcatpost/* - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - while [ -z "$MYCONT" ]; do - let SLI=$RANDOM%10+10 - sleep $SLI - /xcatpost/getpostscript.awk |sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /tmp/mypostscript - MYCONT=`cat /tmp/mypostscript` - done - chmod +x /tmp/mypostscript - GOTIT=1 - break - fi - done - if [ "$GOTIT" = "1" ] - then - break - fi - RAND=$(perl -e 'print int(rand(5)). "\n"') - sleep $RAND -done -PATH=/xcatpost:$PATH -export PATH -/tmp/mypostscript -updateflag.awk $MASTER 3002 -cd / -/xcatpost/#TABLE:nodelist:$NODE:node# -rm -Rf /xcatpost -rm -f /tmp/mypostscript -rmdir /xcatpost +mkdir -p /opt/xcat +cat >/opt/xcat/xcatdsklspost << EOF +#INCLUDE_NOP:#TABLE:site:key=installdir:value#/postscripts/xcatdsklspost# +chkconfig xcatpostinit off +EOF +chmod 755 /opt/xcat/xcatdsklspost + +chkconfig --add xcatpostinit ]]> diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index d4c4b2507..756a9774c 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -110,10 +110,3 @@ if [ $# -gt 0 ]; then echo "returned" fi - - - - - - - diff --git a/xCAT/postscripts/xcatpostinit b/xCAT/postscripts/xcatpostinit index e2e759420..88a8c6a88 100755 --- a/xCAT/postscripts/xcatpostinit +++ b/xCAT/postscripts/xcatpostinit @@ -13,7 +13,9 @@ ### END INIT INFO # Source function library. -. /etc/rc.d/init.d/functions +if [ -x /etc/rc.d/init.d/functions ]; then + . /etc/rc.d/init.d/functions +fi case $1 in restart)