2012-04-01 20:54:49 +04:00
|
|
|
#!/bin/sh
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: snail-watcher
|
|
|
|
# Required-Start: $local_fs
|
|
|
|
# Required-Stop: $local_fs
|
|
|
|
# Should-Start:
|
|
|
|
# Should-Stop:
|
|
|
|
# Default-Start: 2 3 4 5
|
|
|
|
# Default-Stop: 0 1 6
|
|
|
|
# Short-Description: Snail watcher.
|
|
|
|
# Description: Starts the snail-watcher daemon
|
|
|
|
# /etc/default/snail-watcher.
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Get lsb functions
|
|
|
|
. /lib/lsb/init-functions
|
|
|
|
|
|
|
|
PATH=$PATH:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
2012-04-02 00:39:08 +04:00
|
|
|
DAEMON="/usr/sbin/snail-watcher.sh"
|
2012-04-01 20:54:49 +04:00
|
|
|
DAEMON_ARGS=""
|
|
|
|
PIDFILE=/var/run/snail-watcher.pid
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
log_begin_msg "Starting snail-watcher"
|
|
|
|
pid=`cat $PIDFILE 2>/dev/null`
|
2012-04-02 00:53:18 +04:00
|
|
|
[ -z $pid ] || ! ps $pid 1>/dev/null 2>&1 && \
|
2012-04-01 20:54:49 +04:00
|
|
|
start-stop-daemon --make-pidfile \
|
|
|
|
--background \
|
|
|
|
--start \
|
|
|
|
--pidfile $PIDFILE \
|
|
|
|
--exec $DAEMON \
|
|
|
|
-- $DAEMON_ARGS \
|
2012-04-02 00:53:18 +04:00
|
|
|
|| log_warning_msg "Already running..."
|
2012-04-01 20:54:49 +04:00
|
|
|
log_end_msg $?
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
log_begin_msg "Stopping snail-watcher"
|
|
|
|
start-stop-daemon --stop \
|
|
|
|
--pidfile $PIDFILE
|
|
|
|
log_end_msg $?
|
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
$0 stop
|
|
|
|
$0 start
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
log_success_msg "Usage: /etc/init.d/snail-watcher {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|