2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-22 14:05:32 +00:00

Merge pull request #2173 from immarvin/onxcatservice

refine the conditional code logic on  swith variables site table
This commit is contained in:
neo954
2016-11-22 02:50:38 -06:00
committed by GitHub
5 changed files with 22 additions and 21 deletions

View File

@ -160,12 +160,12 @@ mkdir -p /opt/xcat
cat >/opt/xcat/xcatinstallpost << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
if [ -f /xcatpost/mypostscript.post ]; then
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2 | tr -d \'\" | tr A-Z a-z`
fi
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]]; then
chkconfig xcatpostinit1 off
fi
echo "REBOOT=TRUE" >> /opt/xcat/xcatinf
echo "REBOOT=TRUE" >> /opt/xcat/xcatinfo
EOF
chmod 755 /opt/xcat/xcatinstallpost

View File

@ -28,6 +28,7 @@ if [[ $TFTPDIR != /* ]]; then
TFTPDIR="/"$TFTPDIR
fi
NODESTATUS=$(echo "$NODESTATUS"| tr -d \'\"| tr A-Z a-z)
(cat << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/updateflag.awk#
@ -337,18 +338,18 @@ cat >/opt/xcat/xcatinstallpost << 'EOF'
#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost#
if [ -f /xcatpost/mypostscript.post ]; then
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2`
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2 | tr -d \'\" | tr A-Z a-z`
fi
if [[ $OSVER == ubuntu* ]]; then
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]]; then
update-rc.d -f xcatpostinit1 remove
fi
if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
msgutil_r "$MASTER_IP" "debug" "update-rc.d -f xcatpostinit1 remove" "/var/log/xcat/xcat.log"
fi
else
if [ "$RUNBOOTSCRIPTS" != "'yes'" ] && [ "$NODESTATUS" = "'n'" ]; then
if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]] && [[ ! "$NODESTATUS" =~ ^(1|yes|y)$ ]]; then
chkconfig xcatpostinit1 off
if [ "$XCATDEBUGMODE" = "1" ] || [ "$XCATDEBUGMODE" = "2" ]; then
msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 disabled" "/var/log/xcat/xcat.log"

View File

@ -24,13 +24,13 @@
if [ -f /xcatpost/mypostscript.post ]; then
XCATDEBUGMODE=`grep 'XCATDEBUGMODE=' /xcatpost/mypostscript.post |cut -d= -f2|sed s/\'//g`
XCATDEBUGMODE=`grep 'XCATDEBUGMODE=' /xcatpost/mypostscript.post | cut -d= -f2 | tr -d \'\" | tr A-Z a-z`
MASTER_IP=`grep '^MASTER_IP=' /xcatpost/mypostscript.post |cut -d= -f2|sed s/\'//g`
else
for param in `cat /proc/cmdline`; do
key=`echo $param|awk -F= '{print $1}'`
if [ "$key" = "xcatdebugmode" ]; then
XCATDEBUGMODE=`echo $param|awk -F= '{print $2}'`
XCATDEBUGMODE=`echo $param|awk -F= '{print $2}'| tr -d \'\" | tr A-Z a-z`
fi
if [ "$key" = "LOGSERVER" ]; then
@ -654,7 +654,7 @@ fi
#save the USEFLOWCONTROL into the xcatinfo file
#for updatenode case, passwd in with the -f flag
if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ]; then
useflowcontrol=`grep '^USEFLOWCONTROL' /$xcatpost/mypostscript |cut -d= -f2`
useflowcontrol=`grep '^USEFLOWCONTROL' /$xcatpost/mypostscript |cut -d= -f2 | tr -d \'\" | tr A-Z a-z`
fi
if [ ! -f /opt/xcat/xcatinfo ]; then
mkdir -p /opt/xcat
@ -662,7 +662,7 @@ if [ ! -f /opt/xcat/xcatinfo ]; then
fi
if [ -n "$useflowcontrol" ]; then
# lets just put YES or NO in xcatinfo
if [ "$useflowcontrol" = "1" ] || [ "$useflowcontrol" = "yes" ] || [ "$useflowcontrol" = "YES" ]; then
if [[ "$useflowcontrol" =~ ^(1|yes|y)$ ]]; then
new_fc="YES"
else
new_fc="NO"
@ -711,11 +711,11 @@ if [ "$MODE" = "6" ]; then
echo "$TMP" > /$xcatpost/mypostscript
# get the RUNBOOTSCRIPTS site variable
if [ -f /$xcatpost/mypostscript ]; then
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /$xcatpost/mypostscript |cut -d= -f2`
RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /$xcatpost/mypostscript |cut -d= -f2 | tr -d \'\" | tr A-Z a-z `
fi
# if admin did not requested running of post boot scripts - then remove PBS
if [ "$RUNBOOTSCRIPTS" != "'yes'" ]; then
if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]]; then
#remove all the postscripts
TMP=`sed "/# postbootscripts-start-here/,/# postbootscripts-end-here/ d" /$xcatpost/mypostscript`
echo "$TMP" > /$xcatpost/mypostscript
@ -890,8 +890,8 @@ echo "$TMP" > /$xcatpost/mypostscript
if [ $NODE_DEPLOYMENT -eq 1 ] || [ "$MODE" = "4" ] || [ "$MODE" = "6" ]; then
#notify the server that we are done with netbooting
CNS=`grep NODESTATUS= /$xcatpost/mypostscript |awk -F = '{print $2}'`
if [ -z "$CNS" ] || [ "$CNS" != "'0'" -a "$CNS" != "'N'" -a "$CNS" != "'n'" ]; then
CNS=`grep NODESTATUS= /$xcatpost/mypostscript |awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z`
if [ -z "$CNS" ] || [[ "$CNS" =~ ^(1|yes|y)$ ]]; then
# TMP=`sed "/postscripts-start-here/ i\updateflag.awk \\$MASTER 3002 \\"installstatus configuring\\"" /$xcatpost/mypostscript`
# echo "$TMP"> /$xcatpost/mypostscript
if [ "$MODE" = "6" ]; then
@ -922,8 +922,8 @@ fi
DHCP_TMP=`sed 's/\(DHCPINTERFACES=\)\(.*\)$/\1"\2"/' /$xcatpost/mypostscript`
echo "$DHCP_TMP" > /$xcatpost/mypostscript
CLEANUPXCATPOST=`grep CLEANUPXCATPOST= /$xcatpost/mypostscript |awk -F = '{print $2}'`
if [ "$CLEANUPXCATPOST" = "'1'" ] || [ "$CLEANUPXCATPOST" = "'yes'" ]; then
CLEANUPXCATPOST=`grep CLEANUPXCATPOST= /$xcatpost/mypostscript |awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z`
if [[ "$CLEANUPXCATPOST" =~ ^(1|yes|y)$ ]]; then
echo "cd /" >> /$xcatpost/mypostscript
# /xcatpost might be read-only for statelite nodes
echo "rm -rf /$xcatpost/*" >> /$xcatpost/mypostscript

View File

@ -7,7 +7,7 @@
. /xcatpost/xcatlib.sh
if [ -f /xcatpost/mypostscript.post ]; then
XCATDEBUGMODE=`grep 'XCATDEBUGMODE=' /xcatpost/mypostscript.post |cut -d= -f2|sed s/\'//g`
XCATDEBUGMODE=`grep 'XCATDEBUGMODE=' /xcatpost/mypostscript.post |cut -d= -f2 | tr -d \'\" | tr A-Z a-z `
MASTER_IP=`grep '^MASTER_IP=' /xcatpost/mypostscript.post |cut -d= -f2|sed s/\'//g`
OSVER=`grep '^OSVER=' /xcatpost/mypostscript.post |cut -d= -f2|sed s/\'//g`
fi
@ -83,8 +83,8 @@ else
fi
CNS=`grep NODESTATUS= /xcatpost/mypostscript.post |awk -F = '{print $2}'`
if [ -z "$CNS" ] || [ "$CNS" != "'0'" -a "$CNS" != "'N'" -a "$CNS" != "'n'" ]; then
CNS=`grep NODESTATUS= /xcatpost/mypostscript.post |awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z`
if [ -z "$CNS" ] || [[ "$CNS" =~ ^(1|yes|y)$ ]]; then
#update the node status during the postbootscript running
#TMP=`sed "/postbootscripts-start-here/ i\updateflag.awk \\$MASTER 3002 \\"installstatus configuring\\"" /xcatpost/mypostscript.post`
#echo "$TMP"> /xcatpost/mypostscript.post

View File

@ -23,9 +23,9 @@ start)
REBOOT=`grep 'REBOOT' /opt/xcat/xcatinfo |cut -d= -f2 | tr -d \'\"`
fi
# if the xcatdsklspost file exists and this is a reboot - run xcatdsklspost with a mode of 6
if [ "$REBOOT" = "TRUE" -a -r /opt/xcat/xcatdsklspost ] && [[ "$RUNBOOTSCRIPTS" =~ ^1|yes|y$ ]]; then
if [ "$REBOOT" = "TRUE" -a -r /opt/xcat/xcatdsklspost ] && [[ "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]]; then
/opt/xcat/xcatdsklspost 6
elif [ "$REBOOT" = "TRUE" ] && [[ "$NODESTATUS" =~ ^1|yes|y$ ]]; then
elif [ "$REBOOT" = "TRUE" ] && [[ "$NODESTATUS" =~ ^(1|yes|y)$ ]]; then
/xcatpost/updateflag.awk $XCATSERVER 3002 "installstatus booted"
else
# run /opt/xcat/xcatinstallpost