Line | |
---|
1 | #!/bin/sh |
---|
2 | |
---|
3 | ### BEGIN INIT INFO |
---|
4 | # Provides: flarmradar |
---|
5 | # Required-Start: $remote_fs $syslog |
---|
6 | # Required-Stop: $remote_fs $syslog |
---|
7 | # Default-Start: 5 |
---|
8 | # Default-Stop: 6 |
---|
9 | # Short-Description: FlarmRadar |
---|
10 | # Description: Put a long description of the service here |
---|
11 | ### END INIT INFO |
---|
12 | |
---|
13 | # Change the next 3 lines to suit where you install your script and what you want to call it |
---|
14 | DIR=/home/pi/flarmradar |
---|
15 | DAEMON=$DIR/flarmradar.pl |
---|
16 | DAEMON_OPT='-f /home/pi/flarmradar/testdata/Flarm07Jul13.TXT' |
---|
17 | DAEMON_NAME=flarmradar |
---|
18 | |
---|
19 | # This next line determines what user the script runs as. |
---|
20 | # Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python. |
---|
21 | DAEMON_USER=pi |
---|
22 | |
---|
23 | # The process ID of the script when it runs is stored here: |
---|
24 | PIDFILE=/var/run/$DAEMON_NAME.pid |
---|
25 | |
---|
26 | . /lib/lsb/init-functions |
---|
27 | |
---|
28 | do_start () { |
---|
29 | log_daemon_msg "Starting system $DAEMON_NAME daemon" |
---|
30 | start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile $PIDFILE --user $DAEMON_USER --startas $DAEMON -- $DAEMON_OPT |
---|
31 | log_end_msg $? |
---|
32 | } |
---|
33 | do_stop () { |
---|
34 | log_daemon_msg "Stopping system $DAEMON_NAME daemon" |
---|
35 | start-stop-daemon --stop --pidfile $PIDFILE --retry 10 |
---|
36 | log_end_msg $? |
---|
37 | } |
---|
38 | |
---|
39 | case "$1" in |
---|
40 | |
---|
41 | start|stop) |
---|
42 | do_${1} |
---|
43 | ;; |
---|
44 | |
---|
45 | restart|reload|force-reload) |
---|
46 | do_stop |
---|
47 | do_start |
---|
48 | ;; |
---|
49 | |
---|
50 | status) |
---|
51 | status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $? |
---|
52 | ;; |
---|
53 | *) |
---|
54 | echo "Usage: /etc/init.d/$DEAMON_NAME {start|stop|restart|status}" |
---|
55 | exit 1 |
---|
56 | ;; |
---|
57 | |
---|
58 | esac |
---|
59 | exit 0 |
---|
Note: See
TracBrowser
for help on using the repository browser.