1 |
On 24 May 2009, at 14:37, Jarry wrote: |
2 |
> ... |
3 |
> The /etc/init.d/MailScanner script looks so: |
4 |
> ---------------------------------- |
5 |
> #!/sbin/runscript |
6 |
> opts="${opts} reload" |
7 |
> depend() { |
8 |
> need net mta |
9 |
> use logger dns } |
10 |
> |
11 |
> start() { |
12 |
> ebegin "Starting MailScanner" |
13 |
> /usr/sbin/check_MailScanner >/dev/null |
14 |
> RETVAL=$? |
15 |
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner |
16 |
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner.off |
17 |
> eend ${RETVAL} |
18 |
> } |
19 |
> |
20 |
> stop() { |
21 |
> ebegin "Stopping MailScanner" |
22 |
> killall -15 MailScanner |
23 |
> RETVAL=$? |
24 |
> [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner |
25 |
> [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off |
26 |
> eend ${RETVAL} |
27 |
> } |
28 |
> # restart () {} and reload () {} removed |
29 |
> ---------------------------------- |
30 |
|
31 |
|
32 |
That's the ugliest init.d script ever. It looks like it fell out of |
33 |
the ugly tree, hit every branch on the way down and now not even its |
34 |
mother could love it. &c &c. |
35 |
|
36 |
Suggest you follow Mike's advice & rewrite the script based on the |
37 |
other examples installed on your system, the ones written by Gentoo |
38 |
devs. Unfortunately, if you don't know Bash very well, this may be a |
39 |
bit of a mission, but I'm afraid it needs doing. |
40 |
|
41 |
The script needs to save the process ID of the process that it starts |
42 |
when it opens the application, then to stop the app it needs to kill |
43 |
that specific PID, calling it by number. It needs to check that the |
44 |
commands have worked - for instance: was it successful when it |
45 |
executed `kill $PID`? See Example 6-1 of the Bash Scripting Guide <http://tldp.org/LDP/abs/html/exit-status.html |
46 |
>. See also use of special variable $! in chapter 9 of ABSGuide and |
47 |
also <http://www.unix.com/shell-programming-scripting/26377-pid-bash.html |
48 |
>, but as Mike observes start-stop-daemon should take care of that |
49 |
for you. |
50 |
|
51 |
Stroller. |