summaryrefslogtreecommitdiffstats
path: root/redhat/scripts/bcfg2-server.init
blob: 7fd1bd906cf6a587aaf3f1944d96b7078238b86e (plain)
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
#!/bin/sh
#
# bcfg2-server - bcfg2 configuration daemon
#
# chkconfig: 345 80 20
# description: bcfg2 is a configuration management system that builds \
#              and installs configuration files. \
#              This is the server that provides the configurations \
#              to clients.

DAEMON=/usr/sbin/bcfg2-server
PIDFILE=/var/run/bcfg2-server/bcfg2-server.pid
PARAMS="-D $PIDFILE"
prog=$(basename $DAEMON)
conf="/etc/bcfg2.conf"

# Disabled per default
BCFG2_SERVER_OPTIONS=""
BCFG2_SERVER_ENABLED=0

PATH=/sbin:/bin:/usr/bin:/usr/sbin

# Source function library
. /etc/init.d/functions

# Include default startup configuration if exists
test -f /etc/sysconfig/$prog && . /etc/sysconfig/$prog

if [ "$BCFG2_SERVER_ENABLED" -eq 0 ] ; then
     failure $"bcfg2-server is disabled - see /etc/sysconfig/bcfg2-server"
     echo
     exit 0
fi

RETVAL=0

start () {
    test -x $DAEMON || exit 5
    test -f $conf || exit 6
    echo -n $"Starting $prog: "
    daemon $DAEMON ${PARAMS} ${BCFG2_SERVER_OPTIONS} && success || failure
    RETVAL=$?
    echo
    if test $RETVAL = 0 ; then
        test -d /var/lock/subsys && touch /var/lock/subsys/$prog
    fi
    return $RETVAL
}

stop () {
    echo -n $"Stopping $prog: "
    # we do NOT want to specify the pidfile to killproc; if we do, and
    # it has to kill -9 the server, it only kills the master and the
    # child processes stay running (if the multiprocessing core is in
    # use).  By not specifying a pidfile, it looks in the process
    # table for all bcfg2-server processes, and kill -9's them all if
    # necessary.
    killproc -d 30 ${prog} && success || failure
    RETVAL=$?
    echo
    rm -f /var/lock/subsys/$prog
    return $RETVAL
}

case "$1" in
    start)
        start
        RETVAL=$?
    ;;
    stop)
        stop
        RETVAL=$?
    ;;
    status)
        status $prog
        RETVAL=$?
    ;;
    restart|reload|force-reload)
        stop
        sleep 5
        start
        RETVAL=$?
    ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
        RETVAL=3
    ;;
esac

exit $RETVAL