source: trunk/packages/invirt-dev/debian/invirt-dev.invirtibuilder.init @ 3044

Last change on this file since 3044 was 3034, checked in by gdb, 14 years ago

Renamed init script to 'invirtibuilder'

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/bin/bash
2### BEGIN INIT INFO
3# Provides:          invirt-dev
4# Required-Start:    $local_fs $remote_fs
5# Required-Stop:     $local_fs $remote_fs
6# Default-Start:     2 3 4 5
7# Default-Stop:      0 1 6
8# Short-Description: Invirt development configuration
9# Description:       
10### END INIT INFO
11
12# Author: Invirt project <invirt@mit.edu>
13
14# Do NOT "set -e"
15
16NAME=invirtibuilder
17DESC="the Invirt build daemon"
18DAEMON="/usr/bin/$NAME"
19PIDFILE="/var/run/$NAME.pid"
20GEN_FILES=/srv/repository/conf/distributions
21
22[ -x "$DAEMON" ] || exit 0
23
24. /lib/init/std-init.sh
25. /lib/init/gen-files.sh
26
27do_start()
28{
29    # Return
30    #  0 if daemon has been started
31    #  1 if daemon was already running
32    #  2 if daemon could not be started
33    ret=0
34
35    gen_files || ret=2
36    for d in db dists lists pool; do
37        dir="/srv/repository/$d"
38        mkdir -p "$dir"
39        chown -R repository:nogroup "$dir"
40    done
41    reprepro-env export || ret=2
42
43    invirt-build-conf || ret=2
44
45    if [ "$ret" = 0 ]; then
46        # Return
47        #   0 if daemon has been started
48        #   1 if daemon was already running
49        #   2 if daemon could not be started
50        log_daemon_msg "Starting $DESC" "$NAME"
51        if daemon --running -n $NAME; then
52            log_daemon_msg "$NAME is already running!"
53            return 1
54        fi
55        daemon -r -O daemon.info -E daemon.err -n $NAME -U $DAEMON || return 2
56    fi
57    return $ret
58}
59
60do_stop()
61{
62    # Return
63    #   0 if daemon has been stopped
64    #   1 if daemon was already stopped
65    #   2 if daemon could not be stopped
66    #   other if a failure occurred
67    log_daemon_msg "Stopping $DESC" "$NAME"
68    daemon --stop -n $NAME
69    RETVAL="$?"
70    [ "$RETVAL" = 2 ] && return 2
71    # Many daemons don't delete their pidfiles when they exit.
72    # rm -f $PIDFILE
73    return "$RETVAL"
74}
75
76do_reload()
77{
78    do_stop
79    do_start
80}
81
82std_init "$@"
Note: See TracBrowser for help on using the repository browser.