diff --git a/confluent_osdeploy/debian/profiles/default/scripts/functions b/confluent_osdeploy/debian/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/debian/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/el10-diskless/profiles/default/scripts/functions b/confluent_osdeploy/el10-diskless/profiles/default/scripts/functions deleted file mode 120000 index b20bb48f..00000000 --- a/confluent_osdeploy/el10-diskless/profiles/default/scripts/functions +++ /dev/null @@ -1 +0,0 @@ -../../../../el9-diskless/profiles/default/scripts/functions \ No newline at end of file diff --git a/confluent_osdeploy/el7-diskless/profiles/default/scripts/functions b/confluent_osdeploy/el7-diskless/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/el7-diskless/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/el7/profiles/default/scripts/functions b/confluent_osdeploy/el7/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/el7/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions b/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/el8-diskless/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/el8/profiles/default/scripts/functions b/confluent_osdeploy/el8/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/el8/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/el9-diskless/profiles/default/scripts/functions b/confluent_osdeploy/el9-diskless/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/el9-diskless/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/genesis/profiles/default/scripts/functions b/confluent_osdeploy/genesis/profiles/default/scripts/functions deleted file mode 100644 index 97c3d54d..00000000 --- a/confluent_osdeploy/genesis/profiles/default/scripts/functions +++ /dev/null @@ -1,168 +0,0 @@ -#!/bin/bash - -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}') - fi - confluent_mgr=$(confluentpython /opt/confluent/bin/apiclient -c) - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export nodename confluent_mgr confluent_profile -} - -fetch_remote() { - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - mkdir -p $(dirname $1) - confluentpython $apiclient /confluent-public/os/$confluent_profile/scripts/$1 -o $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - unsettmpdir=1 - fi - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - unsettmpdir=1 - fi - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - confluentpython /opt/confluent/bin/apiclient /confluent-public/os/$confluent_profile/scripts/$1 -o $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/rhvh4/profiles/default/scripts/functions b/confluent_osdeploy/rhvh4/profiles/default/scripts/functions deleted file mode 100644 index 5d6189e6..00000000 --- a/confluent_osdeploy/rhvh4/profiles/default/scripts/functions +++ /dev/null @@ -1,38 +0,0 @@ -run_remote() { - requestedcmd="'$*'" - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$mgr/confluent-public/os/$profile/scripts/ - tmpdir=$(mktemp -d) - echo Executing in $tmpdir - cd $tmpdir - curl -f -sS https://$mgr/confluent-public/os/$profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - echo "$requestedcmd exited with code $retcode" - cd - > /dev/null - return $retcode -} - -run_remote_python() { - echo - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$mgr/confluent-public/os/$profile/scripts/ - tmpdir=$(mktemp -d) - echo Executing in $tmpdir - cd $tmpdir - curl -f -sS https://$mgr/confluent-public/os/$profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - /usr/libexec/platform-python $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - return $retcode -} diff --git a/confluent_osdeploy/suse15-diskless/profiles/default/scripts/functions b/confluent_osdeploy/suse15-diskless/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/suse15-diskless/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/suse15/profiles/hpc/scripts/functions b/confluent_osdeploy/suse15/profiles/hpc/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/suse15/profiles/hpc/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/suse15/profiles/server/scripts/functions b/confluent_osdeploy/suse15/profiles/server/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/suse15/profiles/server/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/functions b/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/ubuntu18.04/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/functions b/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/functions deleted file mode 100644 index 5df56438..00000000 --- a/confluent_osdeploy/ubuntu20.04-diskless/profiles/default/scripts/functions +++ /dev/null @@ -1,198 +0,0 @@ -#!/bin/bash -function test_mgr() { - if curl -s https://${1}/confluent-api/ > /dev/null; then - return 0 - fi - 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}') - fi - confluent_nodename=$nodename - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_mgr confluent_profile nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - unsettmpdir=1 - fi - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - unsettmpdir=1 - fi - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - confluentscripttmpdir=$(mktemp -d /tmp/confluentscripts.XXXXXXXXX) - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - 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 - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/functions b/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/ubuntu20.04/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}" diff --git a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/functions b/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/functions deleted file mode 100644 index a88ba210..00000000 --- a/confluent_osdeploy/ubuntu22.04/profiles/default/scripts/functions +++ /dev/null @@ -1,216 +0,0 @@ -#!/bin/bash -function test_mgr() { - whost=$1 - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - if curl -gs https://${whost}/confluent-api/ > /dev/null; then - return 0 - fi - return 1 -} - -function initconfluentscriptstmp() { - if [ -z "$confluentscripttmpdir" ]; then - mkdir -p /opt/confluent/tmpexec - confluentscripttmpdir=$(mktemp -d /opt/confluent/tmpexec/confluentscripts.XXXXXXXXX) - fi -} - -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}') - fi - if [[ "$confluent_mgr" == *"%"* ]]; then - confluent_mgr="" - fi - if [ -z "$confluent_mgr" ]; then - confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if ! test_mgr $confluent_mgr; then - confluent_mgr=$(grep ^deploy_server_v6: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - if [[ "$confluent_mgr" = *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - fi - if ! test_mgr $confluent_mgr; then - BESTMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|1$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - OKMGRS=$(grep ^EXTMGRINFO: /etc/confluent/confluent.info | grep '|0$' | sed -e 's/EXTMGRINFO: //' -e 's/|.*//') - for confluent_mgr in $BESTMGRS $OKMGRS; do - if [[ $confluent_mgr == *":"* ]]; then - confluent_mgr="[$confluent_mgr]" - fi - if test_mgr $confluent_mgr; then - break - fi - done - fi - fi - if [ -z "$confluent_profile" ]; then - confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //') - fi - export confluent_profile confluent_mgr nodename -} - -fetch_remote() { - curlargs="" - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - set_confluent_vars - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi -} - -source_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -run_remote_parts() { - unset confluentscripttmpdir - initconfluentscriptstmp - 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 - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir -} - -source_remote() { - set_confluent_vars - unsettmpdir=0 - echo - echo '---------------------------------------------------------------------------' - echo Sourcing $1 from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - initconfluentscriptstmp - echo Sourcing from $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $1 failed to download; return 1; fi - chmod +x $1 - cmd=$1 - shift - source ./$cmd - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - rm -rf $confluentscripttmpdir - return $retcode -} - -run_remote() { - requestedcmd="'$*'" - unsettmpdir=0 - set_confluent_vars - echo - echo '---------------------------------------------------------------------------' - echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - if [ -z "$confluentscripttmpdir" ]; then - unsettmpdir=1 - fi - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - fetch_remote $1 - if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi - chmod +x $1 - cmd=$1 - if [ -x /usr/bin/chcon ]; then - chcon system_u:object_r:bin_t:s0 $cmd - fi - shift - ./$cmd $* - retcode=$? - if [ $retcode -ne 0 ]; then - echo "$requestedcmd exited with code $retcode" - fi - cd - > /dev/null - if [ "$unsettmpdir" = 1 ]; then - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - unsettmpdir=0 - fi - return $retcode -} - -run_remote_python() { - echo - set_confluent_vars - if [ -f /etc/confluent/ca.pem ]; then - curlargs=" --cacert /etc/confluent/ca.pem" - fi - echo '---------------------------------------------------------------------------' - echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/ - unset confluentscripttmpdir - initconfluentscriptstmp - echo Executing in $confluentscripttmpdir - cd $confluentscripttmpdir - mkdir -p $(dirname $1) - whost=$confluent_mgr - if [[ "$whost" == *:* ]] && [[ "$whost" != *[* ]] ; then - whost="[$whost]" - fi - curl -gf -sS $curlargs https://$whost/confluent-public/os/$confluent_profile/scripts/$1 > $1 - if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi - confluentpython $* - retcode=$? - echo "'$*' exited with code $retcode" - cd - > /dev/null - rm -rf $confluentscripttmpdir - unset confluentscripttmpdir - return $retcode -} - -run_remote_config() { - echo - set_confluent_vars - apiclient=/opt/confluent/bin/apiclient - if [ -f /etc/confluent/apiclient ]; then - apiclient=/etc/confluent/apiclient - fi - echo '---------------------------------------------------------------------------' - echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile - 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}"