Skip to content

Instantly share code, notes, and snippets.

@griggheo
Created July 21, 2010 17:12
Show Gist options
  • Save griggheo/484780 to your computer and use it in GitHub Desktop.
Save griggheo/484780 to your computer and use it in GitHub Desktop.
#! /bin/sh
### BEGIN INIT INFO
# Provides: chef-client
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start a chef-client.
### END INIT INFO
#
# Copyright (c) 2009-2010 Opscode, Inc, <[email protected]>
#
# chef-client Startup script for chef-client.
# chkconfig: - 99 02
# description: starts up chef-client in daemon mode.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/chef-client
NAME=chef-client
DESC=chef-client
PIDFILE=/var/run/chef/client.pid
LOGFILE=/var/log/chef.log
CONFIG=/etc/chef/client.rb
JSON=/etc/chef/chef.json
INTERVAL=600
SPLAY=30
test -x $DAEMON || exit 0
. /lib/lsb/init-functions
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
if [ ! -d /var/run/chef ]; then
mkdir /var/run/chef
fi
DAEMON_OPTS="-L $LOGFILE -d -j $JSON -c $CONFIG -i $INTERVAL -s $SPLAY"
start() {
start_daemon -p $PIDFILE $DAEMON $DAEMON_OPTS
errcode=$?
return $errcode
}
stop() {
pkill -f chef-client
rm -f $PIDFILE
errcode=$?
return $errcode
}
case "$1" in
start)
log_daemon_msg "Starting $DESC " "$NAME"
start
;;
stop)
log_daemon_msg "Stopping $DESC" "$NAME"
stop
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment