slackbuilds/xap/calibre/rc.calibre-server
Gwenhael Le Moine 19e83a5252
add
Signed-off-by: Gwenhael Le Moine <gwenhael.le.moine@gmail.com>
2017-07-05 10:18:40 +02:00

74 lines
1.5 KiB
Bash

#!/bin/bash
CALIBRE_LIBRARY_PATH="/home/cycojesus/BKP/tibou/Documents/eBooks/Livres/"
PIDFILE=/tmp/calibre-server.pid
USER=cycojesus
PORT=8081
AUTH=""
# uncomment and adapt to enable authtentication
# AUTH=" --username=\"$USER\" --password=\"password\""
OPTIONS=" --enable-local-writes"
start() {
echo "Starting Calibre server..."
su $USER -c "calibre-server --with-library=\"$CALIBRE_LIBRARY_PATH\" -p $PORT --pidfile=$PIDFILE --daemonize $AUTH $OPTIONS" &
if [ $? -ne 0 ]; then
echo "Could not start calibre-server."
fi
}
stop() {
echo "Stopping Calibre server..."
if [ -e $PIDFILE ]; then
read PID < $PIDFILE
ps aux | grep "$PID" | grep 'calibre-server' > /dev/null
RUNNING=$?
if [ $RUNNING -eq 0 ]; then
kill $PID
if [ $? -eq 0 ]; then
rm $PIDFILE
fi
else
echo "Could not find a calibre-server process with PID $PID."
fi
else
echo "Could not find pidfile: $PIDFILE"
fi
}
restart() {
stop
start
}
status() {
if [ -e $PIDFILE ]; then
read PID < $PIDFILE
echo "calibre-server is running with PID $PID."
else
echo "calibre-server is not running."
fi
}
unknown() {
echo "Unrecognized command: $1"
echo "Try one of the following: (start|stop|restart|status)"
}
case $1 in
start )
start
;;
stop )
stop
;;
restart )
restart
;;
status )
status
;;
* )
unknown
;;
esac