4
# Required-Start: $local_fs $remote_fs
5
# Should-Start: mysql postgresql
6
# Required-Stop: $local_fs $remote_fs
7
# Default-Start: 2 3 4 5
9
# Short-Description: Tiny Tiny RSS update daemon
10
# Description: Update the Tiny Tiny RSS subscribed syndication feeds.
13
# PATH should only include /usr/* if it runs after the mountnfs.sh script
14
PATH=/sbin:/usr/sbin:/bin:/usr/bin
15
DESC="Tiny Tiny RSS update daemon"
20
PIDFILE=/var/lib/tt-rss/update_daemon.lock
21
LOGFILE="/var/log/tt-rss.log"
23
# Read configuration variable file if it is present
24
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
26
DAEMON="/usr/share/tt-rss/www/update.php"
27
DAEMON_ARGS="--daemon"
29
if [ "$FORKING" != "0" ]; then
30
DAEMON="/usr/share/tt-rss/www/update_daemon2.php"
35
DAEMON_DIR="/usr/share/tt-rss/www"
36
SCRIPTNAME=/etc/init.d/tt-rss
38
# Exit if the package or loader is not installed
39
[ -x "$LOADER" ] || exit 0
40
[ -x "$DAEMON" ] || exit 0
42
# Load the VERBOSE setting and other rcS variables
45
# Define LSB log_* functions.
46
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
47
. /lib/lsb/init-functions
49
if [ "$DISABLED" != "0" -a "$1" != "stop" ]; then
50
log_warning_msg "Not starting $DESC - edit /etc/default/tt-rss and change DISABLED to be 0.";
55
# Function that starts the daemon/service
59
if [ ! -f "$LOGFILE" ] ; then
61
chown www-data:www-data "$LOGFILE"
65
# 0 if daemon has been started
66
# 1 if daemon was already running
67
# 2 if daemon could not be started
68
start-stop-daemon --start --background --quiet -c "www-data:www-data" --chdir "$DAEMON_DIR" --pidfile "$PIDFILE" --exec "$DAEMON" --test > /dev/null \
71
start-stop-daemon --start --background --quiet -c "www-data:www-data" --chdir "$DAEMON_DIR" --pidfile "$PIDFILE" --exec "$DAEMON" --startas /bin/sh -- -c "$DAEMON $DAEMON_ARGS >> $LOGFILE 2>&1" \
73
# Add code here, if necessary, that waits for the process to be ready
74
# to handle requests from services started subsequently which depend
75
# on this one. As a last resort, sleep for some time.
79
# Function that stops the daemon/service
84
# 0 if daemon has been stopped
85
# 1 if daemon was already stopped
86
# 2 if daemon could not be stopped
87
# other if a failure occurred
88
start-stop-daemon --stop --quiet --retry=TERM/1/KILL/5 --pidfile $PIDFILE
90
[ "$RETVAL" = 2 ] && return 2
91
# Wait for children to finish too if this is a daemon that forks
92
# and if the daemon is only ever run from this initscript.
93
# If the above conditions are not satisfied then add some other code
94
# that waits for the process to drop all resources that could be
95
# needed by services started subsequently. A last resort is to
96
# sleep for some time.
97
start-stop-daemon --stop --quiet --oknodo --retry=0/1/KILL/5 --exec $DAEMON
98
[ "$?" = 2 ] && return 2
99
# Many daemons don't delete their pidfiles when they exit.
106
log_daemon_msg "Starting $DESC" "$NAME"
109
0|1) log_end_msg 0 ;;
114
log_daemon_msg "Stopping $DESC" "$NAME"
117
0|1) log_end_msg 0 ;;
121
restart|force-reload)
123
# If the "reload" option is implemented then remove the
124
# 'force-reload' alias
126
log_daemon_msg "Restarting $DESC" "$NAME"
133
1) log_end_msg 1 ;; # Old process is still running
134
*) log_end_msg 1 ;; # Failed to start
144
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
147
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2