Merge lp:~nijaba/charms/oneiric/limesurvey/trunk into lp:charms/oneiric/limesurvey

Proposed by Nick Barcet
Status: Merged
Merged at revision: 11
Proposed branch: lp:~nijaba/charms/oneiric/limesurvey/trunk
Merge into: lp:charms/oneiric/limesurvey
Diff against target: 280 lines (+180/-47)
7 files modified
config.yaml (+53/-0)
hooks/config-changed (+13/-0)
hooks/db-relation-changed (+10/-37)
hooks/limesurvey-common (+76/-0)
limesurvey.yaml (+7/-0)
readme.txt (+20/-9)
revision (+1/-1)
To merge this branch: bzr merge lp:~nijaba/charms/oneiric/limesurvey/trunk
Reviewer Review Type Date Requested Status
Clint Byrum Pending
Review via email: mp+84696@code.launchpad.net

This proposal supersedes a proposal from 2011-12-06.

Description of the change

* add a few site specific configuration parameters, including mysql table type.
* implement config-changed hook
* merge with trunk done

To post a comment you must log in.
Revision history for this message
Clint Byrum (clint-fewbar) wrote : Posted in a previous version of this proposal

Hi Nick. It would seem that there are some conflicts between these changes (which all look great) and the ones I did to make db-relation-changed idempotent.

Once those conflicts are resolved I'll merge it into the main charm.

review: Needs Fixing
Revision history for this message
Nick Barcet (nijaba) wrote : Posted in a previous version of this proposal

Merge done.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'config.yaml'
2--- config.yaml 1970-01-01 00:00:00 +0000
3+++ config.yaml 2011-12-07 00:02:26 +0000
4@@ -0,0 +1,53 @@
5+options:
6+ mysql-tabletype:
7+ default: myISAM
8+ type: string
9+ description: Storage engine mysql should use when creating survey results tables and token tables. Default is myISAM, but InnoDB should be much faster with concurent access. This setting cannot be changed after initial deployment.
10+ db-persistent:
11+ default: false
12+ type: string
13+ description: If you want to enable persistent database connections set this to 'true' - this might be faster for some database drivers. This setting cannot be changed after initial deployment.
14+ site-name:
15+ default: Limesurvey
16+ type: string
17+ description: The official name of the site (appears in the Window title)
18+ default-admin-pass:
19+ default: password
20+ type: string
21+ description: Default password for the admin user. This setting cannot be changed after initial deployment.
22+ default-lang:
23+ default: en
24+ type: string
25+ description: The default language to use - the available languages are the directory names in the /locale dir - for example de = German
26+ admin-email:
27+ default: thisaddress@hasnotbeen.set
28+ type: string
29+ description: The default email address of the site administrator (displayed on the front page).
30+ admin-bounce:
31+ default: thisaddress@hasnotbeen.set
32+ type: string
33+ description: The default email address used for error notification of sent messages for the site administrator (Return-Path).
34+ admin-name:
35+ default: MyName
36+ type: string
37+ description: Name of the site admin
38+ mail-method:
39+ default: mail
40+ type: string
41+ description: Mailer type to use. Value can be 'mail' (internal phpmailer), 'sendmail', 'qmail', 'smtp'
42+ mail-smtp-host:
43+ default: smtphost.address:25
44+ type: string
45+ description: Address of the SMTP host and optional port.
46+ mail-smtp-user:
47+ default: ""
48+ type: string
49+ description: SMTP authorisation username - only set this if your server requires authorization - if you set it you HAVE to set a password too
50+ mail-smtp-password:
51+ default: ""
52+ type: string
53+ description: SMTP authorisation password - empty password is not allowed
54+ mail-smtp-ssl:
55+ default: ""
56+ type: string
57+ description: Set this to 'ssl' or 'tls' to use SSL/TLS for SMTP connection
58
59=== added file 'hooks/config-changed'
60--- hooks/config-changed 1970-01-01 00:00:00 +0000
61+++ hooks/config-changed 2011-12-07 00:02:26 +0000
62@@ -0,0 +1,13 @@
63+#!/bin/bash
64+
65+set -eu # -x for verbose logging to juju debug-log
66+
67+FORMULA_DIR=$(dirname $0)
68+if [[ -e $FORMULA_DIR/limesurvey-common ]] ; then
69+ . $FORMULA_DIR/limesurvey-common
70+else
71+ echo "ERROR: Could not load limesurvey-common from $FORMULA_DIR"
72+fi
73+
74+# Write the limesurvey config
75+set-config
76
77=== modified file 'hooks/db-relation-changed'
78--- hooks/db-relation-changed 2011-12-06 21:49:38 +0000
79+++ hooks/db-relation-changed 2011-12-07 00:02:26 +0000
80@@ -2,25 +2,13 @@
81
82 set -eu # -x for verbose logging to juju debug-log
83
84-LPATH="/var/opt/limesurvey/"
85-
86-hostname=`unit-get public-address`
87-juju-log "Retrieved hostname: $hostname"
88-
89-# Get the database settings; if not set, wait for this hook to be
90-# invoked again
91-database=`relation-get database`
92-if [ -z "$database" ] ; then
93- exit 0 # wait for future handshake from database service unit
94+FORMULA_DIR=$(dirname $0)
95+if [[ -e $FORMULA_DIR/limesurvey-common ]] ; then
96+ . $FORMULA_DIR/limesurvey-common
97+else
98+ echo "ERROR: Could not load limesurvey-common from $FORMULA_DIR"
99 fi
100
101-# Our protocol on this interface ensures that all or none of the
102-# settings are set. But we can verify the setting or the values if
103-# more error checking if desired.
104-user=`relation-get user`
105-password=`relation-get password`
106-host=`relation-get private-address`
107-
108 juju-log "Creating appropriate upload paths and directories"
109 # Setup appropriate upload paths and directories
110 ln -sf $LPATH "/var/www/$hostname"
111@@ -30,26 +18,11 @@
112 chmod 0770 -R "$LPATH/tmp"
113 chmod 0770 -R "$LPATH/upload"
114
115-juju-log "Writing limesurvey config file $config_file_path"
116-# Write the wordpress config
117-cat > $config_file_path <<EOF
118-<?php
119-\$databasetype = 'mysql';
120-\$databaselocation = '$host';
121-\$databasename = '$database';
122-\$databaseuser = '$user';
123-\$databasepass = '$password';
124-\$dbprefix = 'lime_';
125-\$rooturl = "http://{\$_SERVER['HTTP_HOST']}";
126-\$rootdir = dirname(__FILE__);
127-\$defaultuser = 'admin';
128-\$defaultpass = 'password';
129-\$debug = 0;
130-\$sessionhandler = 'db';
131-?>
132-EOF
133-chmod 0644 $config_file_path
134-chown root:www-data $config_file_path
135+# write the invariant part of the config file
136+set-invariant-config
137+
138+# Write the limesurvey config
139+set-config
140
141 juju-log "Starting limesurvey install"
142 pushd /var/opt/limesurvey
143
144=== added file 'hooks/limesurvey-common'
145--- hooks/limesurvey-common 1970-01-01 00:00:00 +0000
146+++ hooks/limesurvey-common 2011-12-07 00:02:26 +0000
147@@ -0,0 +1,76 @@
148+#!/bin/bash
149+
150+LPATH="/var/opt/limesurvey/"
151+config_file_path="${LPATH}config.php"
152+config_tmp="$FORMULA_DIR/config.tmp"
153+
154+hostname=`unit-get public-address`
155+juju-log "Retrieved hostname: $hostname"
156+
157+#Store the invariant part of the config file on disk, so that we can
158+#reuse it outside of a relation-changed hook. This is a workaround until
159+#we will be able to do relation-get <relation> <variable>
160+function set-invariant-config {
161+ # Get the database settings; if not set, wait for this hook to be
162+ # invoked again
163+ database=`relation-get database`
164+ if [ -z "$database" ] ; then
165+ exit 0 # wait for future handshake from database service unit
166+ fi
167+
168+ # Our protocol on this interface ensures that all or none of the
169+ # settings are set. But we can verify the setting or the values if
170+ # more error checking if desired.
171+ user=`relation-get user`
172+ password=`relation-get password`
173+ host=`relation-get private-address`
174+
175+ juju-log "Writing limesurvey invariant config.tmp"
176+ # Write the limesurvey config
177+ cat > $config_tmp <<EOF
178+<?php
179+\$databasetype = 'mysql';
180+\$databaselocation = '$host';
181+\$databasename = '$database';
182+\$databaseuser = '$user';
183+\$databasepass = '$password';
184+\$dbprefix = 'lime_';
185+\$rooturl = "http://{\$_SERVER['HTTP_HOST']}";
186+\$rootdir = dirname(__FILE__);
187+\$defaultuser = 'admin';
188+\$defaultpass = '$(config-get default-admin-pass)';
189+\$debug = 0;
190+\$sessionhandler = 'db';
191+\$databasetabletype = '$(config-get mysql-tabletype)';
192+\$databasepersistent = '$(config-get db-persistent)';
193+EOF
194+}
195+
196+#Set the configuration values that can be changed after the relation
197+#with the db has been done
198+function set-config {
199+ if [[ ! -e $config_tmp ]] ; then
200+ juju-log "Database relation has not been established yet, can't write the config"
201+ exit 0
202+ fi
203+
204+ juju-log "Writing limesurvey config file $config_file_path"
205+ # Write the limesurvey config
206+ cat $config_tmp > $config_file_path
207+ cat >> $config_file_path <<EOF
208+\$sitename = '$(config-get site-name)';
209+\$defaultlang = '$(config-get default-lang)';
210+\$siteadminemal = '$(config-get admin-email)';
211+\$siteadminbounce = '$(config-get admin-bounce)';
212+\$siteadminname = '$(config-get admin-name)';
213+\$emailmethod = '$(config-get mail-method)';
214+\$emailsmtphost = '$(config-get mail-smtp-host)';
215+\$emailsmtpuser = '$(config-get mail-smtp-user)';
216+\$emailsmtppassword = '$(config-get mail-smtp-password)';
217+\$emailsmtpssl = '$(config-get mail-smtp-ssl)';
218+?>
219+EOF
220+
221+ chmod 0644 $config_file_path
222+ chown root:www-data $config_file_path
223+}
224
225=== added file 'limesurvey.yaml'
226--- limesurvey.yaml 1970-01-01 00:00:00 +0000
227+++ limesurvey.yaml 2011-12-07 00:02:26 +0000
228@@ -0,0 +1,7 @@
229+limesurvey:
230+ mysql-tabletype: MyISAM
231+ site-name: MyLimeSurveySite
232+ default-admin-pass: password
233+ admin-email: thisaddress@hasnotbeen.set
234+ admin-bounce: thisaddress@hasnotbeen.set
235+ admin-name: Thisshouldbe Aname
236
237=== modified file 'readme.txt'
238--- readme.txt 2011-12-04 09:35:45 +0000
239+++ readme.txt 2011-12-07 00:02:26 +0000
240@@ -1,13 +1,24 @@
241 Juju charm limesurvey
242-author: Nick Barcet <nick.barcet@ubuntu.com>
243-
244-Example deployment
245+author: Nick Barcet <nick.barcet@canonical.com>
246+
247+Example deployment:
248+
249+1. Setup your site specific parameters in limesurvey.yaml
250+> vi limesurvey.yaml
251+a list of all settable parameter with description is available using
252+> juju get limesurvey
253+
254+2. Deployment with mysql and haproxy
255 >juju bootstrap
256->juju deploy service limesurvey
257->juju deploy service mysql
258+>juju deploy --config limesurvey.yaml limesurvey
259+>juju deploy mysql
260+>juju deploy haproxy
261 >juju add-relation mysql limesurvey
262+>juju add-relation limesurvey haproxy
263+>juju expose haproxy
264
265-Limesurvey should be ready to go add http://<limesurvey-machine-addr>/.
266-The admin interface is at http://<limesurvey-machine-addr>/admin/ with
267-default login (admin) and password (password) that you should change as
268-soon as possible.
269+3. Accessing you new limesurvey survey site should be ready at
270+http://<haproxy-machine-addr>/. To find out the public address of haproxy,
271+look for it in the output of the 'juju status' command. The admin interface
272+is at http://<limesurvey-machine-addr>/admin/ with default login (admin) and
273+password (password) that you should change as soon as possible.
274
275=== modified file 'revision'
276--- revision 2011-12-04 23:58:32 +0000
277+++ revision 2011-12-07 00:02:26 +0000
278@@ -1,1 +1,1 @@
279-8
280+13

Subscribers

People subscribed via source and target branches

to all changes: