obtainpid() {
pidstr=`pgrep $prog`
pidcount=`awk -v name="$pidstr" 'BEGIN{split(name,a," "); print length(a)}'`
if [ ! -r "$pidfile" ] && [ $pidcount -ge 2 ]; then
pid=`awk -v name="$pidstr" 'BEGIN{split(name,a," "); print a[1]}'`
echo $prog is already running and it was not started by the init script.
fi
}
stop() {
echo -n $"Shutting down $desc ($prog): "
if [ -r "$pidfile" ]; then
pid=`cat $pidfile`
kill -s 3 $pid
RETVAL=$?
else
RETVAL=1
fi
[ $RETVAL -eq 0 ] && success || failure
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/$prog
rm -f $pidfile
fi
return $RETVAL
}
restart() {
stop
start
}
forcestop() {
echo -n $"Shutting down $desc ($prog): "
kill -s 3 $pid
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/$prog
rm -f $pidfile
fi
return $RETVAL
}
status() {
if [ -r "$pidfile" ]; then
pid=`cat $pidfile`
fi
if [ $pid ]; then
echo "$prog (pid $pid) is running..."
else
echo "$prog is stopped"
fi
}
#!/bin/bash d/init. d/subversion subsys/ svnserve
#
# /etc/rc.
#
# Starts the Subversion Daemon
#
# chkconfig: 2345 90 10
# description: Subversion Daemon
# processname: svnserve
# pidfile: /var/lock/
source /lib/lsb/ init-functions
[ -x /usr/bin/svnserve ] || exit 1
### Default variables "/etc/sysconfig /subversion"
SYSCONFIG=
### Read configuration
[ -r "$SYSCONFIG" ] && source "$SYSCONFIG"
RETVAL=0 "/var/run/ $prog.pid"
prog="svnserve"
desc="Subversion Daemon"
pidfile=
start() { subsys/ $prog
echo -n $"Starting $desc ($prog): "
# daemon $prog -d $OPTIONS --pid-file $pidfile
/usr/bin/$prog -d $OPTIONS --pid-file $pidfile
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch /var/lock/
fi
echo
}
obtainpid() { split(name, a," "); print length(a)}'` split(name, a," "); print a[1]}'`
pidstr=`pgrep $prog`
pidcount=`awk -v name="$pidstr" 'BEGIN{
if [ ! -r "$pidfile" ] && [ $pidcount -ge 2 ]; then
pid=`awk -v name="$pidstr" 'BEGIN{
echo $prog is already running and it was not started by the init script.
fi
}
stop() { subsys/ $prog
echo -n $"Shutting down $desc ($prog): "
if [ -r "$pidfile" ]; then
pid=`cat $pidfile`
kill -s 3 $pid
RETVAL=$?
else
RETVAL=1
fi
[ $RETVAL -eq 0 ] && success || failure
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/
rm -f $pidfile
fi
return $RETVAL
}
restart() {
stop
start
}
forcestop() {
echo -n $"Shutting down $desc ($prog): "
kill -s 3 $pid subsys/ $prog
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/
rm -f $pidfile
fi
return $RETVAL
}
status() {
if [ -r "$pidfile" ]; then
pid=`cat $pidfile`
fi
if [ $pid ]; then
echo "$prog (pid $pid) is running..."
else
echo "$prog is stopped"
fi
}
obtainpid
case "$1" in subsys/ $prog ] && restart stop|forcestop| restart| condrestart| status} "
start)
start
;;
stop)
stop
;;
restart)
restart
RETVAL=$?
;;
condrestart)
[ -e /var/lock/
RETVAL=$?
;;
status)
status
;;
forcestop)
forcestop
;;
*)
echo $"Usage: $0 {start|
RETVAL=1
esac
exit $RETVAL