diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-10-18 14:43:24 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-10-18 14:43:24 -0400 |
commit | a2bdcb74d46c3b1002df03365330772a049c5173 (patch) | |
tree | 269df7b9b14a3203b03bd7434ebb8cc51f02741a /keysafe.init | |
parent | b519bf51580695e881f5e6766253e0f5e88a9a7e (diff) | |
download | keysafe-a2bdcb74d46c3b1002df03365330772a049c5173.tar.gz |
Added a LSB init script, for non-systemd systems.
(It currently uses Debian's start-stop-daemon, so would need porting for
other distributions.)
This commit was sponsored by Fernando Jimenez on Patreon.
Diffstat (limited to 'keysafe.init')
-rwxr-xr-x | keysafe.init | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/keysafe.init b/keysafe.init new file mode 100755 index 0000000..4aa1348 --- /dev/null +++ b/keysafe.init @@ -0,0 +1,60 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: keysafe +# Required-Start: $network $remote_fs +# Required-Stop: $network $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Keysafe server +# Description: Starts keysafe in server mode +### END INIT INFO + +PATH=/bin:/usr/bin:/sbin:/usr/sbin +NAME=keysafe +DESC="Keysafe server" +DAEMON="/usr/bin/keysafe" +PIDFILE=/var/run/"$NAME".pid + +test -x /usr/bin/keysafe || exit 0 + +. /lib/lsb/init-functions + +# Parameters to pass to keysafe. This can be overridden in /etc/default/keysafe +DAEMON_PARAMS="--port 4242 --store-directory=/var/lib/keysafe/" +if [ -e /etc/default/keysafe ]; then + . /etc/default/keysafe +fi + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + start-stop-daemon --start --quiet --oknodo \ + --background --no-close \ + --pidfile "$PIDFILE" --make-pidfile \ + --chuid keysafe:keysafe \ + --exec "$DAEMON" -- --server $DAEMON_PARAMS \ + > /var/log/keysafe.log + log_end_msg $? + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + killproc -p "$PIDFILE" "$DAEMON" + RETVAL=$? + [ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE + log_end_msg $RETVAL + ;; + restart|reload|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + $0 stop + $0 start + ;; + status) + status_of_proc -p $PIDFILE "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + *) + log_action_msg "Usage: /etc/init.d/keysafe {start|stop|status|restart|reload|force-reload}" + exit 2 + ;; +esac +exit 0 |