From d23f9db6e025c94f66eb910bc427098a8ce6f0db Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 7 Oct 2021 08:38:29 -0400 Subject: [PATCH] Syncronize diskfull and diskless el8 and el9 functions --- .../profiles/default/scripts/functions | 33 ++++++++++--------- .../el8/profiles/default/scripts/functions | 12 +++++-- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions b/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions index 3fbfc0b1..b1364bd0 100644 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions +++ b/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions @@ -6,6 +6,18 @@ function test_mgr() { return 1 } +function confluentpython() { + if [ -x /usr/libexec/platform-python ]; then + /usr/libexec/platform-python $* + elif [ -x /usr/bin/python3 ]; then + /usr/bin/python3 $* + elif [ -x /usr/bin/python ]; then + /usr/bin/python $* + elif [ -x /usr/bin/python2 ]; then + /usr/bin/python2 $* + fi +} + function set_confluent_vars() { if [ -z "$nodename" ]; then nodename=$(grep ^NODENAME: /etc/confluent/confluent.info | awk '{print $2}') @@ -56,7 +68,7 @@ source_remote_parts() { if [ -f /etc/confluent/apiclient ]; then apiclient=/etc/confluent/apiclient fi - scriptlist=$(/usr/libexec/platform-python $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') + scriptlist=$(confluentpython $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') for script in $scriptlist; do source_remote $1/$script done @@ -69,7 +81,7 @@ run_remote_parts() { if [ -f /etc/confluent/apiclient ]; then apiclient=/etc/confluent/apiclient fi - scriptlist=$(/usr/libexec/platform-python $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') + scriptlist=$(confluentpython $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') for script in $scriptlist; do run_remote $1/$script done @@ -138,11 +150,7 @@ run_remote_python() { mkdir -p $(dirname $1) curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1 if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - if [ -x /usr/libexec/platform-python ]; then - /usr/libexec/platform-python $* - else - /usr/bin/python $* - fi + confluentpython $* retcode=$? echo "'$*' exited with code $retcode" cd - > /dev/null @@ -158,17 +166,12 @@ run_remote_config() { fi echo '---------------------------------------------------------------------------' echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - if [ -x /usr/libexec/platform-python ]; then - /usr/libexec/platform-python $apiclient /confluent-api/self/remoteconfig/"$*" -d {} - /usr/libexec/platform-python $apiclient /confluent-api/self/remoteconfig/status -w 204 - else - /usr/bin/python $apiclient /confluent-api/self/remoteconfig/"$*" -d {} - /usr/bin/python $apiclient /confluent-api/self/remoteconfig/status -w 204 - fi + confluentpython $apiclient /confluent-api/self/remoteconfig/"$*" -d {} + confluentpython $apiclient /confluent-api/self/remoteconfig/status -w 204 echo echo 'Completed remote configuration' echo '---------------------------------------------------------------------------' return } #If invoked as a command, use the arguments to actually run a function -(return 0 2>/dev/null) || $1 "${@:2}" \ No newline at end of file +(return 0 2>/dev/null) || $1 "${@:2}" diff --git a/confluent_osdeploy/el8/profiles/default/scripts/functions b/confluent_osdeploy/el8/profiles/default/scripts/functions index ef91b1c4..b1364bd0 100644 --- a/confluent_osdeploy/el8/profiles/default/scripts/functions +++ b/confluent_osdeploy/el8/profiles/default/scripts/functions @@ -64,7 +64,11 @@ fetch_remote() { source_remote_parts() { confluentscripttmpdir=$(mktemp -d) - scriptlist=$(confluentpython /etc/confluent/apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') + apiclient=/opt/confluent/bin/apiclient + if [ -f /etc/confluent/apiclient ]; then + apiclient=/etc/confluent/apiclient + fi + scriptlist=$(confluentpython $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') for script in $scriptlist; do source_remote $1/$script done @@ -73,7 +77,11 @@ source_remote_parts() { run_remote_parts() { confluentscripttmpdir=$(mktemp -d) - scriptlist=$(confluentpython /etc/confluent/apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') + apiclient=/opt/confluent/bin/apiclient + if [ -f /etc/confluent/apiclient ]; then + apiclient=/etc/confluent/apiclient + fi + scriptlist=$(confluentpython $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //') for script in $scriptlist; do run_remote $1/$script done