Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 68 additions & 20 deletions puppet-etc/manifests/site.pp
Original file line number Diff line number Diff line change
@@ -1,28 +1,76 @@
file { '/etc/captiveportal':
ensure => 'directory',
}
file { '/etc/captiveportal/captiveportal.conf':
ensure => 'file',
mode => '0644',
content => '[/]
tools.staticdir.root = "/srv/captiveportal"
# Nodejs for etherpad

Exec['apt-key-update'] -> Package<| |>

package { ['libc-ares2','libc6','libev4','libgcc1','libssl1.0.0','libstdc++6',
'libv8-3.8.9.20','zlib1g','libmysql-ruby','libjson-ruby', 'ruby-json',
'rubygems']:
ensure => 'present',
}
package { ['apt-file','git','mlocate','chkconfig']:
ensure => 'present',
}
class { 'nodejs': }
exec { 'apt-key-update':
command => 'apt-key update',
path => '/bin:/sbin:/usr/bin:/usr/sbin',
}
exec { 'gem install etherpad-lite':
path => '/bin:/usr/bin',
onlyif => 'gem list --local |grep etherpad-lite|wc -l |grep 0 > /dev/null',
}
file { '/etc/hosts':
content => '127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

127.0.1.1 raspberrypi raspberrypi.byzantium.org
',
subscribe => File['/etc/captiveportal'],
}
file { '/srv/captiveportal/':
ensure => 'directory',
mode => '0644',
file { '/etc/hostname':
content => 'raspberrypi.byzantium.org
',
}
file { '/srv/captiveportal/':
source => 'puppet://srv-captiveportal',
recurse => true,
package { ['nfs-common','samba-common','rcpbind','portmap']:
ensure => 'absent',
}
file { '/etc/motd':
content => 'The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

# Nodejs for etherpad
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

package { [libc-ares2' 'libc6', 'libev4', 'libgcc1', 'libssl1.0.0',
'libstdc++6', 'libv8-3.8.9.20', 'zlib1g']
ensure => 'present',
------------------------------------------------------------------------------
- -
- Welcome to Byzantium Linux - Emergency Mesh Networking -
- -
- To start a graphical environment, please type the following -
- command and hit ENTER. -
startx -
- -
------------------------------------------------------------------------------
'
}
class { 'nodejs': }
package { ['weechat','weechat-core','weechat-plugins',
'weechat-scripts']:
ensure => 'present',
}
# work around for a missing key.

exec { 'install-ngircd':
command => 'apt-get -y --force-yes install ngircd',
path => '/bin:/sbin:/usr/bin:/usr/sbin',
onlyif => 'which ngircd| wc -l|grep 0 > /dev/null',
}

# Packages for etherpad-lite
package { ['gzip','git-core','curl','python','libssl-dev','pkg-config',
'build-essential']:
ensure => 'present',
}

57 changes: 57 additions & 0 deletions puppet-etc/modules/etherpad-lite/files/configs/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
This file must be valid JSON. But comments are allowed

Please edit settings.json, not settings.json.template
*/
{
//Ip and port which etherpad should bind at
"ip": "0.0.0.0",
"port" : 9001,

//The Type of the database. You can choose between dirty, sqlite and mysql
//You should use mysql or sqlite for anything else than testing or development
//"dbType" : "dirty",
//"dbType" : "mysql",

//the database specific settings
//"dbSettings" : {
// "filename" : "../var/dirty.db"
// },

/* An Example of MySQL Configuration */
"dbType" : "mysql",
"dbSettings" : {
"user" : "etherpad",
"host" : "localhost",
"password": "byzantiumpad12345",
"database": "etherpad"
},


//the default text of a pad
"defaultPadText" : "Welcome to Etherpad Lite!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nEtherpad Lite on Github: http:\/\/j.mp/ep-lite\n",

/* Users must have a session to access pads. This effectively allows only group pads to be accessed. */
"requireSession" : false,

/* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */
"editOnly" : false,

/* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly,
but makes it impossible to debug the javascript/css */
"minify" : true,

/* How long may clients use served javascript code? Without versioning this
is may cause problems during deployment. */
"maxAge" : 21600000, // 6 hours

/* This is the path to the Abiword executable. Setting it to null, disables abiword.
Abiword is needed to enable the import/export of pads*/
"abiword" : null,

/* This setting is used if you need http basic auth */
// "httpAuth" : "user:pass",

/* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
"loglevel": "ERROR"
}
45 changes: 45 additions & 0 deletions puppet-etc/modules/etherpad-lite/files/configs/settings.json.DIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
This file must be valid JSON. But comments are allowed

Please edit settings.json, not settings.json.template
*/
{
//Ip and port which etherpad should bind at
"ip": "0.0.0.0",
"port" : 9001,

//The Type of the database. You can choose between sqlite and mysql
"dbType" : "dirty",
//the database specific settings
"dbSettings" : {
"filename" : "../var/dirty.db"
},

/* An Example of MySQL Configuration
"dbType" : "mysql",
"dbSettings" : {
"user" : "<% db_user %>",
"host" : "<% db_host %>",
<% if db_password == 'trocla' -%>
"password": "<%= Puppet::Parser::Functions.function('trocla');'' %><%= scope.function_trocla('mysql_etherpad-lite','plain') %>",
<% else -%>
"password": <% db_password -%>
<% end -%>
"database": "<% db_name %>"
},
*/

//the default text of a pad
"defaultPadText" : "Welcome to Etherpad Lite!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nEtherpad Lite on Github: http:\/\/j.mp/ep-lite\n",

/* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly,
but makes it impossible to debug the javascript/css */
"minify" : true,

/* This is the path to the Abiword executable. Setting it to null, disables abiword.
Abiword is needed to enable the import/export of pads*/
"abiword" : null,

/* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
"loglevel": "INFO"
}
76 changes: 76 additions & 0 deletions puppet-etc/modules/etherpad-lite/files/etherpad-lite.init
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/sh

### BEGIN INIT INFO
# Provides: etherpad-lite
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts etherpad lite
# Description: starts etherpad lite using start-stop-daemon
### END INIT INFO

PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/etherpad-lite/etherpad-lite.log"
EPLITE_DIR="/srv/etherpad-lite"
HOME="/srv/etherpad-lite"
TMP="/var/tmp"
EPLITE_BIN="bin/safeRun.sh"
USER="etherpad-lite"
GROUP="etherpad-lite"
DESC="Etherpad Lite"
NAME="etherpad-lite"

set -e

. /lib/lsb/init-functions

start() {
echo "Starting $DESC... "

start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
echo "done"
}

#We need this function to ensure the whole process tree will be killed
killtree() {
local _pid=$1
local _sig=${2-TERM}
for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
killtree ${_child} ${_sig}
done
kill -${_sig} ${_pid}
}

stop() {
echo "Stopping $DESC... "
killtree $(cat /var/run/$NAME.pid) 15
rm /var/run/$NAME.pid
echo "done"
}

status() {
status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $NAME {start|stop|restart|status}" >&2
exit 1
;;
esac

exit 0
43 changes: 43 additions & 0 deletions puppet-etc/modules/etherpad-lite/files/pad-ecology/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
The way this works is that a new mysql table is created for timestamps that are
updated whenever a new record in the main etherpad table is inserted. This is
done with mysql triggers, so it only works with mysql as a backend. Then a
clear-old-pads.rb uses the etherpad API to delete pads with old timestamps.

It is recommended that you run the cronjob regularly, at least several times a
day. This is because if you run it irregularly, it was found that deleting large
numbers of pads would cause problems with the server, so its better to remove
smaller batches more regularly.

How to use:

0. In your my.cnf you need something like the following:

[mysqld]
init_connect='SET collation_connection = utf8_general_ci; SET NAMES utf8;'

1. Add the pad_timestamps table to your etherpad-lite database:
mysql> use etherpad-lite
mysql> \. timestamp-mysql.sql

2. Put the ../../templates/pad-ecology/clear-old-pads.erb somewhere useful

3. install the required gems:
# sudo apt-get install ruby rubygems libmysql-ruby1.8
# sudo gem install json

NOTE: there is currently a bug with the current version of the ruby
etherpad-lite API gem. Pad names with non-ascii characters in their names
sometimes throw exceptions and keep things from being cleaned up. The unstable
etherpad-lite gem fixes this issue

4. Get the unstable etherpad-lite gem and put it in the same directory as the
clear-old-pads.rb (dont worry, this is only used for the clear-old-pads.rb
script, not for your main etherpad-lite)

5. edit clear-old-pads.rb to fill out the database password, url and api key

6. Setup a cronjob to run clear-old-pads.rb on a regular basis (maybe once per
hour, like */1)

You can run clear-old-pads.rb with --verbose to see if it works properly.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Add this to the etherpad-lite database in order to track timestamps of the last day that a
# pad was modified. We use this to destroy old pads.
#

#
# Create a table 'pad_timestamps' that just maps pad name to timestamp:
#

DROP INDEX pad_name ON pad_timestamps;
DROP TABLE pad_timestamps;

CREATE TABLE pad_timestamps (pad VARCHAR(100), time DATE);
CREATE UNIQUE INDEX pad_name ON pad_timestamps (pad);

#
# Set a trigger on table 'store' that inserts a row into pad_timestamps
# whenever a pad is modified (ie, new key is inserted of the form
# "pad:<padid>:revs:<n>" where <padid> is the name of the pad and <n> is the
# revision number).
#
# Because mysql doesn't bother updating a record when the values don't change,
# this trigger should be relatively efficient. The pad timestamp column is of type
# date, so at most the pad_timestamp table will have one update per pad per day.
#

DROP TRIGGER add_pad_timestamp;
DELIMITER $$
CREATE TRIGGER `add_pad_timestamp`
AFTER INSERT ON `store` FOR EACH ROW
BEGIN
IF POSITION('pad:' IN NEW.key) = 1 AND POSITION(':revs:' IN NEW.key) THEN
SET @padname = SUBSTR(SUBSTRING_INDEX(NEW.key, ':', 2),5);
SET @padtime = DATE(NOW());
INSERT INTO pad_timestamps(pad, time) VALUES (@padname, @padtime) ON DUPLICATE KEY UPDATE time = @padtime;
END IF;
END
$$
DELIMITER ;

Loading