#!/bin/sh
# Usage: juju-db
# Connect to the database holding the state of the current Juju controller.
set -e
while [ $# -ge 1 ]; do
key="$1"
case $key in
-h|--help)
echo usage: `basename $0`
echo connect to the database holding the state of the current Juju controller
exit 0
;;
--description)
echo conect to the Juju MongoDB
exit 0
;;
*)
echo unexpected parameters passed: $*
exit 1
;;
esac
shift
done
port=`juju controller-config state-port`
password=`juju ssh -m controller 0 sudo grep statepassword: /var/lib/juju/agents/machine-0/agent.conf | cut -b16- | sed 's/\\r//'`
echo state port: $port
echo password: $password
juju ssh -m controller 0 \
sudo /usr/lib/juju/mongo3.2/bin/mongo 127.0.0.1:$port/admin --ssl \
--sslAllowInvalidCertificates --sslPEMKeyPassword /var/lib/juju/shared-secret \
--sslPEMKeyFile /var/lib/juju/server.pem -u machine-0 -p $password