summaryrefslogtreecommitdiff
path: root/debian/puppet.init
blob: 381e998560e06e65899c07ebe856262d314c63f0 (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
#! /bin/sh
### BEGIN INIT INFO
# Provides:          puppet
# Required-Start:    $network $named $remote_fs $syslog
# Required-Stop:     $network $named $remote_fs $syslog
# Should-Start:      puppetmaster apache2
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: puppet agent
# Description:       The puppet agent connects to a puppet master, requests a
#                    catalog of resources, and configures the local system.
### END INIT INFO                                                                                                                                          

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/puppet
DAEMON_OPTS=""
NAME="agent"
DESC="puppet agent"
PIDFILE="/var/run/puppet/${NAME}.pid"

test -x $DAEMON || exit 0

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

. /lib/lsb/init-functions

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 --quiet --oknodo --pidfile $PIDFILE
}

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

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