~upstart-devel/upstart/upstart-jobs

« back to all changes in this revision

Viewing changes to utopic/etc/init.d/buildd

  • Committer: Dimitri John Ledkov
  • Date: 2014-11-19 12:58:41 UTC
  • Revision ID: dimitri.j.ledkov@intel.com-20141119125841-98dr37roy8dvcv3b
auto update

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#! /bin/sh
2
 
#
3
 
### BEGIN INIT INFO
4
 
# Provides:          buildd
5
 
# Required-Start:    $local_fs $network $remote_fs
6
 
# Required-Stop:     $local_fs $network $remote_fs
7
 
# Should-Start:      schroot
8
 
# Should-Stop:
9
 
# Default-Start:     2 3 4 5
10
 
# Default-Stop:      0 1 6
11
 
# Short-Description: Debian package autobuilder daemon
12
 
# Description:       Control the buildd daemon.
13
 
### END INIT INFO
14
 
#
15
 
# Copyright © 2006-2009  Roger Leigh <rleigh@debian.org>
16
 
# Copyright © 2007       Federico Di Gregorio <fog@debian.org>
17
 
#
18
 
# sbuild is free software: you can redistribute it and/or modify it
19
 
# under the terms of the GNU General Public License as published by
20
 
# the Free Software Foundation, either version 3 of the License, or
21
 
# (at your option) any later version.
22
 
#
23
 
# sbuild is distributed in the hope that it will be useful, but
24
 
# WITHOUT ANY WARRANTY; without even the implied warranty of
25
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
26
 
# General Public License for more details.
27
 
#
28
 
# You should have received a copy of the GNU General Public License
29
 
# along with this program.  If not, see
30
 
# <http://www.gnu.org/licenses/>.
31
 
 
32
 
DAEMON=/usr/bin/buildd
33
 
PIDFILE=/var/lib/buildd/build/buildd.pid
34
 
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
35
 
NAME=buildd
36
 
DESC="Debian package autobuilder"
37
 
 
38
 
. /lib/lsb/init-functions
39
 
 
40
 
test -x $BUILDD || exit 0
41
 
test -x $BUILDD_WATCHER || exit 0
42
 
 
43
 
# Include buildd defaults if available
44
 
if [ -f "/etc/default/$NAME" ] ; then
45
 
    . "/etc/default/$NAME"
46
 
fi
47
 
 
48
 
set -e
49
 
 
50
 
start () {
51
 
    log_begin_msg "Starting $DESC: $NAME "
52
 
 
53
 
    if [ -e /var/lib/buildd/NO-DAEMON-PLEASE ]; then
54
 
        log_failure_msg "NO-DAEMON-PLEASE exists, not starting"
55
 
    else
56
 
        start-stop-daemon --start --quiet --oknodo --pidfile "$PIDFILE" --chuid buildd:buildd --exec $DAEMON
57
 
 
58
 
        log_end_msg $?
59
 
    fi
60
 
}
61
 
 
62
 
stop () {
63
 
    log_begin_msg "Stopping $DESC: $NAME"
64
 
 
65
 
    start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME
66
 
 
67
 
    log_end_msg $?
68
 
}
69
 
 
70
 
reload () {
71
 
    log_begin_msg "Reloading $DESC: $NAME"
72
 
    start-stop-daemon --stop --quiet --pidfile $PIDFILE --name $NAME --signal USR1 && success=1
73
 
    log_end_msg $?
74
 
}
75
 
 
76
 
restart () {
77
 
    log_begin_msg "Restarting $DESC: $NAME "
78
 
    if start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME; then
79
 
       if [ -e /var/lib/buildd/NO-DAEMON-PLEASE ]; then
80
 
           log_failure_msg "NO-DAEMON-PLEASE exists, not starting"
81
 
       else
82
 
           start-stop-daemon --start --quiet --pidfile "$PIDFILE"  --chuid buildd:buildd --exec $DAEMON
83
 
       fi
84
 
    fi
85
 
    log_end_msg $?
86
 
}
87
 
 
88
 
case "$1" in
89
 
    start)
90
 
        start
91
 
        ;;
92
 
    restart)
93
 
        restart
94
 
        ;;
95
 
    force-reload)
96
 
        reload
97
 
        ;;
98
 
    stop)
99
 
        stop
100
 
        ;;
101
 
    status)
102
 
        echo -n "Status of $DESC: "
103
 
        if [ ! -r "$PIDFILE" ]; then
104
 
            echo "$NAME is not running."
105
 
            exit 3
106
 
        fi
107
 
        if read pid < "$PIDFILE" && ps -p "$pid" > /dev/null 2>&1; then
108
 
            echo "$NAME is running."
109
 
            exit 0
110
 
        else
111
 
            echo "$NAME is not running but $PIDFILE exists."
112
 
            exit 1
113
 
        fi
114
 
        ;;
115
 
    *)
116
 
        N=/etc/init.d/$NAME
117
 
        echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
118
 
        exit 1
119
 
        ;;
120
 
esac
121
 
 
122
 
exit 0