creating a sysv script
Craig White
craigwhite at azapple.com
Thu Jan 27 07:34:22 UTC 2005
Trying to use relaydelay.pl from projects.puremagic.com (greylisting
milter for sendmail)
End result is a perl file... and I want to invoke it as a daemon -
detached from any terminal.
it appears that most of the sysv scripts use /etc/rc.d/init.d/functions
to get a more sophisticated box of tools...
my problem is that my sysv script (called relay) hangs at the point
where it wants to initlog -q -c /usr/local/sbin/relaydelay.pl and
this obviously comes from the code in /etc/rc.d/init.d/functions. If I
kill the neverending process...everything is fine and the program is
launched BUT - it never detaches from the terminal. i.e.
#service relay start
then from another terminal (cuz this one never let's go)
#ps aux|grep relay
root 26576 0.0 0.1 2120 932 pts/4 S 00:28
0:00 /bin/sh /sbin/service relay start
root 26579 0.0 0.2 4456 1208 pts/4 S 00:28
0:00 /bin/sh /etc/init.d/relay start
root 26582 0.0 0.1 3784 676 pts/4 S 00:28 0:00 initlog -
q -c /usr/local/sbin/relaydelay.pl
root 26583 0.2 1.2 31004 6408 pts/4 S 00:28
0:00 /usr/bin/perl -w /usr/local/sbin/relaydelay.pl
root 26602 0.0 0.0 1620 472 pts/3 S 00:30 0:00 grep
relay
note that process is still listed in pts/4 (and I have switched to pts/3
cause pts/4 is otherwise occupied)
# kill 26582
# ps aux|grep relay
root 26583 0.1 1.2 31004 6412 pts/4 S 00:28
0:00 /usr/bin/perl -w /usr/local/sbin/relaydelay.pl
root 26613 0.0 0.0 1612 472 pts/3 S 00:32 0:00 grep
relay
I just want it to detach from the terminal (which is apparently the
entire point of /etc/rc.d/init.d/functions
Can someone direct me on this as I don't get it.
The entire contents of /etc/rc.d/init.d/relay
#!/bin/sh
#
# chkconfig: - 98 28
# description: Starts and stops the Relay-Delay
# #
# pidfile: /var/run/relaydelay.pid
# config: /etc/mail/relaydelay.conf
# Source function library.
. /etc/rc.d/init.d/functions
source /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x /root/relaydelay-0.04/relaydelay.pl ] || exit 1
RETVAL=0
prog="/usr/local/sbin/relaydelay.pl"
desc="Greylisting"
start() {
echo -n $"Starting $desc ($prog): "
daemon $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/relaydelay
return $RETVAL
}
stop() {
echo -n $"Shutting down $desc ($prog): "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/relaydelay
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading relaydelay.conf file: "
pkill relaydelay -HUP
RETVAL=$?
echo
return $RETVAL
}
rhstatus() {
status relaydelay
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit $RETVAL
thanks - Craig
More information about the fedora-list
mailing list