summaryrefslogtreecommitdiffstats
path: root/redhat/scripts/bcfg2-report-collector.init
blob: 3c112006d3b461172a47859fcaf7ae7ea753f5f3 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#
# bcfg-report-collector - Bcfg2 reporting collector daemon
#
# chkconfig: 2345 19 81
# description: bcfg2 server for reporting data
#
### BEGIN INIT INFO
# Provides:          bcfg2-report-collector
# Required-Start:    $network $remote_fs $named
# Required-Stop:     $network $remote_fs $named
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Configuration management Server
# Description:       Bcfg2 is a configuration management system that builds
#                    installs configuration files served by bcfg2-server
### END INIT INFO

# Include lsb functions
. /etc/init.d/functions

# Commonly used stuff
DAEMON=/usr/sbin/bcfg2-report-collector
PIDFILE=/var/run/bcfg2-server/bcfg2-report-collector.pid
PARAMS="-D $PIDFILE"

# Include default startup configuration if exists
test -f "/etc/sysconfig/bcfg2-report-collector" && . /etc/sysconfig/bcfg2-report-collector

# Exit if $DAEMON doesn't exist and is not executable
test -x $DAEMON || exit 5

# Internal variables
BINARY=$(basename $DAEMON)
RETVAL=0

start () {
    echo -n "Starting Configuration Report Collector: "
    daemon ${DAEMON} ${PARAMS} ${BCFG2_REPORT_OPTIONS} && success || failure
    STATUS=$?
    if [ "$STATUS" = 0 ]
    then
        test -d /var/lock/subsys && touch /var/lock/subsys/$BINARY
    else
        log_failure_msg "bcfg2-report-collector"
    fi
    return $STATUS
}

stop () {
    echo -n "Stopping Configuration Report Collector: "
    if [ -f $PIDFILE ]; then
      killproc -p $PIDFILE ${BINARY}
    else
      killproc ${BINARY}
    fi
    STATUS=$?
    test -e /var/lock/subsys/bcfg2-report-collector && rm /var/lock/subsys/$BINARY
    return $STATUS
}

status () {
    PID=$(pidofproc -p "$PIDFILE" $BINARY)
    if [ -n "$PID" ]; then
      echo "$BINARY (pid $PID) is running..."
      return 0
    fi

    if [ -f $PIDFILE ]; then
      if [ -n "$PID" ]; then
        echo "$BINARY dead but pid file exists..."
        return 1
      fi
    fi

    echo "$BINARY is not running"
    return 3
}

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

exit $RETVAL