#!/bin/sh
# chkconfig: - 95 02
# description: The Coda update server and clients
# Source function library.
. /etc/rc.d/init.d/functions
exec1=/usr/sbin/updatesrv
exec2=/usr/sbin/updateclnt
prog1=updatesrv
prog2=updateclnt
pidfile1=/vice/misc/$prog1.pid
pidfile2=/vice/misc/$prog2.pid
config=/vice/db/scm
lockfile=/var/lock/subsys/update
[ -e /etc/sysconfig/update ] && . /etc/sysconfig/update
start() {
[ -x $exec1 ] || exit 5
[ -x $exec2 ] || exit 5
[ -f $config ] || exit 6
if [ "`cat /vice/hostname`" = "`cat /vice/db/scm`" ]; then
prog="coda update server"
echo -n $"Starting $prog: "
daemon --pidfile=$pidfile1 $exec1
retval=$?
echo
[ $retval -ne 0 ] && return $retval
fi
prog="coda update client"
echo -n $"Starting $prog: "
daemon --pidfile=$pidfile2 $exec2 -h `cat /vice/db/scm`
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
retval=0
if [ "`cat /vice/hostname`" = "`cat /vice/db/scm`" ]; then
prog="coda update server"
echo -n $"Stopping $prog: "
killproc -p $pidfile1 $prog1
retval=$?
echo
fi
prog="coda update client"
echo -n $"Stopping $prog: "
killproc -p $pidfile2 $prog2
retval2=$?
[ $retval2 -ne 0 ] && retval=$retval2
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
start
}
reload() {
restart
}
force_reload() {
restart
}
rh_status() {
retval=0
if [ "`cat /vice/hostname`" = "`cat /vice/db/scm`" ]; then
status -p $pidfile1 $prog1
retval=$?
fi
status -p $pidfile2 $prog2
retval2=$?
[ $retval2 -ne 0 ] && retval=$retval2
return $retval
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?