]> git.sommitrealweird.co.uk Git - onak.git/commitdiff
Add Debian init.d file for keyd
authorJonathan McDowell <noodles@earth.li>
Sat, 16 Apr 2011 17:04:45 +0000 (10:04 -0700)
committerJonathan McDowell <noodles@earth.li>
Sat, 16 Apr 2011 17:04:45 +0000 (10:04 -0700)
  Add an init.d file to start up/shut down keyd on Debian machines if
  it's configured in onak.conf.

debian/onak.init [new file with mode: 0755]

diff --git a/debian/onak.init b/debian/onak.init
new file mode 100755 (executable)
index 0000000..34d0348
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          pgp-keyserver
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: onak init script
+# Description:       onak is a PGP keyserver with an optional persistent
+#                    backend daemon which this script starts.
+### END INIT INFO
+
+# Author: Jonathan McDowell <noodles@earth.li>
+
+# Do NOT "set -e"
+
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="PGP Keyserver backend"
+NAME=keyd
+DAEMON=/usr/sbin/$NAME
+DAEMON_ARGS=""
+SCRIPTNAME=/etc/init.d/onak
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# 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
+
+if ! grep -q -E '^use_keyd *(true|yes|1)$' /etc/onak.conf; then
+       exit 0
+fi
+
+case "$1" in
+  start)
+       [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+       start-stop-daemon --start --oknodo --user onak --chuid onak \
+               --exec $DAEMON
+       case "$?" in
+               0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+               1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+       esac
+       ;;
+  stop)
+       [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+       /usr/bin/keydctl quit
+       start-stop-daemon --stop --oknodo --user onak --exec $DAEMON
+       case "$?" in
+               0) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+               1) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+       esac
+       ;;
+  status)
+       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+       ;;
+  *)
+       echo "Usage: $SCRIPTNAME {start|stop|status}" >&2
+       exit 3
+       ;;
+esac
+
+: