Mercurial > hg > freeDiameter
comparison contrib/debian/freediameter-daemon.init @ 328:90294e7e986c
Moved the debian dir outside the top level directory
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 28 May 2010 17:19:22 +0900 |
parents | debian/freediameter-daemon.init@b26ed8eff9bf |
children | adc78299a151 |
comparison
equal
deleted
inserted
replaced
327:0f43f42669be | 328:90294e7e986c |
---|---|
1 #! /bin/sh | |
2 | |
3 ### BEGIN INIT INFO | |
4 # Provides: freediameter | |
5 # Default-Start: 2 3 4 5 | |
6 # Default-Stop: 0 1 6 | |
7 # Required-Start: $remote_fs $syslog | |
8 # Required-Stop: $remote_fs $syslog | |
9 # Short-Description: Start freeDiameter daemon at boot time | |
10 # Description: Start the freeDiameter daemon at boot time. | |
11 # freeDiameter is an extensible implementation of the Diameter protocol, | |
12 # designed for Authentication, Authorization and Accounting. Diameter is | |
13 # an evolution of the RADIUS protocol. | |
14 ### END INIT INFO# | |
15 | |
16 DAEMON=/usr/bin/freeDiameterd | |
17 CONF=/etc/freeDiameter/freeDiameter.conf | |
18 NAME=freediameter | |
19 DESC=freeDiameter daemon | |
20 | |
21 test -x $DAEMON || exit 0 | |
22 | |
23 LOGDIR=/var/log/freediameter | |
24 PIDFILE=/var/run/$NAME.pid | |
25 DODTIME=30 # Time to wait for the server to die, in seconds | |
26 # The value is high because we wait for STA answers | |
27 # before disconnecting the peers. | |
28 | |
29 # Include freediameter defaults if available | |
30 if [ -f /etc/default/freediameter ] ; then | |
31 . /etc/default/freediameter | |
32 fi | |
33 | |
34 test x"" != x$DAEMON_OPTS || test -f $CONF || exit 0 | |
35 | |
36 set -e | |
37 | |
38 running_pid() | |
39 { | |
40 # Check if a given process pid's cmdline matches a given name | |
41 pid=$1 | |
42 name=$2 | |
43 [ -z "$pid" ] && return 1 | |
44 [ ! -d /proc/$pid ] && return 1 | |
45 cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1` | |
46 # Is this the expected child? | |
47 [ "$cmd" != "$name" ] && return 1 | |
48 return 0 | |
49 } | |
50 | |
51 running() | |
52 { | |
53 # Check if the process is running looking at /proc | |
54 # (works for all users) | |
55 | |
56 # No pidfile, probably no daemon present | |
57 [ ! -f "$PIDFILE" ] && return 1 | |
58 # Obtain the pid and check it against the binary name | |
59 pid=`cat $PIDFILE` | |
60 running_pid $pid $DAEMON || return 1 | |
61 return 0 | |
62 } | |
63 | |
64 force_stop() { | |
65 # Forcefully kill the process | |
66 [ ! -f "$PIDFILE" ] && return | |
67 if running ; then | |
68 kill -15 $pid | |
69 # Is it really dead? | |
70 [ -n "$DODTIME" ] && sleep "$DODTIME"s | |
71 if running ; then | |
72 kill -9 $pid | |
73 [ -n "$DODTIME" ] && sleep "$DODTIME"s | |
74 if running ; then | |
75 echo "Cannot kill $LABEL (pid=$pid)!" | |
76 exit 1 | |
77 fi | |
78 fi | |
79 fi | |
80 rm -f $PIDFILE | |
81 return 0 | |
82 } | |
83 | |
84 case "$1" in | |
85 start) | |
86 echo -n "Starting $DESC: " | |
87 start-stop-daemon --start --quiet --pidfile $PIDFILE \ | |
88 --exec $DAEMON -- $DAEMON_OPTS | |
89 if running ; then | |
90 echo "$NAME." | |
91 else | |
92 echo " ERROR." | |
93 fi | |
94 ;; | |
95 stop) | |
96 echo -n "Stopping $DESC: " | |
97 start-stop-daemon --stop --quiet --pidfile $PIDFILE \ | |
98 --exec $DAEMON | |
99 echo "$NAME." | |
100 ;; | |
101 force-stop) | |
102 echo -n "Forcefully stopping $DESC: " | |
103 force_stop | |
104 if ! running ; then | |
105 echo "$NAME." | |
106 else | |
107 echo " ERROR." | |
108 fi | |
109 ;; | |
110 #reload) | |
111 # | |
112 # If the daemon can reload its config files on the fly | |
113 # for example by sending it SIGHUP, do it here. | |
114 # | |
115 # If the daemon responds to changes in its config file | |
116 # directly anyway, make this a do-nothing entry. | |
117 # | |
118 # echo "Reloading $DESC configuration files." | |
119 # start-stop-daemon --stop --signal 1 --quiet --pidfile \ | |
120 # /var/run/$NAME.pid --exec $DAEMON | |
121 #;; | |
122 force-reload) | |
123 # | |
124 # If the "reload" option is implemented, move the "force-reload" | |
125 # option to the "reload" entry above. If not, "force-reload" is | |
126 # just the same as "restart" except that it does nothing if the | |
127 # daemon isn't already running. | |
128 # check wether $DAEMON is running. If so, restart | |
129 start-stop-daemon --stop --test --quiet --pidfile \ | |
130 /var/run/$NAME.pid --exec $DAEMON \ | |
131 && $0 restart \ | |
132 || exit 0 | |
133 ;; | |
134 restart) | |
135 echo -n "Restarting $DESC: " | |
136 start-stop-daemon --stop --quiet --pidfile \ | |
137 /var/run/$NAME.pid --exec $DAEMON | |
138 [ -n "$DODTIME" ] && sleep $DODTIME | |
139 start-stop-daemon --start --quiet --pidfile \ | |
140 /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS | |
141 echo "$NAME." | |
142 ;; | |
143 status) | |
144 echo -n "$LABEL is " | |
145 if running ; then | |
146 echo "running" | |
147 else | |
148 echo " not running." | |
149 exit 1 | |
150 fi | |
151 ;; | |
152 *) | |
153 N=/etc/init.d/$NAME | |
154 # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 | |
155 echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2 | |
156 exit 1 | |
157 ;; | |
158 esac | |
159 | |
160 exit 0 |