2020-10-05 16:57:46 -04:00
|
|
|
function set_confluent_vars() {
|
|
|
|
if [ -z "$mgr" ]; then
|
|
|
|
mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
|
|
|
fi
|
|
|
|
if [ -z "$profile" ]; then
|
|
|
|
profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch_remote() {
|
|
|
|
if [ -f /etc/confluent/ca.pem ]; then
|
|
|
|
curlargs=" --cacert /etc/confluent/ca.pem"
|
|
|
|
fi
|
|
|
|
set_confluent_vars
|
2020-10-09 14:07:58 -04:00
|
|
|
mkdir -p $(dirname $1)
|
2020-10-05 16:57:46 -04:00
|
|
|
curl -f -sS $curlargs https://$mgr/confluent-public/os/$profile/scripts/$1 > $1
|
|
|
|
if [ $? != 0 ]; then echo $1 failed to download; return 1; fi
|
|
|
|
}
|
|
|
|
|
2021-04-23 09:08:50 -04:00
|
|
|
run_remote_parts() {
|
|
|
|
scriptlist=$(/usr/libexec/platform-python /etc/confluent/apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //')
|
|
|
|
for script in $scriptlist; do
|
|
|
|
run_remote $1.d/$script
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2020-07-23 12:29:43 -04:00
|
|
|
run_remote() {
|
2020-08-21 10:33:56 -04:00
|
|
|
requestedcmd="'$*'"
|
2020-10-05 16:57:46 -04:00
|
|
|
curlargs=""
|
|
|
|
if [ -f /etc/confluent/ca.pem ]; then
|
|
|
|
curlargs=" --cacert /etc/confluent/ca.pem"
|
|
|
|
fi
|
|
|
|
set_confluent_vars
|
2020-08-21 10:35:28 -04:00
|
|
|
echo
|
|
|
|
echo '---------------------------------------------------------------------------'
|
2020-08-21 16:39:37 -04:00
|
|
|
echo Running $requestedcmd from https://$mgr/confluent-public/os/$profile/scripts/
|
2020-08-21 17:42:02 -04:00
|
|
|
tmpdir=$(mktemp -d)
|
|
|
|
echo Executing in $tmpdir
|
|
|
|
cd $tmpdir
|
2020-10-09 14:07:58 -04:00
|
|
|
mkdir -p $(dirname $1)
|
2020-10-05 16:57:46 -04:00
|
|
|
curl -f -sS $curlargs https://$mgr/confluent-public/os/$profile/scripts/$1 > $1
|
2020-08-21 17:42:02 -04:00
|
|
|
if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi
|
2020-07-23 12:29:43 -04:00
|
|
|
chmod +x $1
|
|
|
|
cmd=$1
|
2020-07-24 16:07:15 -04:00
|
|
|
if [ -x /usr/bin/chcon ]; then
|
2020-07-24 15:32:13 -04:00
|
|
|
chcon system_u:object_r:bin_t:s0 $cmd
|
|
|
|
fi
|
2020-07-23 12:29:43 -04:00
|
|
|
shift
|
|
|
|
./$cmd $*
|
2020-08-21 17:42:02 -04:00
|
|
|
retcode=$?
|
|
|
|
echo "$requestedcmd exited with code $retcode"
|
|
|
|
cd - > /dev/null
|
|
|
|
return $retcode
|
2020-07-23 12:29:43 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
run_remote_python() {
|
2020-08-21 17:03:12 -04:00
|
|
|
echo
|
2020-10-05 16:57:46 -04:00
|
|
|
set_confluent_vars
|
|
|
|
if [ -f /etc/confluent/ca.pem ]; then
|
|
|
|
curlargs=" --cacert /etc/confluent/ca.pem"
|
|
|
|
fi
|
2020-08-21 17:03:12 -04:00
|
|
|
echo '---------------------------------------------------------------------------'
|
|
|
|
echo Running python script "'$*'" from https://$mgr/confluent-public/os/$profile/scripts/
|
2020-08-21 17:42:02 -04:00
|
|
|
tmpdir=$(mktemp -d)
|
|
|
|
echo Executing in $tmpdir
|
|
|
|
cd $tmpdir
|
2020-10-09 14:07:58 -04:00
|
|
|
mkdir -p $(dirname $1)
|
2020-10-05 16:57:46 -04:00
|
|
|
curl -f -sS $curlargs https://$mgr/confluent-public/os/$profile/scripts/$1 > $1
|
2020-08-21 17:42:02 -04:00
|
|
|
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
|
2020-12-10 10:54:30 -05:00
|
|
|
if [ -x /usr/libexec/platform-python ]; then
|
|
|
|
/usr/libexec/platform-python $*
|
|
|
|
else
|
|
|
|
/usr/bin/python $*
|
|
|
|
fi
|
2020-08-21 17:42:02 -04:00
|
|
|
retcode=$?
|
|
|
|
echo "'$*' exited with code $retcode"
|
|
|
|
cd - > /dev/null
|
|
|
|
return $retcode
|
2020-07-23 12:29:43 -04:00
|
|
|
}
|
2021-04-23 09:08:50 -04:00
|
|
|
|
|
|
|
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 $mgr under profile $profile
|
|
|
|
if [ -x /usr/libexec/platform-python ]; then
|
|
|
|
/usr/libexec/platform-python $apiclient /confluent-api/self/remoteconfig/"$*" -d {}
|
|
|
|
/usr/libexec/platform-python $apiclient /confluent-api/self/remoteconfig/status -w 204
|
|
|
|
else
|
|
|
|
/usr/bin/python $apiclient /confluent-api/self/remoteconfig/"$*" -d {}
|
|
|
|
/usr/bin/python $apiclient /confluent-api/self/remoteconfig/status -w 204
|
|
|
|
fi
|
|
|
|
echo
|
|
|
|
echo 'Completed remote configuration'
|
|
|
|
echo '---------------------------------------------------------------------------'
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|