Previous Section  < Day Day Up >  Next Section

Appendix D. Init Script for CVSD

#! /bin/sh

# /etc/init.d/cvsd script for starting cvsd

# copied from the Debian installation of 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



CVSD_BIN=/usr/sbin/cvsd

DESC="cvs pserver chroot wrapper"

CVSD_CFG=/etc/cvsd/cvsd.conf



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

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



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

[ -n "$PIDFILE" ] && PFO="--pidfile $PIDFILE"



case "$1" in

start)

  echo -n "Starting $DESC: cvsd"

  start-stop-daemon --start --quiet \

                    $PFO \

                    --exec $CVSD_BIN \

                    -- -f $CVSD_CFG \

    || echo -n " already running"

  echo "."

  ;;

stop)

  echo -n "Stopping $DESC: cvsd"

  start-stop-daemon --stop --quiet  \

                    $PFO \

                    --exec $CVSD_BIN \

    || echo -n " not running"

  echo "."

  [ -n "$PIDFILE" ] && rm -f $PIDFILE

  ;;

restart|force-reload)

  echo -n "Restarting $DESC: cvsd"

  start-stop-daemon --stop --quiet --retry 10 \

                    $PFO \

                    --exec $CVSD_BIN

  [ -n "$PIDFILE" ] && rm -f $PIDFILE

  start-stop-daemon --start --quiet \

                    $PFO \

                    --exec $CVSD_BIN \

                    -- -f $CVSD_CFG \

    || echo -n " not restarted"

  echo "."

  ;;

status)

  echo -n "Status of $DESC: "

  if [ -n "$PIDFILE" ]

  then

    if [ -f "$PIDFILE" ]

    then

      if kill -0 `cat $PIDFILE` > /dev/null 2>&1

      then

        echo "running."

        exit 0

      else

        echo "stopped."

        exit 1

      fi

    else

      echo "stopped."

      exit 3

    fi

  else

    if ps -ef | grep cvsd | grep -v grep > /dev/null 2>&1

    then

      echo "probably running. (no PidFile in cvsd.conf)"

    else

      echo "probably not running. (no PidFile in cvsd.conf)"

      exit 3

    fi

  fi

  ;;

*)

  echo "Usage: $0 {start|stop|restart|force-reload}" >&2

  exit 1

  ;;

esac



exit 0

    Previous Section  < Day Day Up >  Next Section