summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2013-07-25 22:14:30 +0200
committerAlexander Sulfrian <alexander@sulfrian.net>2013-07-25 22:14:30 +0200
commit6f2a04b078f4f7634ea394fbd71a47d8dc7119fd (patch)
tree843201035b7b677047d7df132ab2c7f4c01cec68
parent96a95e293d018ac28bd6bed1c84f49adde2f6aac (diff)
downloadbot-6f2a04b078f4f7634ea394fbd71a47d8dc7119fd.tar.gz
bot-6f2a04b078f4f7634ea394fbd71a47d8dc7119fd.tar.bz2
bot-6f2a04b078f4f7634ea394fbd71a47d8dc7119fd.zip
add init script and default filedebian/1_2_git90-2
-rw-r--r--debian/changelog6
-rw-r--r--debian/phenny.default13
-rwxr-xr-xdebian/phenny.init85
3 files changed, 104 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 9410381..64bd1c7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+phenny (1:2~git90-2) unstable; urgency=low
+
+ * add init script and default file
+
+ -- Alexander Sulfrian <alex@spline.inf.fu-berlin.de> Thu, 25 Jul 2013 22:13:43 +0200
+
phenny (1:2~git90-1) unstable; urgency=low
* removed debian patches
diff --git a/debian/phenny.default b/debian/phenny.default
new file mode 100644
index 0000000..3270d73
--- /dev/null
+++ b/debian/phenny.default
@@ -0,0 +1,13 @@
+# The user the phenny bot is executed as (defaults to nobody).
+#PHENNY_USER="nobody"
+
+# The group the phenny bot is executed as. If not specified the default group
+# of the PHENNY_USER is used.
+#PHENNY_GROUP=""
+
+# The config file or directory for the phenny bot(s). If it is a directory, for
+# each *.py file in it an own bot will start with that file as config.
+#PHENNY_CONFIG="/etc/phenny/"
+
+# Other opts to the phenny daemon.
+#PHENNY_OPTS=""
diff --git a/debian/phenny.init b/debian/phenny.init
new file mode 100755
index 0000000..049d81d
--- /dev/null
+++ b/debian/phenny.init
@@ -0,0 +1,85 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: phenny
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
+# Should-Start:
+# Should-Stop:
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: Start/Stop the Phenny Bot
+### END INIT INFO
+
+DAEMON=/usr/bin/phenny
+NAME=phenny
+DESC="Phenny Bots"
+PIDDIR=/var/run/phenny
+
+PHENNY_USER=nobody
+PHENNY_GROUP=
+PHENNY_CONFIG=/etc/phenny/
+PHENNY_OPTS=
+
+if ! [ -x "/lib/lsb/init-functions" ]; then
+ . /lib/lsb/init-functions
+else
+ echo "E: /lib/lsb/init-functions not found, lsb-base (>= 3.0-6) needed"
+ exit 1
+fi
+
+# Include phenny defaults if available
+if [ -f "/etc/default/$NAME" ] ; then
+ . "/etc/default/$NAME"
+fi
+
+if [ -z "$PHENNY_USER" -o "$PHENNY_USER" = "root" ]; then
+ echo "PHENNY_USER not set or set to root. I will not start."
+ exit 1
+fi
+
+if [ -z "$PHENNY_CONFIG" ]; then
+ echo "PHENNY_CONFIG not set. I will not start."
+ exit 1
+fi
+
+#since /var/run can be wiped completly we create our run directory here
+if [ ! -d "$PIDDIR" ]; then
+ mkdir "$PIDDIR"
+ chown "$PHENNY_USER:$PHENNY_GROUP" "$PIDDIR"
+fi
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting $DESC" "$NAME"
+ start-stop-daemon --start \
+ --pidfile "$PIDDIR/$NAME.pid" \
+ --make-pidfile \
+ --chuid "$PHENNY_USER:$PHENNY_GROUP" \
+ --background \
+ --exec $DAEMON -- --config "$PHENNY_CONFIG" $PHENNY_OPTS
+ log_end_msg $?
+ ;;
+ stop)
+ log_daemon_msg "Stopping $DESC" "$NAME"
+ start-stop-daemon --stop --quiet \
+ --pidfile "$PIDDIR/$NAME.pid" \
+ --user "$PHENNY_USER" \
+ --signal INT \
+ --retry 15
+ log_end_msg $?
+ ;;
+ status)
+ status_of_proc -p "$PIDDIR/$NAME.pid" "$DESC" "$NAME" && exit 0 || exit $?
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ log_failure_msg "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
+
+exit 0