File: cvsd.init.in

package info (click to toggle)
cvsd 1.0.13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,372 kB
  • ctags: 157
  • sloc: sh: 4,552; ansic: 1,868; perl: 198; makefile: 147
file content (124 lines) | stat: -rw-r--r-- 3,102 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#! /bin/sh

# init script for starting and stopping cvsd
# Copyright (C) 2001, 2002, 2003, 2004, 2006 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

### BEGIN INIT INFO
# Provides:          cvsd
# Required-Start:    $local_fs $syslog
# Required-Stop:     $local_fs $syslog
# Should-Start:      $remote_fs $network 
# Should-Stop:       $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      S 0 1 6
# Short-Description: cvs pserver chroot wrapper
# 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.
### END INIT INFO

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

[ -x "$CVSD_BIN" ] || exit 5
[ -f "$CVSD_CFG" ] || exit 6

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

# find the flavor of the echo command (stolen from configure)
case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  *c*,-n*) ECHO_N= ECHO_C='
' ;;
  *c*,*  ) ECHO_N=-n ECHO_C= ;;
  *)       ECHO_N= ECHO_C='\c' ;;
esac

case "$1" in
start)
  echo $ECHO_N "Starting $DESC: cvsd$ECHO_C"
  if [ -n "$PIDFILE" ] && [ -f "$PIDFILE" ] && \
     kill -s 0 `cat $PIDFILE` > /dev/null 2>&1
  then
    echo " already running."
    exit 0
  fi
  RET=0
  $CVSD_BIN -f $CVSD_CFG || RET=7
  echo "."
  exit $RET
  ;;
stop)
  echo $ECHO_N "Stopping $DESC: cvsd$ECHO_C"
  if [ -n "$PIDFILE" ]
  then
    if [ -f "$PIDFILE" ]
    then
      :
    else
      echo " not running."
      exit 0
    fi
    kill `cat $PIDFILE 2> /dev/null` 2> /dev/null
    echo "."
    rm -f $PIDFILE
  else
    echo " unable to stop, no PidFile!"
    exit 1
  fi
  ;;
restart|force-reload)
  $0 stop
  sleep 2
  $0 start || exit 7
  ;;
status)
  echo $ECHO_N "Status of $DESC: $ECHO_C"
  if [ -n "$PIDFILE" ]
  then
    if [ -f "$PIDFILE" ]
    then
      if kill -s 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 -e | grep cvsd | grep -v grep > /dev/null 2>&1
    then
      echo "probably running. (no PidFile in cvsd.conf)"
      exit 0
    else
      echo "probably not running. (no PidFile in cvsd.conf)"
      exit 3
    fi
  fi
  ;;
*)
  echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2
  exit 3
  ;;
esac

exit 0