-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibred.sh
88 lines (75 loc) · 1.53 KB
/
calibred.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
### BEGIN INIT INFO
# Provides: calibred
# Required-Start: $network $local_fs
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Calibre daemon - ebook content server
### END INIT INFO
USER=calibre
PORT=8080
LIBRARY=/home/calibre/propirata
## DON'T CHANGE FOLLOWING LINES ##
GROUP=`id -ng "$USER"`
HOME=`getent passwd $USER | cut -d: -f6`
NAME="Calibre Server"
DAEMON=/usr/bin/calibre-server
PIDFILE=/home/calibre/.calibred.pid
. /lib/lsb/init-functions
start() {
log_daemon_msg "Starting $NAME"
if [ ! -x $DAEMON ]; then
log_progress_msg " \"$DAEMON\" not installed or not executable";
log_end_msg 1
return 4
fi
if /sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE -u $USER -c $USER:$USER --exec $DAEMON -- --pidfile $PIDFILE --port $PORT --with-library $LIBRARY --daemonize > /dev/null
then
log_progress_msg " started"
log_end_msg 0
return 0
else
log_progress_msg " was already running"
log_end_msg 2
return 1
fi
}
stop(){
log_daemon_msg "Closing $NAME"
if /sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE --retry forever/TERM/1
then
rm $PIDFILE
log_progress_msg "closed"
log_end_msg 0
return 0
else
log_progress_msg "was not running"
log_end_msg 2
return 1
fi
}
status(){
status_of_proc "$DAEMON" "$NAME"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
status
;;
*)
echo "Usage: calibred {start|stop|restart|status}"
exit 1
;;
esac
exit $?