mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-25 11:01:09 +00:00
508e5b4a46
Behave more consistently
91 lines
3.1 KiB
Plaintext
91 lines
3.1 KiB
Plaintext
function set_confluent_vars() {
|
|
if [ -z "$confluent_mgr" ]; then
|
|
confluent_mgr=$(grep ^deploy_server: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
|
fi
|
|
if [ -z "$confluent_profile" ]; then
|
|
confluent_profile=$(grep ^profile: /etc/confluent/confluent.deploycfg | sed -e 's/[^ ]*: //')
|
|
fi
|
|
}
|
|
|
|
run_remote() {
|
|
set_confluent_vars
|
|
requestedcmd="'$*'"
|
|
echo
|
|
echo '---------------------------------------------------------------------------'
|
|
echo Running $requestedcmd from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
|
tmpdir=$(mktemp -d)
|
|
echo Executing in $tmpdir
|
|
cd $tmpdir
|
|
mkdir -p $(dirname $1)
|
|
curl -f -sS https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
|
if [ $? != 0 ]; then echo $requestedcmd failed to download; return 1; fi
|
|
chmod +x $1
|
|
cmd=$1
|
|
shift
|
|
./$cmd $*
|
|
retcode=$?
|
|
echo "$requestedcmd exited with code $retcode"
|
|
cd - > /dev/null
|
|
return $retcode
|
|
}
|
|
|
|
source_remote_parts() {
|
|
confluentscripttmpdir=$(mktemp -d)
|
|
apiclient=/opt/confluent/bin/apiclient
|
|
if [ -f /etc/confluent/apiclient ]; then
|
|
apiclient=/etc/confluent/apiclient
|
|
fi
|
|
scriptlist=$(/usr/bin/python3 $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //')
|
|
for script in $scriptlist; do
|
|
source_remote $1/$script
|
|
done
|
|
unset confluentscripttmpdir
|
|
}
|
|
|
|
run_remote_parts() {
|
|
confluentscripttmpdir=$(mktemp -d)
|
|
apiclient=/opt/confluent/bin/apiclient
|
|
if [ -f /etc/confluent/apiclient ]; then
|
|
apiclient=/etc/confluent/apiclient
|
|
fi
|
|
scriptlist=$(/usr/bin/python3 $apiclient /confluent-api/self/scriptlist/$1|sed -e 's/^- //')
|
|
for script in $scriptlist; do
|
|
run_remote $1/$script
|
|
done
|
|
unset confluentscripttmpdir
|
|
}
|
|
|
|
run_remote_python() {
|
|
echo
|
|
echo '---------------------------------------------------------------------------'
|
|
echo Running python script "'$*'" from https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/
|
|
tmpdir=$(mktemp -d)
|
|
echo Executing in $tmpdir
|
|
cd $tmpdir
|
|
mkdir -p $(dirname $1)
|
|
curl -f -sS https://$confluent_mgr/confluent-public/os/$confluent_profile/scripts/$1 > $1
|
|
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 '---------------------------------------------------------------------------'
|
|
echo Requesting to run remote configuration for "'$*'" from $confluent_mgr under profile $confluent_profile
|
|
python3 $apiclient /confluent-api/self/remoteconfig/"$*" -d {}
|
|
python3 $apiclient /confluent-api/self/remoteconfig/status -w 204
|
|
echo
|
|
echo 'Completed remote configuration'
|
|
echo '---------------------------------------------------------------------------'
|
|
return
|
|
}
|