Update check_mongo script

This commit is contained in:
Arif Ali 2022-03-31 12:44:52 +01:00
parent f1d511a082
commit b6aeb4571b
Signed by: arif
GPG Key ID: 369608FBA1353A70

View File

@ -4,16 +4,16 @@ machine=${1:-0}
model=${2:-controller}
read -d '' -r cmds <<'EOF'
conf=/var/lib/juju/agents/machine-*/agent.conf
user=`sudo grep tag $conf | cut -d' ' -f2`
password=`sudo grep statepassword $conf | cut -d' ' -f2`
user=$(sudo ls /var/lib/juju/agents/)
conf=/var/lib/juju/agents/${user}/agent.conf
password=$(sudo grep statepassword ${conf} | cut -d' ' -f2)
if [ -f /usr/lib/juju/mongo*/bin/mongo ]; then
client=/usr/lib/juju/mongo*/bin/mongo
else
client=/usr/bin/mongo
fi
$client 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --username "$user" --password "$password"
${client} 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --username "${user}" --password "${password}"
EOF
juju ssh -m $model $machine "$cmds"
juju ssh -m ${model} ${machine} "${cmds}"