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

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

Renamed init script to 'invirtibuilder'

  • Property svn:executable set to *
File size: 1.8 KB
RevLine 
[890]1#!/bin/bash
[2552]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
[853]11
[2552]12# Author: Invirt project <invirt@mit.edu>
[853]13
[2552]14# Do NOT "set -e"
[853]15
[3033]16NAME=invirtibuilder
17DESC="the Invirt build daemon"
18DAEMON="/usr/bin/$NAME"
19PIDFILE="/var/run/$NAME.pid"
[2552]20GEN_FILES=/srv/repository/conf/distributions
[853]21
[3033]22[ -x "$DAEMON" ] || exit 0
23
[2589]24. /lib/init/std-init.sh
[2552]25. /lib/init/gen-files.sh
26
[2589]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
[2633]34
[2589]35    gen_files || ret=2
[2634]36    for d in db dists lists pool; do
37        dir="/srv/repository/$d"
[2635]38        mkdir -p "$dir"
[2634]39        chown -R repository:nogroup "$dir"
40    done
[2589]41    reprepro-env export || ret=2
[2633]42
[2589]43    invirt-build-conf || ret=2
[2633]44
[3033]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
[2589]57    return $ret
58}
59
60do_stop()
61{
[3033]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"
[2589]74}
75
76do_reload()
77{
[3033]78    do_stop
[2589]79    do_start
80}
[2628]81
[2629]82std_init "$@"
Note: See TracBrowser for help on using the repository browser.