4
# Provides: ifetch-tools
5
# Required-Start: $remote_fs $network $syslog
6
# Required-Stop: $remote_fs $network $syslog
7
# Should-Start: $local_fs
8
# Default-Start: 2 3 4 5
10
# Short-Description: Tools to collect IP Camera images.
11
# Description: Tools to collect, monitor, view images from IP Cameras.
15
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
16
DAEMON=/usr/bin/wwwifetch
17
DAEMON_CONFIG=/etc/ifetch-tools/ifetch-tools.conf
24
test -x $DAEMON || exit 0
26
# Test for the ifetch-tools.conf
27
test -f $DAEMON_CONFIG || exit 0
29
. /lib/lsb/init-functions
31
LOGDIR=/var/log/ifetch-tools
32
PIDFILE=/var/run/$NAME.pid
33
DODTIME=10 # Time to wait for the server to die, in seconds
34
# If this value is set too low you might not
35
# let some servers to die gracefully and
36
# 'restart' will not work
40
# Check if a given process pid's cmdline matches a given name
44
[ -z "$pid" ] && return 1
46
[ ! -d /proc/$pid ] && return 1
48
cmd=$(cat /proc/$pid/cmdline | tr "\000" "\n"|tail -n 1 |cut -d : -f 1)
50
# Is this the expected child?
51
[ "$cmd" != "$name" ] && return 1
58
# Check if the process is running looking at /proc
59
# (works for all users)
61
# No pidfile, probably no daemon present
62
[ ! -f "$PIDFILE" ] && return 1
64
# Obtain the pid and check it against the binary name
66
running_pid $pid $DAEMON || return 1
73
echo -n "Starting $DESC: "
74
start-stop-daemon --start --chdir /tmp --nicelevel 10 --chuid $_UID --quiet --background --make-pidfile --pidfile $PIDFILE --exec $DAEMON
76
[ -n "$DODTIME" ] && sleep "$DODTIME"s
81
echo "appears to be started."
83
echo "appears to have failed to start."
92
echo -n "Stopping $DESC: "
93
kill -s $signal $(pgrep -u $_UID ifetch)
95
[ -n "$DODTIME" ] && sleep "$DODTIME"s
99
echo "Cannot stop $NAME!"
102
echo "$NAME stopped."
111
mkdir -p /var/run/ifetch-tools
112
mkdir -p /var/lock/ifetch-tools
113
chown ifetch-tools:ifetch-tools /var/run/ifetch-tools /var/lock/ifetch-tools
116
echo "$NAME appears to be already running."
127
echo "$NAME is not running."
134
echo "Forcefully stopping $DESC and camera collecting."
137
echo "$NAME is not running."
149
echo "Forcefully reloading $DESC and camera collecting."
153
echo "$NAME is not running."
158
echo "Restarting $DESC."
165
echo "No running process, try start."
183
echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2