On 24 May 2009, at 14:37, Jarry wrote:
...
The /etc/init.d/MailScanner script looks so:
----------------------------------
#!/sbin/runscript
opts="${opts} reload"
depend() {
       need net mta
       use logger dns }

start() {
       ebegin "Starting MailScanner"
       /usr/sbin/check_MailScanner >/dev/null
       RETVAL=$?
       [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner
       [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner.off
       eend ${RETVAL}
}

stop() {
       ebegin "Stopping MailScanner"
       killall -15 MailScanner
       RETVAL=$?
       [ ${RETVAL} -eq 0 ] && rm -f /var/lock/subsys/MailScanner
       [ ${RETVAL} -eq 0 ] && touch /var/lock/subsys/MailScanner.off
       eend ${RETVAL}
}
# restart () {} and reload () {} removed
----------------------------------


That's the ugliest init.d script ever. It looks like it fell out of the ugly tree, hit every branch on the way down and now not even its mother could love it. &c &c.

Suggest you follow Mike's advice & rewrite the script based on the other examples installed on your system, the ones written by Gentoo devs. Unfortunately, if you don't know Bash very well, this may be a bit of a mission, but I'm afraid it needs doing.

The script needs to save the process ID of the process that it starts when it opens the application, then to stop the app it needs to kill that specific PID, calling it by number. It needs to check that the commands have worked - for instance: was it successful when it executed `kill $PID`? See Example 6-1 of the Bash Scripting Guide <http://tldp.org/LDP/abs/html/exit-status.html >. See also use of special variable $! in chapter 9 of ABSGuide and also <http://www.unix.com/shell-programming-scripting/26377-pid-bash.html >, but as Mike observes start-stop-daemon should take care of that for you.

Stroller.



Reply via email to