Merge lp:~patrick-hetu/charms/precise/postgresql/fix-gethostip-902672 into lp:charms/postgresql

Proposed by Patrick Hetu
Status: Merged
Approved by: Mark Mims
Approved revision: 23
Merge reported by: Mark Mims
Merged at revision: not available
Proposed branch: lp:~patrick-hetu/charms/precise/postgresql/fix-gethostip-902672
Merge into: lp:charms/postgresql
Diff against target: 47 lines (+7/-5)
3 files modified
hooks/common.sh (+2/-2)
hooks/db-relation-changed (+4/-2)
hooks/install (+1/-1)
To merge this branch: bzr merge lp:~patrick-hetu/charms/precise/postgresql/fix-gethostip-902672
Reviewer Review Type Date Requested Status
Mark Mims (community) Approve
Review via email: mp+110218@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mark Mims (mark-mims) wrote :

awesome... thanks for fixing this annoying issue!

I'll test this out against all our various providers... this went back and forth so much because of different responses to `private-address` from different providers. Hopefully gethostip'll work across the board... looks great so far.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/common.sh'
2--- hooks/common.sh 2011-11-22 10:03:11 +0000
3+++ hooks/common.sh 2012-06-14 02:50:25 +0000
4@@ -1,10 +1,10 @@
5
6-
7+ip=$(unit-get private-address)
8 database=${JUJU_REMOTE_UNIT///*}
9 database=${database//-/_}
10 user=${JUJU_REMOTE_UNIT///*}
11 user=${user//-/_}
12-host=`unit-get private-address`
13+host=`gethostip $ip | awk '{print $2}'`
14
15 admin() {
16 [[ $(basename $0) =~ admin ]]
17
18=== modified file 'hooks/db-relation-changed'
19--- hooks/db-relation-changed 2012-05-03 18:30:16 +0000
20+++ hooks/db-relation-changed 2012-06-14 02:50:25 +0000
21@@ -13,11 +13,13 @@
22 exit 0
23 fi
24
25+remote_ip=`gethostip $remote_host | awk '{print $2}'`
26+
27 grant_host_access() {
28- echo "host $(get_database_name) ${user} ${remote_host}/32 md5" >> /etc/postgresql/*/main/pg_hba.conf
29+ echo "host $(get_database_name) ${user} ${remote_ip}/32 md5" >> /etc/postgresql/*/main/pg_hba.conf
30 }
31 host_can_access() {
32- grep -q "$(get_database_name).*${user}.*${remote_host}" /etc/postgresql/*/main/pg_hba.conf
33+ grep -q "$(get_database_name).*${user}.*${remote_ip}" /etc/postgresql/*/main/pg_hba.conf
34 }
35 host_can_access || grant_host_access
36
37
38=== modified file 'hooks/install'
39--- hooks/install 2011-11-09 19:34:44 +0000
40+++ hooks/install 2012-06-14 02:50:25 +0000
41@@ -1,6 +1,6 @@
42 #!/bin/bash
43
44-sudo apt-get install -qqy --no-install-recommends postgresql pwgen
45+sudo apt-get install -qqy --no-install-recommends postgresql pwgen syslinux
46
47 echo "listen_addresses = '*'" >> /etc/postgresql/*/main/postgresql.conf
48

Subscribers

People subscribed via source and target branches