Skip to content

Instantly share code, notes, and snippets.

@mitechie
Created March 2, 2017 15:02
Show Gist options
  • Save mitechie/f95c123ec18ebe594b27f524ff144d9d to your computer and use it in GitHub Desktop.
Save mitechie/f95c123ec18ebe594b27f524ff144d9d to your computer and use it in GitHub Desktop.
juju-db connection script
#!/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 connect 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 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment