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

Subscribers

People subscribed via source and target branches