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
=== added file 'README.rst'
--- README.rst 1970-01-01 00:00:00 +0000
+++ README.rst 2012-03-30 17:15:34 +0000
@@ -0,0 +1,60 @@
1====================
2Etherpad Lite Rocks!
3====================
4
5Overview
6--------
7
8Etherpad lite is a really-real time collaborative editor spawned from the
9Hell fire of Etherpad. It reuses the well tested Etherpad easysync library
10to make it really realtime.
11
12Etherpad Lite is based on node.js ergo is much lighter and more stable than
13the original Etherpad. Our hope is that this will encourage more users to
14use and install a realtime collaborative editor.
15
16A smaller, manageable and well documented codebase makes it easier for
17developers to improve the code and contribute towards the project.
18
19Etherpad Lite is optimized to be eddasy embeddable. It provides a HTTP API
20that allows your web application to manage pads, users and groups. There
21are several clients in for this API:
22
23 * PHP, thx to TomNomNom
24 * .Net, thx to ja-jo
25 * Node.js, thx to tomassedovic
26 * Ruby, thx to jhollinger
27 * Python, thx to devjones
28
29There is also a jQuery plugin that helps you to embed Pads into your website
30
31For more information see https://github.com/Pita/etherpad-lite.
32
33Usage
34-----
35
36Etherpad will happily sit on single server::
37
38 juju deploy etherpad-lite
39
40but it can also be backed by mysql::
41
42 juju deploy mysql
43 juju add-relation etherpad-lite mysql
44
45Note that if you switch an existing etherpad-lite instance to use mysql you will
46lose all of the pads within your standalone deployment - same applies
47vica-versa.
48
49You can change the upstream commit tag for etherpad-lite by using charm config
50either in a yaml file::
51
52 etherpad-lite:
53 commit: 1.0
54
55or::
56
57 juju set etherpad-lite commit=cfb58a80a30486156a15515164c9c0f4647f165b
58
59This can be changed for an existing service as well - allowing you to upgrade to
60a newer (potentially broken!) version.
061
=== added file 'config.yaml'
--- config.yaml 1970-01-01 00:00:00 +0000
+++ config.yaml 2012-03-30 17:15:34 +0000
@@ -0,0 +1,9 @@
1options:
2 commit:
3 default: cfb58a80a30486156a15515164c9c0f4647f165b
4 type: string
5 description: |
6 Commit from http://github.com/Pita/etherpad-lite to use. This
7 could also refer to a branch (master) or a tag (1.1).
8 .
9 Default is one that is know to work with this charm.
010
=== removed file 'hooks/config'
--- hooks/config 2011-07-28 14:49:19 +0000
+++ hooks/config 1970-01-01 00:00:00 +0000
@@ -1,7 +0,0 @@
1# Common configuration for all scripts
2app_name="etherpad-lite"
3app_dir="/opt/${app_name}"
4app_user="ubuntu"
5app_scm="git"
6app_url="https://github.com/Pita/etherpad-lite.git"
7app_branch="master"
80
=== added symlink 'hooks/config-changed'
=== target is u'ep-common'
=== renamed file 'hooks/mysqldb-relation-broken' => 'hooks/db-relation-broken'
--- hooks/mysqldb-relation-broken 2011-09-28 12:53:35 +0000
+++ hooks/db-relation-broken 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1#!/bin/bash
2
3set -eu # -x for verbose logging to juju debug-log
4
5[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
6
7juju-log "configuring ${app_name} to work with dirty"
8
9config_file_path=$app_dir/settings.json
10
11cp $(dirname $0)/ep-config/settings.json.dirty $config_file_path
12
13juju-log "(Re)starting app ${app_name}"
14restart ${app_name} || start ${app_namxme}
150
=== target is u'ep-common'
=== renamed file 'hooks/mysqldb-relation-changed' => 'hooks/db-relation-changed'
--- hooks/mysqldb-relation-changed 2011-09-26 16:32:02 +0000
+++ hooks/db-relation-changed 1970-01-01 00:00:00 +0000
@@ -1,33 +0,0 @@
1#!/bin/bash
2
3set -eu # -x for verbose logging to juju debug-log
4
5[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
6
7# Get the database settings; if not set, wait for this hook to be
8# invoked again
9host=`relation-get host`
10if [ -z "$host" ] ; then
11 exit 0 # wait for future handshake from database service unit
12fi
13
14# Get rest of mysql setup
15user=`relation-get user`
16password=`relation-get password`
17database=`relation-get database`
18
19juju-log "configuring ${app_name} to work with the mysql service"
20
21config_file_path=$app_dir/settings.json
22
23cp $(dirname $0)/ep-config/settings.json.mysql $config_file_path
24if [ -f $config_file_path ]; then
25 juju-log "Writing $app_name config file $config_file_path"
26 sed -i "s/DB_USER/${user}/g" $config_file_path
27 sed -i "s/DB_HOST/${host}/g" $config_file_path
28 sed -i "s/DB_PASS/${password}/g" $config_file_path
29 sed -i "s/DB_NAME/${database}/g" $config_file_path
30fi
31
32juju-log "(Re)starting app ${app_name}"
33restart ${app_name} || start ${app_namxme}
340
=== target is u'ep-common'
=== added symlink 'hooks/db-relation-joined'
=== target is u'ep-common'
=== added file 'hooks/ep-common'
--- hooks/ep-common 1970-01-01 00:00:00 +0000
+++ hooks/ep-common 2012-03-30 17:15:34 +0000
@@ -0,0 +1,165 @@
1#!/bin/bash
2
3set -e
4
5# Common configuration for all scripts
6app_name="etherpad-lite"
7app_dir="/opt/${app_name}"
8app_user="ubuntu"
9app_scm="git"
10app_url="https://github.com/Pita/etherpad-lite.git"
11app_branch="master"
12
13umask 002
14
15start_ep () {
16 start ${app_name} || :
17}
18
19stop_ep () {
20 stop ${app_name} || :
21}
22
23restart_ep () {
24 restart ${app_name} || start ${app_name}
25}
26
27install_node () {
28 juju-log "Installing node..."
29 add-apt-repository ppa:chris-lea/node.js
30 apt-get update
31 apt-get -y install -qq nodejs nodejs-dev build-essential npm curl
32}
33
34install_ep () {
35 juju-log "Installing ${app_name}..."
36 apt-get -y install -qq git-core daemon gzip abiword
37 if [ ! -d ${app_dir} ]; then
38 git clone ${app_url} ${app_dir} -b ${app_branch}
39 fi
40}
41
42update_ep () {
43 juju-log "Updating ${app_nane}..."
44 if [ -d ${app_dir} ]; then
45 (
46 cd ${app_dir}
47 git checkout master
48 git pull
49 git checkout $(config-get commit)
50 npm install
51 )
52 fi
53
54 # Modifiy the app so $app_user can write to it
55 # needed as starts up with a dirty database
56 chown -Rf ${app_user}.${app_user} ${app_dir}
57}
58
59install_upstart_config () {
60 juju-log "Installing upstart configuration for etherpad-lite"
61 cat > /etc/init/${app_name}.conf <<EOS
62description "${app_name} server"
63
64start on runlevel [2345]
65stop on runlevel [!2345]
66
67limit nofile 8192 8192
68
69pre-start script
70 touch /var/log/${app_name}.log || true
71 chown ${app_user}:${app_user} /var/log/${app_name}.log || true
72end script
73
74script
75 exec daemon --name=${app_name} --inherit --user=${app_user} --output=/var/log/${app_name}.log \
76 -- ${app_dir}/bin/run.sh
77end script
78EOS
79}
80
81configure_dirty_ep () {
82 juju-log "Configurating ${app_name} with default dirty database..."
83 cp templates/settings.json.dirty /opt/${app_name}/settings.json
84}
85
86configure_mysql_ep () {
87 # Get the database settings; if not set, wait for this hook to be
88 # invoked again
89 host=`relation-get host`
90 if [ -z "$host" ] ; then
91 exit 0 # wait for future handshake from database service unit
92 fi
93
94 # Get rest of mysql setup
95 user=`relation-get user`
96 password=`relation-get password`
97 database=`relation-get database`
98
99 juju-log "configuring ${app_name} to work with the mysql service"
100
101 config_file_path=$app_dir/settings.json
102
103 cp templates/settings.json.mysql $config_file_path
104 if [ -f $config_file_path ]; then
105 juju-log "Writing $app_name config file $config_file_path"
106 sed -i "s/DB_USER/${user}/g" $config_file_path
107 sed -i "s/DB_HOST/${host}/g" $config_file_path
108 sed -i "s/DB_PASS/${password}/g" $config_file_path
109 sed -i "s/DB_NAME/${database}/g" $config_file_path
110 fi
111}
112
113configure_website () {
114 juju-log "Setting relation parameters for website..."
115 relation-set port="9001" hostname=`unit-get private-address`
116}
117
118open_ports () {
119 juju-log "Opening ports for access to ${app_name}"
120 open-port 9001
121}
122
123COMMAND=`basename $0`
124
125
126case $COMMAND in
127 install)
128 install_node
129 install_ep
130 update_ep
131 install_upstart_config
132 configure_dirty_ep
133 ;;
134 start)
135 start_ep
136 open_ports
137 ;;
138 stop)
139 stop_ep
140 ;;
141 upgrade-charm)
142 install_node
143 update_ep
144 install_upstart_config
145 restart_ep
146 ;;
147 config-changed)
148 update_ep
149 restart_ep
150 ;;
151 website-relation-joined)
152 configure_website
153 ;;
154 db-relation-joined|db-relation-changed)
155 configure_mysql_ep
156 restart_ep
157 ;;
158 db-relation-broken)
159 configure_dirty_ep
160 restart_ep
161 ;;
162 *)
163 juju-log "Command not recognised"
164 ;;
165esac
0166
=== modified file 'hooks/install'
--- hooks/install 2012-02-09 21:53:32 +0000
+++ hooks/install 1970-01-01 00:00:00 +0000
@@ -1,71 +0,0 @@
1#!/bin/bash
2
3set -eu # -x for verbose logging to juju debug-log
4umask 002
5
6[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
7
8install_node() {
9 juju-log "Installing node..."
10 apt-get -y install -qq nodejs nodejs-dev build-essential
11}
12[[ -x /usr/bin/node ]] || install_node
13
14install_npm() {
15 juju-log "Installing npm..."
16 apt-get -y install -qq git-core
17 git clone https://github.com/isaacs/npm /tmp/npm -b 0.2
18 cd /tmp/npm && node cli.js install
19}
20[[ -x /usr/bin/npm ]] || install_npm
21
22install_app() {
23 juju-log "Installing ${app_name}..."
24 apt-get -y install -qq git-core daemon gzip abiword
25 # Grab 1.0 of etherpad
26 git clone ${app_url} ${app_dir} -b ${app_branch}
27 cd ${app_dir} && git checkout 1.0
28
29 if [ -f ${app_dir}/package.json ]; then
30 # Install ep-lite deps
31 cd ${app_dir} && npm install
32 fi
33
34 # Modifiy the app so $app_user can write to it
35 # needed as starts up with a dirty database
36 chown -Rf ${app_user}.${app_user} ${app_dir}
37
38 cat > /etc/init/${app_name}.conf <<EOS
39description "${app_name} server"
40
41start on runlevel [2345]
42stop on runlevel [!2345]
43
44limit nofile 8192 8192
45
46pre-start script
47 touch /var/log/${app_name}.log || true
48 chown ${app_user}:${app_user} /var/log/${app_name}.log || true
49end script
50
51script
52 exec daemon --name=${app_name} --inherit --user=${app_user} --output=/var/log/${app_name}.log \
53 -- ${app_dir}/bin/run.sh
54end script
55EOS
56}
57[[ -d ${app_dir} ]] || install_app
58
59configure_app() {
60 juju-log "Configurating ${app_name} with default dirty database..."
61 # TODO: add hook to configure default text in this function
62 cp $(dirname $0)/ep-config/settings.json.dirty /opt/${app_name}/settings.json
63}
64
65# always configure application - defaults to node dirty < 1M records
66configure_app
67
68# Open Port for Access to Application - it will run on dirty so if good from the start
69open-port 9001
70
71juju-log "Delaying app external db config (mysqldb might join)"
720
=== target is u'ep-common'
=== modified file 'hooks/start'
--- hooks/start 2011-07-28 14:49:19 +0000
+++ hooks/start 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1#!/bin/bash
2
3[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
4
5start ${app_name}
6
70
=== target is u'ep-common'
=== modified file 'hooks/stop'
--- hooks/stop 2011-07-28 14:49:19 +0000
+++ hooks/stop 1970-01-01 00:00:00 +0000
@@ -1,6 +0,0 @@
1#!/bin/bash
2
3[[ -f "$(dirname $0)/config" ]] && source "$(dirname $0)/config"
4
5stop ${app_name}
6
70
=== target is u'ep-common'
=== added symlink 'hooks/upgrade-charm'
=== target is u'ep-common'
=== modified file 'hooks/website-relation-joined'
--- hooks/website-relation-joined 2011-10-12 06:19:57 +0000
+++ hooks/website-relation-joined 1970-01-01 00:00:00 +0000
@@ -1,5 +0,0 @@
1#!/bin/sh
2
3app_port=9001
4
5relation-set port=$app_port hostname=`unit-get private-address`
60
=== target is u'ep-common'
=== modified file 'metadata.yaml'
--- metadata.yaml 2011-10-12 06:19:57 +0000
+++ metadata.yaml 2012-03-30 17:15:34 +0000
@@ -1,4 +1,3 @@
1ensemble: formula
2name: etherpad-lite1name: etherpad-lite
3summary: "Etherpad Lite"2summary: "Etherpad Lite"
4description: "Collaborative document sharing for the Internet"3description: "Collaborative document sharing for the Internet"
54
=== modified file 'revision'
--- revision 2012-02-09 22:29:36 +0000
+++ revision 2012-03-30 17:15:34 +0000
@@ -1,1 +1,1 @@
18121
22
=== renamed directory 'hooks/ep-config' => 'templates'

Subscribers

People subscribed via source and target branches

to all changes: