2021-03-22 14:35:11 +00:00
|
|
|
function set_confluent_vars() {
|
2021-05-03 16:48:08 +00:00
|
|
|
if [ -z "$confluent_mgr" ]; then
|
|
|
|
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
2021-03-22 14:35:11 +00:00
|
|
|
fi
|
2021-05-03 16:48:08 +00:00
|
|
|
if [ -z "$confluent_profile" ]; then
|
|
|
|
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
2021-03-22 14:35:11 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
fetch_remote() {
|
|
|
|
if [ -f /etc/confluent/ca.pem ]; then
|
|
|
|
curlargs=" --cacert /etc/confluent/ca.pem"
|
|
|
|
fi
|
|
|
|
set_confluent_vars
|
|
|
|
mkdir -p $(dirname $1)
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
2021-03-22 14:35:11 +00:00
|
|
|
if [ $? != 0 ]; then echo $1 failed to download; return 1; fi
|
|
|
|
}
|
|
|
|
|
|
|
|
run_remote_parts() {
|
|
|
|
scriptlist=$(python3 /etc/confluent/apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //')
|
|
|
|
for script in $scriptlist; do
|
2021-05-03 16:48:08 +00:00
|
|
|
run_remote $1/$script
|
2021-03-22 14:35:11 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
run_remote() {
|
|
|
|
requestedcmd="'$*'"
|
|
|
|
curlargs=""
|
|
|
|
if [ -f /etc/confluent/ca.pem ]; then
|
|
|
|
curlargs=" --cacert /etc/confluent/ca.pem"
|
|
|
|
fi
|
|
|
|
set_confluent_vars
|
|
|
|
echo
|
|
|
|
echo '---------------------------------------------------------------------------'
|
2021-05-03 16:48:08 +00:00
|
|
|
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
2021-03-22 14:35:11 +00:00
|
|
|
tmpdir=$(mktemp -d)
|
|
|
|
echo Executing in $tmpdir
|
|
|
|
cd $tmpdir
|
|
|
|
mkdir -p $(dirname $1)
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
2021-03-22 14:35:11 +00:00
|
|
|
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
|
|
|
|
set_confluent_vars
|
|
|
|
if [ -f /etc/confluent/ca.pem ]; then
|
|
|
|
curlargs=" --cacert /etc/confluent/ca.pem"
|
|
|
|
fi
|
|
|
|
echo '---------------------------------------------------------------------------'
|
2021-05-03 16:48:08 +00:00
|
|
|
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
2021-03-22 14:35:11 +00:00
|
|
|
tmpdir=$(mktemp -d)
|
|
|
|
echo Executing in $tmpdir
|
|
|
|
cd $tmpdir
|
|
|
|
mkdir -p $(dirname $1)
|
2021-05-03 16:48:08 +00:00
|
|
|
curl -f -sS $curlargs https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
2021-03-22 14:35:11 +00:00
|
|
|
if [ $? != 0 ]; then echo "'$*'" failed to download; return 1; fi
|
|
|
|
python3 $*
|
|
|
|
retcode=$?
|
|
|
|
echo "'$*' exited with code $retcode"
|
|
|
|
cd - > /dev/null
|
|
|
|
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 '---------------------------------------------------------------------------'
|
2021-05-03 16:48:08 +00:00
|
|
|
echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile
|
2021-03-22 14:35:11 +00:00
|
|
|
python3 $apiclient /confluent-api/self/remoteconfig/"$*" -d {}
|
|
|
|
python3 $apiclient /confluent-api/self/remoteconfig/status -w 204
|
|
|
|
echo
|
|
|
|
echo 'Completed remote configuration'
|
|
|
|
echo '---------------------------------------------------------------------------'
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|