commit 934b4b694c20d292698a8c1e91aec42d38e50716 Author: anadahz anadahz@github Date: Fri Jan 24 20:42:19 2014 +0100
Add ooni-backend SysV Init Script --- scripts/oonibd | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/scripts/oonibd b/scripts/oonibd new file mode 100755 index 0000000..c29a980 --- /dev/null +++ b/scripts/oonibd @@ -0,0 +1,65 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: oonibd +# Required-Start: $local_fs $remote_fs $network +# Required-Stop: $local_fs $remote_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: OONI Backend system init script +# Description: This script will start the open observatory +# of network interference backend system. +### END INIT INFO + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.2-14) to ensure that this file is present +# and status_of_proc is working. +. /lib/lsb/init-functions + +# oonib executable +DAEMON="/var/oonib/bin/oonib" +# oonib config file +ARGS="-c /var/oonib/oonib.conf" +PROC_NAME="python $DAEMON $ARGS" + + +case "$1" in + start) + CPIDS=$(pgrep -f "$PROC_NAME") + if [ -z "$CPIDS" ]; then + printf "Starting ooni-backend...\n" + $DAEMON $ARGS& + else + printf "ooni-backend already running\n" + fi + ;; + stop) + printf "Stopping ooni-backend...\n" + CPIDS=$(pgrep -f "$PROC_NAME") + if [ -n "$CPIDS" ]; then + sleep 5 + printf "Killing procs:\n$CPIDS\n" + kill -KILL $CPIDS + else + printf "No running ooni-backend procs\n" + fi + ;; + status) + printf "ooni-backend Status\nListing all ooni-backend procs\n" + CPIDS=$(pgrep -l -f "$PROC_NAME") + if [ -n "$CPIDS" ]; then + printf "$CPIDS\n" + else + printf "No running ooni-backend procs\n" + fi + ;; + *) + printf "Usage: /etc/init.d/oonibd {start|stop|status}\n" + exit 1 + ;; +esac + +exit 0