#!/bin/sh

# chkconfig: 345 96 04
# description: cvsd is a wrapper program for cvs in pserver mode. it \
# will run 'cvs pserver' under a special uid/gid in a chroot jail.

# /etc/init.d/cvsd script for starting cvsd
# Copyright (C) 2002, 2003, 2004 Arthur de Jong
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

. /etc/rc.d/init.d/functions

CVSD_BIN=@CVSD_BIN@
DESC="cvs pserver chroot wrapper"
CVSD_CFG=@CONFIGFILE@

[ -x "$CVSD_BIN" ] || exit 0
[ -f "$CVSD_CFG" ] || exit 0

PIDFILE=`sed -n 's/^ *PidFile *\([^ ]*\) *$/\1/p' < $CVSD_CFG`

case "$1" in
start)
  echo -n "Starting $DESC: cvsd"
  daemon $CVSD_BIN -f $CVSD_CFG
  echo
  ;;
stop)
  echo -n "Stopping $DESC: cvsd"
  killproc $CVSD_BIN
  echo
  [ -n "$PIDFILE" ] && rm -f $PIDFILE
  ;;
restart)
  $0 stop
  sleep 2
  $0 start
  ;;
status)
  status $CVSD_BIN
  ;;
*)
  echo "Usage: $0 {start|stop|restart|status}"
  exit 1
  ;;
esac

exit 0
