diff options
author | Luke Williams <xocel@iquidus.org> | 2012-12-21 21:34:15 +0100 |
---|---|---|
committer | Matteo Bernardini <ponce@slackbuilds.org> | 2012-12-21 21:34:41 +0100 |
commit | f5ff7ccd0787bbbe094fc0f7f0503a2cddc4368c (patch) | |
tree | 5d86b9907d651b1befe6140fbba1b442c9619566 /network/etherpad-lite/rc.etherpad-lite | |
parent | 0a49058508940879bd303fe27c03f9c4a3d0675f (diff) |
network/etherpad-lite: Added (real-time collaborative editor).
Signed-off-by: Matteo Bernardini <ponce@slackbuilds.org>
Diffstat (limited to 'network/etherpad-lite/rc.etherpad-lite')
-rw-r--r-- | network/etherpad-lite/rc.etherpad-lite | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/network/etherpad-lite/rc.etherpad-lite b/network/etherpad-lite/rc.etherpad-lite new file mode 100644 index 0000000000000..d2d56849e960e --- /dev/null +++ b/network/etherpad-lite/rc.etherpad-lite @@ -0,0 +1,100 @@ +#!/bin/sh +# rc.etherpad-lite +# Initscript that manages an instance of etherpad-Lite running on Slackware Linux. +# +# Author: Luke Williams ( xocel@iquidus.org ) +# License: WTFPL <http://sam.zoy.org/wtfpl/COPYING> + +USER="etherpad" +HOMEDIR="/var/etherpad-lite" +LOGDIR="/var/log/etherpad-lite" +PIDFILE="/var/run/etherpad-lite.pid" + +etherpad_start() { + echo "Starting Etherpad lite..." + # Launch etherpads run.sh script + /bin/su -l -c "$HOMEDIR/bin/run.sh -s /etc/etherpad-lite/settings.json >> $LOGDIR/etherpad.log 2>> $LOGDIR/error.log &" $USER + # Determine and store PID. In order for this to work sucessfully + # the node.js server needs to have finished launching, normally + # waiting 5 seconds is enough but in some situations (first launch + # after install for example) it can take a while longer. + PID='' # Process ID + COUNT=0 # Count attempts at determining the Process ID + TIMEOUT=9 # Number of failed attempts before exiting, default:9 (9x5=45seconds) + while [ -z "$PID" ]; do + # We don't want anyones boot process hanging here if this + # script is started on boot and etherpad is unable to lanuch. + # So exit out if etherpad appears to be failing to start. + if [ $COUNT -eq $TIMEOUT ]; then + echo "Unable to start Etherpad lite.." + cat $LOGDIR/etherpad.log | tail -n 5 + rm -f "$PIDFILE" + exit 1 + fi + # Wait for node.js server to start up + sleep 5 + # Store the PID + ps ax | grep [s]erver.js | awk '{print $1}' > "$PIDFILE" + # Check PID was written + PID=`cat $PIDFILE 2>/dev/null` + COUNT=$(($COUNT+1)) + done + echo "Running." +} + +etherpad_stop() { + echo "Stopping Etherpad lite..." + PID=`cat $PIDFILE 2>/dev/null` + if [ -z "$PID" ]; then + echo " not running." + elif kill -15 $PID; then + echo " stopped." + rm -f "$PIDFILE" + else + sleep 1 + if kill -9 $PID; then + echo " killed." + rm -f "$PIDFILE" + else + echo " error!" + exit 1 + fi + fi +} + +etherpad_status() { + PID=`cat $PIDFILE 2>/dev/null` + if [ -z "$PID" ]; then + echo "Not running." + exit 1 + elif kill -0 $PID; then + echo "Running." + exit 0 + else + echo "PID file $PIDFILE present but PID $PID is not running." + exit 1 + fi +} + +case "$1" in +start) + etherpad_start + ;; + + stop) + etherpad_stop + ;; + + restart) + etherpad_stop + sleep 3 + etherpad_start + ;; + + status) + etherpad_status + ;; + + *) + echo "Usage $0 (start|stop|restart|status)" +esac |