From 3d5a1b7dd892e4fd91d4c93996180cdfd4ec0207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sun, 30 Aug 2026 23:37:44 -0300 Subject: [PATCH] refactor(xcatdsklspost): share mypostscript fetch pipeline --- xCAT/postscripts/xcatdsklspost | 10 +++------- xCAT/postscripts/xcatlib.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index b0bc6d248..13110575d 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -182,7 +182,6 @@ download_mypostscript() } - # pmatch determines if 1st argument string is matched by 2nd argument pattern pmatch () @@ -680,6 +679,7 @@ fi # We need to call getpostscript.awk . if [ ! -x /$xcatpost/mypostscript ]; then + . /$xcatpost/xcatlib.sh echolog "debug" "no pre-generated mypostscript., trying to get it with getpostscript.awk..." GETPOSTSCRIPT_ARGS="" if [ -n "$node_short" ]; then @@ -699,10 +699,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then useflowcontrol=0 fi fi - /$xcatpost/getpostscript.awk $GETPOSTSCRIPT_ARGS | egrep '' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /$xcatpost/mypostscript; - - - MYCONT=`grep MASTER /$xcatpost/mypostscript` + MYCONT=`fetch_mypostscript "$xcatpost" $GETPOSTSCRIPT_ARGS` MAX_RETRIES=10 RETRY=0 while [ -z "$MYCONT" ]; do @@ -733,8 +730,7 @@ if [ ! -x /$xcatpost/mypostscript ]; then useflowcontrol=0 fi fi - /$xcatpost/getpostscript.awk $GETPOSTSCRIPT_ARGS | egrep '' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' | sed -e 's/<//g' -e 's/&/\&/g' -e 's/"/"/g' -e "s/'/'/g" > /$xcatpost/mypostscript; - MYCONT=`grep MASTER /$xcatpost/mypostscript` + MYCONT=`fetch_mypostscript "$xcatpost" $GETPOSTSCRIPT_ARGS` if [ ! -z "$MYCONT" ]; then break; fi diff --git a/xCAT/postscripts/xcatlib.sh b/xCAT/postscripts/xcatlib.sh index 1dbef7b35..69c25f9da 100755 --- a/xCAT/postscripts/xcatlib.sh +++ b/xCAT/postscripts/xcatlib.sh @@ -826,3 +826,19 @@ function msgutil_r { function msgutil { msgutil_r "" "$@" } + +function fetch_mypostscript { + local postroot + postroot=$1 + shift + + /$postroot/getpostscript.awk "$@" | + egrep '' | + sed -e 's/<[^>]*>//g' | + egrep -v '^ *$' | + sed -e 's/^ *//' | + sed -e 's/<//g' -e 's/&/\&/g' \ + -e 's/"/"/g' -e "s/'/'/g" > /$postroot/mypostscript + + grep MASTER /$postroot/mypostscript +}