diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index ad53a5c60..d6ac63ff0 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -360,11 +360,22 @@ fi #create the xcatinstallpost mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost << 'EOF' -#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# - +#!/bin/bash +# Disable the xcatpostinit1 service *before* running the postscripts (the +# INCLUDE at the end). If a postscript reboots the node, the service is +# already disabled, so the whole postscript set is not run again on reboot. +# The disable decision needs OSVER, RUNBOOTSCRIPTS and NODESTATUS, which the +# included script would otherwise set; read them up front (it re-reads them), +# and source xcatlib.sh so msgutil_r is available for the debug messages. +[ -f /xcatpost/xcatlib.sh ] && . /xcatpost/xcatlib.sh if [ -f /xcatpost/mypostscript.post ]; then + OSVER=`grep '^OSVER=' /xcatpost/mypostscript.post |cut -d= -f2|sed s/\'//g` RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post |cut -d= -f2 | tr -d \'\" | tr A-Z a-z` + 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` fi +[ -f /xcatpost/mypostscript ] && NODESTATUS=`grep 'NODESTATUS=' /xcatpost/mypostscript |awk -F = '{print $2}'|tr -d \'\" | tr A-Z a-z ` +[ -z "$NODESTATUS" ] && NODESTATUS="1" if [[ $OSVER == ubuntu* ]]; then if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]]; then @@ -383,6 +394,8 @@ else fi +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# + EOF chmod 755 /opt/xcat/xcatinstallpost diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat.ng b/xCAT-server/share/xcat/install/scripts/post.xcat.ng index bbabcd1fe..78f0e09a9 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat.ng +++ b/xCAT-server/share/xcat/install/scripts/post.xcat.ng @@ -355,12 +355,22 @@ chmod 0755 /opt/xcat/xcatpostinit1 # Create the xcatinstallpost mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost <<'EOF' -#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# - +#!/bin/bash +# Disable the xcatpostinit1 service *before* running the postscripts (the +# INCLUDE at the end). If a postscript reboots the node, the service is +# already disabled, so the whole postscript set is not run again on reboot. +# The disable decision needs RUNBOOTSCRIPTS and NODESTATUS, which the included +# script would otherwise set; read them up front (it re-reads them), and source +# xcatlib.sh so msgutil_r is available for the debug message. +[ -f /xcatpost/xcatlib.sh ] && . /xcatpost/xcatlib.sh if [ -f /xcatpost/mypostscript.post ] then RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post | cut -d= -f2 | tr -d \'\" | tr A-Z a-z` + 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` fi +[ -f /xcatpost/mypostscript ] && NODESTATUS=`grep 'NODESTATUS=' /xcatpost/mypostscript | awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z` +[ -z "$NODESTATUS" ] && NODESTATUS="1" if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]] && [[ ! "$NODESTATUS" =~ ^(1|yes|y)$ ]]; then systemctl disable xcatpostinit1.service @@ -371,6 +381,8 @@ if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]] && [[ ! "$NODESTATUS" =~ ^(1|yes|y)$ esac fi +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# + EOF chmod 0755 /opt/xcat/xcatinstallpost diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 b/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 index bbabcd1fe..78f0e09a9 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 +++ b/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 @@ -355,12 +355,22 @@ chmod 0755 /opt/xcat/xcatpostinit1 # Create the xcatinstallpost mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost <<'EOF' -#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# - +#!/bin/bash +# Disable the xcatpostinit1 service *before* running the postscripts (the +# INCLUDE at the end). If a postscript reboots the node, the service is +# already disabled, so the whole postscript set is not run again on reboot. +# The disable decision needs RUNBOOTSCRIPTS and NODESTATUS, which the included +# script would otherwise set; read them up front (it re-reads them), and source +# xcatlib.sh so msgutil_r is available for the debug message. +[ -f /xcatpost/xcatlib.sh ] && . /xcatpost/xcatlib.sh if [ -f /xcatpost/mypostscript.post ] then RUNBOOTSCRIPTS=`grep 'RUNBOOTSCRIPTS=' /xcatpost/mypostscript.post | cut -d= -f2 | tr -d \'\" | tr A-Z a-z` + 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` fi +[ -f /xcatpost/mypostscript ] && NODESTATUS=`grep 'NODESTATUS=' /xcatpost/mypostscript | awk -F = '{print $2}' | tr -d \'\" | tr A-Z a-z` +[ -z "$NODESTATUS" ] && NODESTATUS="1" if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]] && [[ ! "$NODESTATUS" =~ ^(1|yes|y)$ ]]; then systemctl disable xcatpostinit1.service @@ -371,6 +381,8 @@ if [[ ! "$RUNBOOTSCRIPTS" =~ ^(1|yes|y)$ ]] && [[ ! "$NODESTATUS" =~ ^(1|yes|y)$ esac fi +#INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# + EOF chmod 0755 /opt/xcat/xcatinstallpost