diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat b/xCAT-server/share/xcat/install/scripts/post.xcat index bb40d0f22..f4c4c6c4e 100755 --- a/xCAT-server/share/xcat/install/scripts/post.xcat +++ b/xCAT-server/share/xcat/install/scripts/post.xcat @@ -358,38 +358,10 @@ fi mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost << 'EOF' #!/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. +#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/postinit.sh# [ -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 - 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" "xcat.xcatinstallpost" - fi -else - 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" "xcat.xcatinstallpost" - fi - fi - -fi +# Disable the service before a postscript can reboot the node. +xcat_disable_postinit legacy #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat.ng b/xCAT-server/share/xcat/install/scripts/post.xcat.ng index 6a63a55f0..ea687c461 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat.ng +++ b/xCAT-server/share/xcat/install/scripts/post.xcat.ng @@ -356,30 +356,10 @@ chmod 0755 /opt/xcat/xcatpostinit1 mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost <<'EOF' #!/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. +#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/postinit.sh# [ -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 - case "$XCATDEBUGMODE" in - "1"|"2") - msgutil_r "$MASTER_IP" "debug" "systemctl disable xcatpostinit1.service" "/var/log/xcat/xcat.log" "xcat.xcatinstallpost" - ;; - esac -fi +# Disable the service before a postscript can reboot the node. +xcat_disable_postinit systemd #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# diff --git a/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 b/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 index 78f0e09a9..5c66ac917 100644 --- a/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 +++ b/xCAT-server/share/xcat/install/scripts/post.xcat.rhels10 @@ -356,30 +356,10 @@ chmod 0755 /opt/xcat/xcatpostinit1 mkdir -p /opt/xcat cat >/opt/xcat/xcatinstallpost <<'EOF' #!/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. +#INCLUDE:#ENV:XCATROOT#/share/xcat/install/scripts/postinit.sh# [ -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 - case "$XCATDEBUGMODE" in - "1"|"2") - msgutil_r "$MASTER_IP" "debug" "systemctl disable xcatpostinit1.service" "/var/log/xcat/xcat.log" "xcat.xcatinstallpost" - ;; - esac -fi +# Disable the service before a postscript can reboot the node. +xcat_disable_postinit systemd #INCLUDE:#TABLE:site:key=installdir:value#/postscripts/xcatinstallpost# diff --git a/xCAT-server/share/xcat/install/scripts/postinit.sh b/xCAT-server/share/xcat/install/scripts/postinit.sh new file mode 100644 index 000000000..b3be593b5 --- /dev/null +++ b/xCAT-server/share/xcat/install/scripts/postinit.sh @@ -0,0 +1,40 @@ +xcat_disable_postinit() +{ + if [ -f /xcatpost/mypostscript.post ]; then + if [ "$1" = legacy ]; then + OSVER=`grep '^OSVER=' /xcatpost/mypostscript.post | cut -d= -f2 | sed s/\'//g` + fi + 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" + + case "$1:$OSVER" in + legacy:ubuntu*) + case "$RUNBOOTSCRIPTS" in + 1|yes|y) ;; + *) update-rc.d -f xcatpostinit1 remove ;; + esac + case "$XCATDEBUGMODE" in + 1|2) msgutil_r "$MASTER_IP" "debug" "update-rc.d -f xcatpostinit1 remove" "/var/log/xcat/xcat.log" "xcat.xcatinstallpost" ;; + esac + ;; + *) + case "$RUNBOOTSCRIPTS" in 1|yes|y) return 0 ;; esac + case "$NODESTATUS" in 1|yes|y) return 0 ;; esac + if [ "$1" = legacy ]; then + chkconfig xcatpostinit1 off + case "$XCATDEBUGMODE" in + 1|2) msgutil_r "$MASTER_IP" "debug" "service xcatpostinit1 disabled" "/var/log/xcat/xcat.log" "xcat.xcatinstallpost" ;; + esac + else + systemctl disable xcatpostinit1.service + case "$XCATDEBUGMODE" in + 1|2) msgutil_r "$MASTER_IP" "debug" "systemctl disable xcatpostinit1.service" "/var/log/xcat/xcat.log" "xcat.xcatinstallpost" ;; + esac + fi + ;; + esac +}