]> www.average.org Git - pulsecounter.git/blob - linux/rc.pulsecounter
Did I say that I hate systemd?
[pulsecounter.git] / linux / rc.pulsecounter
1 #!/bin/sh
2
3 ### BEGIN INIT INFO
4 # Provides:             pulsecounter
5 # Required-Start:       $local_fs $remote_fs $syslog $network
6 # Required-Stop:        $local_fs $remote_fs $syslog $network
7 # Default-Start:        2 3 4 5
8 # Default-Stop:         0 1 6
9 # Short-Description:    Water meter pulse counter
10 ### END INIT INFO
11
12 PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin"
13 DAEMON="/usr/local/bin/pulsecounter"
14
15 test -x "$DAEMON" || exit 0
16
17 NAME="pulsecounter"\
18 DESC="Water meter pulse counter"
19 PIDFILE="/var/run/pulsecounter.pid"
20 DEFAULTS="/etc/default/pulsecounter"
21
22 set -e
23
24 [ -r "$DEFAULTS" ] && . "$DEFAULTS"
25
26 . /lib/lsb/init-functions
27
28 do_start()
29 {
30         start-stop-daemon --start --quiet --oknodo --exec $DAEMON -- \
31                 -d -b $SENSOR_MAC
32 }
33
34 do_stop ()
35 {
36         start-stop-daemon --stop --quiet --oknodo --name $NAME
37 }
38
39 case "$1" in
40         start)
41                 init_is_upstart > /dev/null 2>&1 && exit 1
42                 log_daemon_msg "Starting $DESC" "$NAME"
43                 do_start
44                 log_end_msg $?
45                 ;;
46         stop)
47                 init_is_upstart > /dev/null 2>&1 && exit 0
48                 log_daemon_msg "Stopping $DESC" "$NAME"
49                 do_stop
50                 log_end_msg $?
51                 ;;
52         restart|force-reload)
53                 init_is_upstart > /dev/null 2>&1 && exit 1
54                 log_daemon_msg "Restarting $DESC" "$NAME"
55                 do_stop
56                 sleep 1
57                 do_start
58                 log_end_msg $?
59                 ;;
60         status)
61                 status_of_proc $DAEMON $NAME
62                 ;;
63         *)
64                 echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
65                 exit 3
66                 ''
67 esac
68