3
# Provides: chef-client
4
# Required-Start: $remote_fs $network
5
# Required-Stop: $remote_fs $network
6
# Default-Start: 2 3 4 5
8
# Short-Description: Start a chef-client.
11
# Copyright (c) 2009-2010 Opscode, Inc, <legal@opscode.com>
13
# chef-client Startup script for chef-client.
15
# description: starts up chef-client in daemon mode.
17
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
18
DAEMON=$(which chef-client)
21
PIDFILE=/var/run/chef/client.pid
23
test -x $DAEMON || exit 1
25
. /lib/lsb/init-functions
27
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
29
if [ ! -d /var/run/chef ]; then
33
DAEMON_OPTS="-d -P $PIDFILE -c $CONFIG -i $INTERVAL -s $SPLAY"
35
if [ ! -z $LOGFILE ]; then
36
DAEMON_OPTS="${DAEMON_OPTS} -L $LOGFILE"
42
[ -z "$pid" ] && return 1
43
[ ! -d /proc/$pid ] && return 1
44
cmd=`awk '/Name:/ {print $2}' /proc/$pid/status`
45
[ "$cmd" != "$name" ] && return 1
50
[ ! -f "$PIDFILE" ] && return 1
52
running_pid $pid ruby || return 1
57
if [ -z "$DAEMONUSER" ] ; then
58
start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
61
start-stop-daemon --start --quiet --pidfile $PIDFILE \
63
--exec $DAEMON -- $DAEMON_OPTS
70
if [ -z "$DAEMONUSER" ] ; then
71
killproc -p $PIDFILE $DAEMON
74
start-stop-daemon --stop --quiet --pidfile $PIDFILE \
83
if [ -z "$DAEMONUSER" ] ; then
84
killproc -p $PIDFILE $DAEMON -HUP
87
start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE \
96
if [ -z "$DAEMONUSER" ] ; then
97
killproc -p $PIDFILE $DAEMON -USR1
100
start-stop-daemon --stop --signal USR1 --quiet --pidfile $PIDFILE \
109
[ ! -e "$PIDFILE" ] && return
117
echo "Cannot kill $NAME (pid=$pid)!"
127
log_daemon_msg "Starting $DESC " "$NAME"
129
log_progress_msg "apparently already running"
133
if start_server ; then
134
[ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time
145
log_daemon_msg "Stopping $DESC" "$NAME"
148
stop_server || errcode=$?
151
log_progress_msg "apparently not running"
159
log_daemon_msg "Stopping (force) $DESC" "$NAME"
161
force_stop || errcode=$?
165
restart|force-reload)
166
log_daemon_msg "Restarting $DESC" "$NAME"
169
stop_server || errcode=$?
170
[ -n "$DIETIME" ] && sleep $DIETIME
172
start_server || errcode=$?
173
[ -n "$STARTTIME" ] && sleep $STARTTIME
174
running || errcode=$?
178
log_daemon_msg "Checking status of $DESC" "$NAME"
180
log_progress_msg "running"
183
log_progress_msg "apparently not running"
190
log_daemon_msg "Reloading $DESC" "$NAME"
192
reload_server || errcode=$?
198
log_daemon_msg "Triggering run of $DESC" "$NAME"
200
run_server || errcode=$?
206
echo "Usage: $N {start|stop|force-stop|restart|force-reload|status|run}" >&2