aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-support/puppet/puppet/puppet.init
blob: 64ab32ee84fab3845050dbbbba3bb7569f29a91d (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
#!/bin/bash
#
# chkconfig: 35 20 80
# description: The puppet agent connects to a puppet master, requests a
#              catalog of resources, and configures the local system.
#

# Get function from functions library
. /etc/init.d/functions

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/puppet
DAEMON_OPTS="agent --server master --no-daemonize"
NAME="agent"
DESC="puppet agent"
PIDFILE="/var/run/${NAME}.pid"
PID=`test -f $PIDFILE && cat $PIDFILE`
RETVAL=0

test -x $DAEMON || exit 0

[ -r /etc/default/puppet ] && . /etc/default/puppet

reload_puppet_agent() {
    start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE
}

start_puppet_agent() {
    start-stop-daemon --start --quiet --pidfile $PIDFILE \
        --startas $DAEMON -- $NAME $DAEMON_OPTS
}

stop_puppet_agent() {
    start-stop-daemon --stop --retry TERM/10/KILL/5 --quiet --oknodo --pidfile $PIDFILE
}

status_puppet_agent() {
    status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}"
}

case "$1" in
    start)
        echo -n "Starting $DESC"
        start_puppet_agent
        log_end_msg $?
        ;;
    stop)
        echo -n "Stopping $DESC"
        stop_puppet_agent
        log_end_msg $?
        ;;
    reload)
        echo -n "Reloading $DESC"
        reload_puppet_agent
        log_end_msg $?
        ;;
    status)
        status_puppet_agent
        ;;
    restart|force-reload)
        echo -n "Restarting $DESC"
        stop_puppet_agent
        start_puppet_agent
        log_end_msg $?
        ;;
*)
        echo "Usage: $0 {start|stop|status|restart|force-reload|reload}" >&2
        exit 1
        ;;
esac

exit 0