#!/bin/bash #Slackware startup deamon script USER=RUNNING_USER DAEMON="python3 /opt/calibre-web/cps.py" PIDFILE=/var/run/calibre-web.pid RETVAL=0 status() { dbpid=`pgrep -fu $USER calibre-web` if [ -z "$dbpid" ]; then echo "$DAEMON: NOT running." else echo "$DAEMON: running (pid $dbpid)" fi } start() { echo -n "Starting $DAEMON..." sudo -u $USER $DAEMON & RETVAL=$! echo $RETVAL > $PIDFILE sleep 1 status } stop() { echo -n "Shutting down $DAEMON..." kill $(cat $PIDFILE) && rm $PIDFILE RETVAL=$? sleep 1 status } case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) echo $"Usage: $0 {start|stop|restart|status}" RETVAL=1 esac exit $RETVAL