Merge ~bjornt/maas:connect-to-snap-database into maas:master

Proposed by Björn Tillenius
Status: Merged
Approved by: Björn Tillenius
Approved revision: df242f5a2d07d3f256c8a21495a045633c15bbfb
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~bjornt/maas:connect-to-snap-database
Merge into: maas:master
Diff against target: 25 lines (+19/-0)
1 file modified
utilities/connect-to-snap-database (+19/-0)
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+331536@code.launchpad.net

Commit message

Add a script to make it easier to connect to the database the MAAS snap is using.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/utilities/connect-to-snap-database b/utilities/connect-to-snap-database
2new file mode 100755
3index 0000000..95c2beb
4--- /dev/null
5+++ b/utilities/connect-to-snap-database
6@@ -0,0 +1,19 @@
7+#!/bin/bash
8+usage="$(basename "$0") [-h] [--help]
9+
10+Connect psql to the database used by the installed MAAS snap.
11+
12+If you have MAAS installed as a snap, this script will read the
13+configuration file and connect the the snap's postgres database.
14+
15+It only works if the installed snap is configured to run the database server."
16+
17+if [ $1 == "-h" -o $1 == "--help" ];
18+then
19+ echo "$usage"
20+ exit 1
21+fi
22+
23+
24+export PGPASS=$(sudo cat /var/snap/maas/current/regiond.conf | grep database_pass | sed 's/database_pass: \(.*\)/\1/')
25+sudo psql -U maas -h /var/snap/maas/common/db -d maasdb

Subscribers

People subscribed via source and target branches