#!/bin/sh
# Usage: juju-db
# Connect to the database holding the state of the current Juju controller.
password=`juju ssh -m controller 0 sudo grep statepassword: /var/lib/juju/agents/machine-0/agent.conf | cut -b16- | sed 's/\\r//g'`
echo password: $password
juju ssh -m controller 0 \
sudo /usr/lib/juju/mongo3.2/bin/mongo 127.0.0.1:37017/admin --ssl \
--sslAllowInvalidCertificates --sslPEMKeyPassword /var/lib/juju/shared-secret \
--sslPEMKeyFile /var/lib/juju/server.pem -u machine-0 -p $password