15 |
kaklik |
1 |
#! /bin/sh |
|
|
2 |
### BEGIN INIT INFO |
|
|
3 |
# Provides: sidd |
|
|
4 |
# Required-Start: $local_fs $remote_fs |
|
|
5 |
# Required-Stop: $local_fs $remote_fs |
|
|
6 |
# Default-Start: 2 3 4 5 |
|
|
7 |
# Default-Stop: S 0 1 6 |
|
|
8 |
# Short-Description: ionograph monitoring daemon start script |
|
|
9 |
# Description: This file start VLF ionosphere monitor system |
|
|
10 |
# |
|
|
11 |
### END INIT INFO |
|
|
12 |
# |
|
|
13 |
# Author: Jakub Kakona |
|
|
14 |
# |
|
|
15 |
# Please remove the "Author" lines above and replace them |
|
|
16 |
# with your own name if you copy and modify this script. |
|
|
17 |
# |
|
|
18 |
# Version: @(#)sidd 2.85-23 7-august-2008 kaklik@mlab.cz |
|
|
19 |
# |
|
|
20 |
|
|
|
21 |
set -e |
|
|
22 |
|
|
|
23 |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/home/sid |
|
|
24 |
DESC="ionosphere monitoring" |
|
|
25 |
NAME=sidd |
|
|
26 |
DAEMON=/home/sid/$NAME |
|
|
27 |
PIDFILE=/var/run/$NAME.pid |
|
|
28 |
SCRIPTNAME=/etc/init.d/$NAME |
|
|
29 |
|
|
|
30 |
# Gracefully exit if the package has been removed. |
|
|
31 |
test -x $DAEMON || exit 0 |
|
|
32 |
|
|
|
33 |
# Read config file if it is present. |
|
|
34 |
if [ /home/sid/$NAME.conf ] |
|
|
35 |
then |
|
|
36 |
. /home/sid/$NAME.conf |
|
|
37 |
fi |
|
|
38 |
|
|
|
39 |
# |
|
|
40 |
# Function that starts the daemon/service. |
|
|
41 |
# |
|
|
42 |
d_start() { |
|
|
43 |
start-stop-daemon --start --quiet --pidfile $PIDFILE \ |
|
|
44 |
--exec $DAEMON \ |
|
|
45 |
|| echo -n " already running" |
|
|
46 |
} |
|
|
47 |
|
|
|
48 |
# |
|
|
49 |
# Function that stops the daemon/service. |
|
|
50 |
# |
|
|
51 |
d_stop() { |
|
|
52 |
start-stop-daemon --stop --quiet --pidfile $PIDFILE \ |
|
|
53 |
--name $NAME \ |
|
|
54 |
|| echo -n " not running" |
|
|
55 |
} |
|
|
56 |
|
|
|
57 |
# |
|
|
58 |
# Function that sends a SIGHUP to the daemon/service. |
|
|
59 |
# |
|
|
60 |
d_reload() { |
|
|
61 |
start-stop-daemon --stop --quiet --pidfile $PIDFILE \ |
|
|
62 |
--name $NAME --signal 1 |
|
|
63 |
} |
|
|
64 |
|
|
|
65 |
case "$1" in |
|
|
66 |
start) |
|
|
67 |
echo -n "Starting $DESC: $NAME" |
|
|
68 |
d_start |
|
|
69 |
echo "." |
|
|
70 |
;; |
|
|
71 |
stop) |
|
|
72 |
echo -n "Stopping $DESC: $NAME" |
|
|
73 |
d_stop |
|
|
74 |
echo "." |
|
|
75 |
;; |
|
|
76 |
#reload) |
|
|
77 |
# |
|
|
78 |
# If the daemon can reload its configuration without |
|
|
79 |
# restarting (for example, when it is sent a SIGHUP), |
|
|
80 |
# then implement that here. |
|
|
81 |
# |
|
|
82 |
# If the daemon responds to changes in its config file |
|
|
83 |
# directly anyway, make this an "exit 0". |
|
|
84 |
# |
|
|
85 |
# echo -n "Reloading $DESC configuration..." |
|
|
86 |
# d_reload |
|
|
87 |
# echo "done." |
|
|
88 |
#;; |
|
|
89 |
restart|force-reload) |
|
|
90 |
# |
|
|
91 |
# If the "reload" option is implemented, move the "force-reload" |
|
|
92 |
# option to the "reload" entry above. If not, "force-reload" is |
|
|
93 |
# just the same as "restart". |
|
|
94 |
# |
|
|
95 |
echo -n "Restarting $DESC: $NAME" |
|
|
96 |
d_stop |
|
|
97 |
# One second might not be time enough for a daemon to stop, |
|
|
98 |
# if this happens, d_start will fail (and dpkg will break if |
|
|
99 |
# the package is being upgraded). Change the timeout if needed |
|
|
100 |
# be, or change d_stop to have start-stop-daemon use --retry. |
|
|
101 |
# Notice that using --retry slows down the shutdown process somewhat. |
|
|
102 |
sleep 1 |
|
|
103 |
d_start |
|
|
104 |
echo "." |
|
|
105 |
;; |
|
|
106 |
*) |
|
|
107 |
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 |
|
|
108 |
exit 3 |
|
|
109 |
;; |
|
|
110 |
esac |
|
|
111 |
|
|
|
112 |
exit 0 |