From b6aeb4571b80542edcfb4b5b24a0302909795378 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Thu, 31 Mar 2022 12:44:52 +0100 Subject: [PATCH] Update check_mongo script --- check_mongo.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check_mongo.sh b/check_mongo.sh index b02563a..b38b996 100755 --- a/check_mongo.sh +++ b/check_mongo.sh @@ -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}"