File: buildd.init

package info (click to toggle)
sbuild 0.60.0-2squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,136 kB
  • ctags: 640
  • sloc: perl: 14,039; sh: 1,173; sql: 772; makefile: 406
file content (130 lines) | stat: -rwxr-xr-x 3,257 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
125
126
127
128
129
130
#! /bin/sh
#
### BEGIN INIT INFO
# Provides:          buildd
# Required-Start:    $local_fs $network $remote_fs
# Required-Stop:
# Should-Start:      schroot
# Should-Stop:
# Default-Start:     S
# Default-Stop:
# Short-Description: Debian package autobuilder daemon
# Description:       Control the buildd daemon.
### END INIT INFO
#
# Copyright © 2006-2009  Roger Leigh <rleigh@debian.org>
# Copyright © 2007       Federico Di Gregorio <fog@debian.org>
#
# sbuild 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 3 of the License, or
# (at your option) any later version.
#
# sbuild 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, see
# <http://www.gnu.org/licenses/>.

DAEMON=/usr/bin/buildd
PIDFILE=/var/lib/buildd/build/buildd.pid
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=buildd
DESC="Debian package autobuilder"

. /lib/lsb/init-functions

test -x $BUILDD || exit 0
test -x $BUILDD_WATCHER || exit 0

# Include buildd defaults if available
if [ -f "/etc/default/$NAME" ] ; then
    . "/etc/default/$NAME"
fi

set -e

start () {
    log_begin_msg "Starting $DESC: $NAME"

    if [ -e /home/buildd/NO-DAEMON-PLEASE ]; then
        log_failure_msg "NO-DAEMON-PLEASE exists, not starting"
    else
        start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --chuid buildd:buildd --exec $DAEMON

        log_end_msg $?
    fi
}

stop () {
    log_begin_msg "Stopping $DESC: $NAME"

    start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME

    log_end_msg $?
}

stop () {
    log_begin_msg "Stopping $DESC: $NAME"

    start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME

    log_end_msg $?
}

reload () {
    log_begin_msg "Reloading $DESC: $NAME"
    start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --signal USR1 && success=1
    log_end_msg $?
}

restart () {
    log_begin_msg "Restarting $DESC: $NAME"
    if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
       if [ -e /home/buildd/NO-DAEMON-PLEASE ]; then
           log_failure_msg "NO-DAEMON-PLEASE exists, not starting"
       else
           start-stop-daemon --start --quiet --pidfile "$PIDFILE"  --chuid buildd:buildd --exec $DAEMON
       fi
    fi
    log_end_msg $?
}

case "$1" in
    start)
	start
	;;
    restart)
	restart
        ;;
    force-reload)
	reload
	;;
    stop)
	stop
	;;
    status)
	echo -n "Status of $DESC: "
	if [ ! -r "$PIDFILE" ]; then
	    echo "$NAME is not running."
	    exit 3
	fi
	if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
	    echo "$NAME is running."
	    exit 0
	else
	    echo "$NAME is not running but $PIDFILE exists."
	    exit 1
	fi
	;;
    *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0