Merge lp:~james-page/charms/oneiric/etherpad-lite/rocks into lp:charms/oneiric/etherpad-lite

Proposed by James Page
Status: Merged
Approved by: Mark Mims
Approved revision: 8
Merged at revision: 8
Proposed branch: lp:~james-page/charms/oneiric/etherpad-lite/rocks
Merge into: lp:charms/oneiric/etherpad-lite
Diff against target: 455 lines (+235/-144)
12 files modified
README.rst (+60/-0)
config.yaml (+9/-0)
hooks/config (+0/-7)
hooks/db-relation-broken (+0/-14)
hooks/db-relation-changed (+0/-33)
hooks/ep-common (+165/-0)
hooks/install (+0/-71)
hooks/start (+0/-6)
hooks/stop (+0/-6)
hooks/website-relation-joined (+0/-5)
metadata.yaml (+0/-1)
revision (+1/-1)
To merge this branch: bzr merge lp:~james-page/charms/oneiric/etherpad-lite/rocks
Reviewer Review Type Date Requested Status
Mark Mims (community) Approve
Review via email: mp+100202@code.launchpad.net

Description of the change

This update is a major refresh of the etherpad-lite charm.

Fixes in this:

1) Make it work - it was broken and ep-lite would not start
   The charm now uses a know good upstream commit inconjunction
   with Chris Lea's nodejs and npm PPA
2) Make mysql work - not sure how that ever worked but it does now

Improvements

1) Move to -common model with symlinks - I much prefer this style
2) README!
3) Config - you can now choose a commit, branch or tag from upstream github to use

To post a comment you must log in.
Revision history for this message
Mark Mims (mark-mims) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'README.rst'
2--- README.rst 1970-01-01 00:00:00 +0000
3+++ README.rst 2012-03-30 17:15:34 +0000
4@@ -0,0 +1,60 @@
5+====================
6+Etherpad Lite Rocks!
7+====================
8+
9+Overview
10+--------
11+
12+Etherpad lite is a really-real time collaborative editor spawned from the
13+Hell fire of Etherpad. It reuses the well tested Etherpad easysync library
14+to make it really realtime.
15+
16+Etherpad Lite is based on node.js ergo is much lighter and more stable than
17+the original Etherpad. Our hope is that this will encourage more users to
18+use and install a realtime collaborative editor.
19+
20+A smaller, manageable and well documented codebase makes it easier for
21+developers to improve the code and contribute towards the project.
22+
23+Etherpad Lite is optimized to be eddasy embeddable. It provides a HTTP API
24+that allows your web application to manage pads, users and groups. There
25+are several clients in for this API:
26+
27+ * PHP, thx to TomNomNom
28+ * .Net, thx to ja-jo
29+ * Node.js, thx to tomassedovic
30+ * Ruby, thx to jhollinger
31+ * Python, thx to devjones
32+
33+There is also a jQuery plugin that helps you to embed Pads into your website
34+
35+For more information see https://github.com/Pita/etherpad-lite.
36+
37+Usage
38+-----
39+
40+Etherpad will happily sit on single server::
41+
42+ juju deploy etherpad-lite
43+
44+but it can also be backed by mysql::
45+
46+ juju deploy mysql
47+ juju add-relation etherpad-lite mysql
48+
49+Note that if you switch an existing etherpad-lite instance to use mysql you will
50+lose all of the pads within your standalone deployment - same applies
51+vica-versa.
52+
53+You can change the upstream commit tag for etherpad-lite by using charm config
54+either in a yaml file::
55+
56+ etherpad-lite:
57+ commit: 1.0
58+
59+or::
60+
61+ juju set etherpad-lite commit=cfb58a80a30486156a15515164c9c0f4647f165b
62+
63+This can be changed for an existing service as well - allowing you to upgrade to
64+a newer (potentially broken!) version.
65
66=== added file 'config.yaml'
67--- config.yaml 1970-01-01 00:00:00 +0000
68+++ config.yaml 2012-03-30 17:15:34 +0000
69@@ -0,0 +1,9 @@
70+options:
71+ commit:
72+ default: cfb58a80a30486156a15515164c9c0f4647f165b
73+ type: string
74+ description: |
75+ Commit from http://github.com/Pita/etherpad-lite to use. This
76+ could also refer to a branch (master) or a tag (1.1).
77+ .
78+ Default is one that is know to work with this charm.
79
80=== removed file 'hooks/config'
81--- hooks/config 2011-07-28 14:49:19 +0000
82+++ hooks/config 1970-01-01 00:00:00 +0000
83@@ -1,7 +0,0 @@
84-# Common configuration for all scripts
85-app_name="etherpad-lite"
86-app_dir="/opt/${app_name}"
87-app_user="ubuntu"
88-app_scm="git"
89-app_url="https://github.com/Pita/etherpad-lite.git"
90-app_branch="master"
91
92=== added symlink 'hooks/config-changed'
93=== target is u'ep-common'
94=== renamed file 'hooks/mysqldb-relation-broken' => 'hooks/db-relation-broken'
95--- hooks/mysqldb-relation-broken 2011-09-28 12:53:35 +0000
96+++ hooks/db-relation-broken 1970-01-01 00:00:00 +0000
97@@ -1,14 +0,0 @@
98-#!/bin/bash
99-
100-set -eu # -x for verbose logging to juju debug-log
101-
102-[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
103-
104-juju-log "configuring ${app_name} to work with dirty"
105-
106-config_file_path=$app_dir/settings.json
107-
108-cp $(dirname $0)/ep-config/settings.json.dirty $config_file_path
109-
110-juju-log "(Re)starting app ${app_name}"
111-restart ${app_name} || start ${app_namxme}
112
113=== target is u'ep-common'
114=== renamed file 'hooks/mysqldb-relation-changed' => 'hooks/db-relation-changed'
115--- hooks/mysqldb-relation-changed 2011-09-26 16:32:02 +0000
116+++ hooks/db-relation-changed 1970-01-01 00:00:00 +0000
117@@ -1,33 +0,0 @@
118-#!/bin/bash
119-
120-set -eu # -x for verbose logging to juju debug-log
121-
122-[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
123-
124-# Get the database settings; if not set, wait for this hook to be
125-# invoked again
126-host=`relation-get host`
127-if [ -z "$host" ] ; then
128- exit 0 # wait for future handshake from database service unit
129-fi
130-
131-# Get rest of mysql setup
132-user=`relation-get user`
133-password=`relation-get password`
134-database=`relation-get database`
135-
136-juju-log "configuring ${app_name} to work with the mysql service"
137-
138-config_file_path=$app_dir/settings.json
139-
140-cp $(dirname $0)/ep-config/settings.json.mysql $config_file_path
141-if [ -f $config_file_path ]; then
142- juju-log "Writing $app_name config file $config_file_path"
143- sed -i "s/DB_USER/${user}/g" $config_file_path
144- sed -i "s/DB_HOST/${host}/g" $config_file_path
145- sed -i "s/DB_PASS/${password}/g" $config_file_path
146- sed -i "s/DB_NAME/${database}/g" $config_file_path
147-fi
148-
149-juju-log "(Re)starting app ${app_name}"
150-restart ${app_name} || start ${app_namxme}
151
152=== target is u'ep-common'
153=== added symlink 'hooks/db-relation-joined'
154=== target is u'ep-common'
155=== added file 'hooks/ep-common'
156--- hooks/ep-common 1970-01-01 00:00:00 +0000
157+++ hooks/ep-common 2012-03-30 17:15:34 +0000
158@@ -0,0 +1,165 @@
159+#!/bin/bash
160+
161+set -e
162+
163+# Common configuration for all scripts
164+app_name="etherpad-lite"
165+app_dir="/opt/${app_name}"
166+app_user="ubuntu"
167+app_scm="git"
168+app_url="https://github.com/Pita/etherpad-lite.git"
169+app_branch="master"
170+
171+umask 002
172+
173+start_ep () {
174+ start ${app_name} || :
175+}
176+
177+stop_ep () {
178+ stop ${app_name} || :
179+}
180+
181+restart_ep () {
182+ restart ${app_name} || start ${app_name}
183+}
184+
185+install_node () {
186+ juju-log "Installing node..."
187+ add-apt-repository ppa:chris-lea/node.js
188+ apt-get update
189+ apt-get -y install -qq nodejs nodejs-dev build-essential npm curl
190+}
191+
192+install_ep () {
193+ juju-log "Installing ${app_name}..."
194+ apt-get -y install -qq git-core daemon gzip abiword
195+ if [ ! -d ${app_dir} ]; then
196+ git clone ${app_url} ${app_dir} -b ${app_branch}
197+ fi
198+}
199+
200+update_ep () {
201+ juju-log "Updating ${app_nane}..."
202+ if [ -d ${app_dir} ]; then
203+ (
204+ cd ${app_dir}
205+ git checkout master
206+ git pull
207+ git checkout $(config-get commit)
208+ npm install
209+ )
210+ fi
211+
212+ # Modifiy the app so $app_user can write to it
213+ # needed as starts up with a dirty database
214+ chown -Rf ${app_user}.${app_user} ${app_dir}
215+}
216+
217+install_upstart_config () {
218+ juju-log "Installing upstart configuration for etherpad-lite"
219+ cat > /etc/init/${app_name}.conf <<EOS
220+description "${app_name} server"
221+
222+start on runlevel [2345]
223+stop on runlevel [!2345]
224+
225+limit nofile 8192 8192
226+
227+pre-start script
228+ touch /var/log/${app_name}.log || true
229+ chown ${app_user}:${app_user} /var/log/${app_name}.log || true
230+end script
231+
232+script
233+ exec daemon --name=${app_name} --inherit --user=${app_user} --output=/var/log/${app_name}.log \
234+ -- ${app_dir}/bin/run.sh
235+end script
236+EOS
237+}
238+
239+configure_dirty_ep () {
240+ juju-log "Configurating ${app_name} with default dirty database..."
241+ cp templates/settings.json.dirty /opt/${app_name}/settings.json
242+}
243+
244+configure_mysql_ep () {
245+ # Get the database settings; if not set, wait for this hook to be
246+ # invoked again
247+ host=`relation-get host`
248+ if [ -z "$host" ] ; then
249+ exit 0 # wait for future handshake from database service unit
250+ fi
251+
252+ # Get rest of mysql setup
253+ user=`relation-get user`
254+ password=`relation-get password`
255+ database=`relation-get database`
256+
257+ juju-log "configuring ${app_name} to work with the mysql service"
258+
259+ config_file_path=$app_dir/settings.json
260+
261+ cp templates/settings.json.mysql $config_file_path
262+ if [ -f $config_file_path ]; then
263+ juju-log "Writing $app_name config file $config_file_path"
264+ sed -i "s/DB_USER/${user}/g" $config_file_path
265+ sed -i "s/DB_HOST/${host}/g" $config_file_path
266+ sed -i "s/DB_PASS/${password}/g" $config_file_path
267+ sed -i "s/DB_NAME/${database}/g" $config_file_path
268+ fi
269+}
270+
271+configure_website () {
272+ juju-log "Setting relation parameters for website..."
273+ relation-set port="9001" hostname=`unit-get private-address`
274+}
275+
276+open_ports () {
277+ juju-log "Opening ports for access to ${app_name}"
278+ open-port 9001
279+}
280+
281+COMMAND=`basename $0`
282+
283+
284+case $COMMAND in
285+ install)
286+ install_node
287+ install_ep
288+ update_ep
289+ install_upstart_config
290+ configure_dirty_ep
291+ ;;
292+ start)
293+ start_ep
294+ open_ports
295+ ;;
296+ stop)
297+ stop_ep
298+ ;;
299+ upgrade-charm)
300+ install_node
301+ update_ep
302+ install_upstart_config
303+ restart_ep
304+ ;;
305+ config-changed)
306+ update_ep
307+ restart_ep
308+ ;;
309+ website-relation-joined)
310+ configure_website
311+ ;;
312+ db-relation-joined|db-relation-changed)
313+ configure_mysql_ep
314+ restart_ep
315+ ;;
316+ db-relation-broken)
317+ configure_dirty_ep
318+ restart_ep
319+ ;;
320+ *)
321+ juju-log "Command not recognised"
322+ ;;
323+esac
324
325=== modified file 'hooks/install'
326--- hooks/install 2012-02-09 21:53:32 +0000
327+++ hooks/install 1970-01-01 00:00:00 +0000
328@@ -1,71 +0,0 @@
329-#!/bin/bash
330-
331-set -eu # -x for verbose logging to juju debug-log
332-umask 002
333-
334-[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
335-
336-install_node() {
337- juju-log "Installing node..."
338- apt-get -y install -qq nodejs nodejs-dev build-essential
339-}
340-[[ -x /usr/bin/node ]] || install_node
341-
342-install_npm() {
343- juju-log "Installing npm..."
344- apt-get -y install -qq git-core
345- git clone https://github.com/isaacs/npm /tmp/npm -b 0.2
346- cd /tmp/npm && node cli.js install
347-}
348-[[ -x /usr/bin/npm ]] || install_npm
349-
350-install_app() {
351- juju-log "Installing ${app_name}..."
352- apt-get -y install -qq git-core daemon gzip abiword
353- # Grab 1.0 of etherpad
354- git clone ${app_url} ${app_dir} -b ${app_branch}
355- cd ${app_dir} && git checkout 1.0
356-
357- if [ -f ${app_dir}/package.json ]; then
358- # Install ep-lite deps
359- cd ${app_dir} && npm install
360- fi
361-
362- # Modifiy the app so $app_user can write to it
363- # needed as starts up with a dirty database
364- chown -Rf ${app_user}.${app_user} ${app_dir}
365-
366- cat > /etc/init/${app_name}.conf <<EOS
367-description "${app_name} server"
368-
369-start on runlevel [2345]
370-stop on runlevel [!2345]
371-
372-limit nofile 8192 8192
373-
374-pre-start script
375- touch /var/log/${app_name}.log || true
376- chown ${app_user}:${app_user} /var/log/${app_name}.log || true
377-end script
378-
379-script
380- exec daemon --name=${app_name} --inherit --user=${app_user} --output=/var/log/${app_name}.log \
381- -- ${app_dir}/bin/run.sh
382-end script
383-EOS
384-}
385-[[ -d ${app_dir} ]] || install_app
386-
387-configure_app() {
388- juju-log "Configurating ${app_name} with default dirty database..."
389- # TODO: add hook to configure default text in this function
390- cp $(dirname $0)/ep-config/settings.json.dirty /opt/${app_name}/settings.json
391-}
392-
393-# always configure application - defaults to node dirty < 1M records
394-configure_app
395-
396-# Open Port for Access to Application - it will run on dirty so if good from the start
397-open-port 9001
398-
399-juju-log "Delaying app external db config (mysqldb might join)"
400
401=== target is u'ep-common'
402=== modified file 'hooks/start'
403--- hooks/start 2011-07-28 14:49:19 +0000
404+++ hooks/start 1970-01-01 00:00:00 +0000
405@@ -1,6 +0,0 @@
406-#!/bin/bash
407-
408-[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
409-
410-start ${app_name}
411-
412
413=== target is u'ep-common'
414=== modified file 'hooks/stop'
415--- hooks/stop 2011-07-28 14:49:19 +0000
416+++ hooks/stop 1970-01-01 00:00:00 +0000
417@@ -1,6 +0,0 @@
418-#!/bin/bash
419-
420-[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
421-
422-stop ${app_name}
423-
424
425=== target is u'ep-common'
426=== added symlink 'hooks/upgrade-charm'
427=== target is u'ep-common'
428=== modified file 'hooks/website-relation-joined'
429--- hooks/website-relation-joined 2011-10-12 06:19:57 +0000
430+++ hooks/website-relation-joined 1970-01-01 00:00:00 +0000
431@@ -1,5 +0,0 @@
432-#!/bin/sh
433-
434-app_port=9001
435-
436-relation-set port=$app_port hostname=`unit-get private-address`
437
438=== target is u'ep-common'
439=== modified file 'metadata.yaml'
440--- metadata.yaml 2011-10-12 06:19:57 +0000
441+++ metadata.yaml 2012-03-30 17:15:34 +0000
442@@ -1,4 +1,3 @@
443-ensemble: formula
444 name: etherpad-lite
445 summary: "Etherpad Lite"
446 description: "Collaborative document sharing for the Internet"
447
448=== modified file 'revision'
449--- revision 2012-02-09 22:29:36 +0000
450+++ revision 2012-03-30 17:15:34 +0000
451@@ -1,1 +1,1 @@
452-8
453+21
454
455=== renamed directory 'hooks/ep-config' => 'templates'

Subscribers

People subscribed via source and target branches

to all changes: