Hi,
I have a bash script I wrote to monitor two VPN connections. I currently start it from rc.local, but to kill it I have to do a ps aux .... and a kill. To get round this I have hacked another init script, but it does not work as expected. My script is:
Code:
#!/bin/sh
#
# Startup script for ipsec-check. Hacked from pptpd
#
# description: This script starts ipsec-check
# processname: ipsec-check
# pidfile: /var/run/ipsec-check.pid
# Source function library.
. /etc/rc.d/init.d/functions
prog="ipsec-check"
RETVAL=0
# See how we were called.
case "$1" in
start)
echo -n $"Starting $prog: "
daemon /etc/ipsec-check >/dev/null 2>&1 &
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/ipsec-check
;;
stop)
echo -n $"Stopping $prog: "
killproc ipsec-check
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ipsec-check
;;
status)
status ipsec-check
RETVAL=$?
;;
restart|reload)
$0 stop
$0 start
RETVAL=$?
;;
condrestart)
if test "x`/sbin/pidof ipsec-check`" != x; then
$0 stop
$0 start
RETVAL=$?
fi
;;
*)
echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
exit 1
esac
exit $RETVAL
If I use that daemon line I end up with 3 processes:
Code:
ps aux | grep ipsec.c
root 13148 0.0 0.0 4524 772 pts/0 S 17:41 0:00 /bin/sh /etc/init.d/ipsec-check start
root 13150 0.0 0.0 4520 1176 pts/0 S 17:41 0:00 /bin/bash -c ulimit -S -c 0 >/dev/null 2>&1 ; /etc/ipsec-check
root 13151 0.0 0.0 4520 1212 pts/0 S 17:41 0:00 /bin/bash /etc/ipsec-check
instead of just the one I want (13151 in this case).
How do I get it to run just one process?