File: cvsd.init

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 (109 lines) | stat: -rw-r--r-- 3,125 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
#! /bin/sh

# /etc/init.d/cvsd script for starting and stopping cvsd
# Copyright (C) 2002, 2003, 2004, 2005, 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

PATH=/bin:/usr/bin:/sbin:/usr/sbin
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

. /lib/lsb/init-functions

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

case "$1" in
start)
  log_daemon_msg "Starting $DESC" "cvsd"
  start-stop-daemon --start \
                    $PFO \
                    --startas $CVSD_BIN \
                    -- -f $CVSD_CFG
  log_end_msg $?
  ;;
stop)
  log_daemon_msg "Stopping $DESC" "cvsd"
  start-stop-daemon --stop \
                    $PFO \
                    --name cvsd
  log_end_msg $?
  [ -n "$PIDFILE" ] && rm -f $PIDFILE
  ;;
restart|force-reload)
  log_daemon_msg "Restarting $DESC" "cvsd"
  start-stop-daemon --stop --quiet --retry 10 \
                    $PFO \
                    --name cvsd
  [ -n "$PIDFILE" ] && rm -f $PIDFILE
  start-stop-daemon --start \
                    $PFO \
                    --startas $CVSD_BIN \
                    -- -f $CVSD_CFG
  log_end_msg $?
  ;;
status)
  if [ -n "$PIDFILE" ]
  then
    if [ -f "$PIDFILE" ]
    then
      if kill -s 0 `cat $PIDFILE` > /dev/null 2>&1
      then
        log_success_msg "cvsd running"
        exit 0
      else
        log_success_msg "cvsd stopped"
        exit 1
      fi
    else
      log_success_msg "cvsd stopped"
      exit 3
    fi
  else
    if ps -ef | grep cvsd | grep -v grep > /dev/null 2>&1
    then
      log_warning_msg "cvsd probably running (no PidFile in cvsd.conf)"
    else
      log_warning_msg "cvsd probably not running (no PidFile in cvsd.conf)"
      exit 3
    fi
  fi
  ;;
*)
  log_success_msg "Usage: $0 {start|stop|restart|force-reload|status}"
  exit 1
  ;;
esac

exit 0