Last active
August 29, 2015 14:08
-
-
Save typomedia/a7c6cc268ee4169a8b6f to your computer and use it in GitHub Desktop.
Debian Init Script for https://bitbucket.org/raphaelmutschler/calibreserver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: bookserver | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Python Book Server | |
# Description: Python Book Server for Calibre Database | |
# Author: Typomedia Foundation | |
# Version: 1.4 | |
### END INIT INFO | |
PATH=/bin:/usr/bin:/sbin:/usr/sbin | |
DIR=/usr/local/bin/cps | |
DESC="Python Book Server" | |
NAME=bookserver | |
DAEMON=/usr/bin/python | |
PIDFILE=/var/run/$NAME.pid | |
OPTIONS=$DIR/cps.py | |
USER=root | |
. /lib/lsb/init-functions | |
daemon_start () { | |
start-stop-daemon --start --background \ | |
--make-pidfile --pidfile $PIDFILE --chdir $DIR \ | |
--user $USER --chuid $USER --exec $DAEMON -- $OPTIONS | |
} | |
daemon_stop () { | |
#start-stop-daemon --stop --pidfile $PIDFILE --retry 10 | |
kill $(ps aux | grep '[p]ython /usr/local/bin/cps/cps.py' | awk '{print $2}') | |
} | |
case "$1" in | |
start) | |
log_daemon_msg "Starting $DESC" "$NAME" | |
daemon_start | |
log_end_msg $? | |
;; | |
stop) | |
log_daemon_msg "Stopping $DESC" "$NAME" | |
daemon_stop | |
log_end_msg $? | |
;; | |
restart|reload|force-reload) | |
log_daemon_msg "Restarting $DESC" "$NAME" | |
daemon_stop | |
sleep 1 | |
daemon_start | |
log_end_msg $? | |
;; | |
status) | |
status_of_proc "$DAEMON" "$DESC" && exit 0 || exit $? | |
;; | |
*) | |
log_action_msg "Usage: service $NAME {start|stop|restart|status}" || true | |
exit 2 | |
;; | |
esac | |
exit 0 |
add #!/usr/bin/env python in cps.py
update-rc.d bookserver defaults 92
update-rc.d -f bookserver remove
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://pantofflhelden.com/2014/01/raspberry-pi-ein-eigener-ebook-server/