1 |
#!/bin/sh |
2 |
# puppet Init script for running the puppet client daemon |
3 |
# |
4 |
# Author: Duane Griffin <d.griffin@psenterprise.com> |
5 |
# David Lutterkort <dlutter@redhat.com> |
6 |
# |
7 |
# chkconfig: - 98 02 |
8 |
# |
9 |
# description: Starts the puppetd daemon (for Puppet clients) |
10 |
# processname: puppetd |
11 |
# config: /etc/sysconfig/puppetd |
12 |
|
13 |
### BEGIN INIT INFO |
14 |
# Provides: puppet |
15 |
# Required-Start: $local_fs $network $syslog |
16 |
# Should-Start: $named |
17 |
# Required-Stop: $network |
18 |
# Should-Stop: $named |
19 |
# Default-Start: 2 3 4 5 |
20 |
# Default-Stop: 0 1 6 |
21 |
# Short-Description: Starts the puppetd daemon (for Puppet clients) |
22 |
# Description: puppetd is the client for the puppet system management tool. |
23 |
# It enables periodic system configuration checks on which |
24 |
# it's running. |
25 |
### END INIT INFO |
26 |
|
27 |
# Local variables |
28 |
DAEMON_NAME=puppetd |
29 |
DAEMON_PROCESS=$DAEMON_NAME |
30 |
DAEMON_BINARY=/usr/sbin/$DAEMON_PROCESS |
31 |
LOCKFILE=/var/lock/subsys/$DAEMON_PROCESS |
32 |
PIDFILE=/var/run/$DAEMON_PROCESS.pid |
33 |
|
34 |
RETVAL=0 |
35 |
|
36 |
# Source function library. |
37 |
. /etc/rc.d/init.d/functions |
38 |
|
39 |
# Source networking configuration. |
40 |
. /etc/sysconfig/network |
41 |
|
42 |
# Check that networking is up. |
43 |
[ ${NETWORKING} = "no" ] && exit 0 |
44 |
|
45 |
# load service configuration |
46 |
[ -f /etc/sysconfig/$DAEMON_NAME ] && . /etc/sysconfig/$DAEMON_NAME |
47 |
|
48 |
OPTIONS="" |
49 |
[ -n "${PUPPET_SERVER}" ] && OPTIONS="--server=${PUPPET_SERVER}" |
50 |
[ -n "${PUPPET_LOG}" ] && OPTIONS="${OPTIONS} --logdest=${PUPPET_LOG}" |
51 |
[ -n "${PUPPET_PORT}" ] && OPTIONS="${OPTIONS} --port=${PUPPET_PORT}" |
52 |
[ -n "${PUPPET_EXTRA_OPTS}" ] && OPTIONS="${OPTIONS} ${PUPPET_EXTRA_OPTS}" |
53 |
start() { |
54 |
# Check if it is already running |
55 |
if [ ! -f $LOCKFILE ]; then |
56 |
gprintf "Starting %s daemon: " "$DAEMON_NAME" |
57 |
# use --user to run the daemon under the specified uid |
58 |
daemon $DAEMON_BINARY $OPTIONS $PUPPET_EXTRA_OPTS |
59 |
RETVAL=$? |
60 |
[ $RETVAL -eq 0 ] && touch $LOCKFILE |
61 |
echo |
62 |
fi |
63 |
return $RETVAL |
64 |
} |
65 |
|
66 |
stop() { |
67 |
gprintf "Stopping %s daemon: " "$DAEMON_NAME" |
68 |
killproc $DAEMON_PROCESS |
69 |
RETVAL=$? |
70 |
[ $RETVAL -eq 0 ] && rm -f $LOCKFILE |
71 |
echo |
72 |
return $RETVAL |
73 |
} |
74 |
|
75 |
restart() { |
76 |
stop |
77 |
start |
78 |
} |
79 |
|
80 |
reload() { |
81 |
echo "Reloading $DAEMON_NAME configuration" |
82 |
gprintf "Reloading %s daemon: " "$DAEMON_NAME" |
83 |
killproc $DAEMON_PROCESS -HUP |
84 |
RETVAL=$? |
85 |
echo |
86 |
return $RETVAL |
87 |
} |
88 |
|
89 |
|
90 |
|
91 |
case "$1" in |
92 |
start) |
93 |
start |
94 |
;; |
95 |
stop) |
96 |
stop |
97 |
;; |
98 |
restart) |
99 |
restart |
100 |
;; |
101 |
condrestart|condreload) |
102 |
if [ -f $LOCKFILE ]; then |
103 |
restart |
104 |
fi |
105 |
;; |
106 |
status) |
107 |
status $DAEMON_PROCESS |
108 |
RETVAL=$? |
109 |
;; |
110 |
reload) |
111 |
reload |
112 |
;; |
113 |
*) |
114 |
echo "Usage: $0 {start|stop|restart|reload|condrestart|condreload|status}" |
115 |
RETVAL=1 |
116 |
;; |
117 |
esac |
118 |
|
119 |
exit $RETVAL |