useful_scripts/check_mongo.sh

20 lines
534 B
Bash
Raw Normal View History

2021-10-12 19:24:31 +00:00
#!/bin/bash
machine=${1:-0}
model=${2:-controller}
read -d '' -r cmds <<'EOF'
2022-03-31 11:44:52 +00:00
user=$(sudo ls /var/lib/juju/agents/)
conf=/var/lib/juju/agents/${user}/agent.conf
password=$(sudo grep statepassword ${conf} | cut -d' ' -f2)
2021-10-12 19:24:31 +00:00
if [ -f /usr/lib/juju/mongo*/bin/mongo ]; then
client=/usr/lib/juju/mongo*/bin/mongo
else
client=/usr/bin/mongo
fi
2022-03-31 11:44:52 +00:00
${client} 127.0.0.1:37017/juju --authenticationDatabase admin --ssl --sslAllowInvalidCertificates --username "${user}" --password "${password}"
2021-10-12 19:24:31 +00:00
EOF
2022-03-31 11:44:52 +00:00
juju ssh -m ${model} ${machine} "${cmds}"
2021-10-12 19:24:31 +00:00