diff --git a/ext/debian/puppet.init b/ext/debian/puppet.init index df36effe7..6009fa75f 100644 --- a/ext/debian/puppet.init +++ b/ext/debian/puppet.init @@ -1,118 +1,117 @@ #! /bin/sh ### BEGIN INIT INFO # Provides: puppet # Required-Start: $network $named $remote_fs $syslog # Required-Stop: $network $named $remote_fs $syslog # Should-Start: puppet # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -### END INIT INFO +### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/puppet DAEMON_OPTS="agent" 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 is_true() { if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then - return 0 + return 0 else return 1 fi } reload_puppet_agent() { - start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE + start-stop-daemon --stop --quiet --signal HUP --pidfile $PIDFILE } start_puppet_agent() { if is_true "$START" ; then - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --startas $DAEMON -- $NAME $DAEMON_OPTS + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --startas $DAEMON -- $NAME $DAEMON_OPTS else - echo "" - echo "puppet not configured to start, please edit /etc/default/puppet to enable" + echo "" + echo "puppet not configured to start, please edit /etc/default/puppet to enable" fi } stop_puppet_agent() { - start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE + start-stop-daemon --stop --retry TERM/10/KILL/5 --quiet --oknodo --pidfile $PIDFILE } status_puppet_agent() { if (type status_of_proc > /dev/null 2>&1) ; then status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" else status_of_proc() { local pidfile daemon name status - + pidfile= OPTIND=1 while getopts p: opt ; do case "$opt" in p) pidfile="$OPTARG";; esac done shift $(($OPTIND - 1)) - + if [ -n "$pidfile" ]; then pidfile="-p $pidfile" fi daemon="$1" name="$2" status="0" pidofproc $pidfile $daemon >/dev/null || status="$?" if [ "$status" = 0 ]; then log_success_msg "$name is running" return 0 elif [ "$status" = 4 ]; then log_failure_msg "could not access PID file for $name" return $status else log_failure_msg "$name is not running" return $status - fi + fi } - status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" + status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}" fi } case "$1" in start) - log_begin_msg "Starting $DESC" - start_puppet_agent - log_end_msg $? - ;; + log_begin_msg "Starting $DESC" + start_puppet_agent + log_end_msg $? + ;; stop) - log_begin_msg "Stopping $DESC" - stop_puppet_agent - log_end_msg $? - ;; + log_begin_msg "Stopping $DESC" + stop_puppet_agent + log_end_msg $? + ;; reload) - log_begin_msg "Reloading $DESC" + log_begin_msg "Reloading $DESC" reload_puppet_agent - log_end_msg $? - ;; + 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 - ;; + log_begin_msg "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 diff --git a/ext/debian/puppetmaster.init b/ext/debian/puppetmaster.init index b86288d1f..4ebcc5a73 100644 --- a/ext/debian/puppetmaster.init +++ b/ext/debian/puppetmaster.init @@ -1,137 +1,136 @@ #! /bin/sh ### BEGIN INIT INFO # Provides: puppetmaster # Required-Start: $network $named $remote_fs $syslog # Required-Stop: $network $named $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/bin/puppet DAEMON_OPTS="" NAME=master DESC="puppet master" test -x $DAEMON || exit 0 [ -r /etc/default/puppetmaster ] && . /etc/default/puppetmaster . /lib/lsb/init-functions if [ ! -d /var/run/puppet ]; then mkdir -p /var/run/puppet fi chown puppet:puppet /var/run/puppet mongrel_warning="The mongrel servertype is no longer built-in to Puppet. It appears as though mongrel is being used, as the number of puppetmasters is greater than one. Starting the puppetmaster service will not behave as expected until this is resolved. Only the first port has been used in the service, and only one puppetmaster has been started. These settings are defined in /etc/default/puppetmaster" # Warn about removed and unsupported mongrel servertype if ([ -n "$PUPPETMASTERS" ] && [ ${PUPPETMASTERS} -gt 1 ]) || [ "${SERVERTYPE}" = "mongrel" ]; then echo $mongrel_warning echo fi is_true() { if [ "x$1" = "xtrue" -o "x$1" = "xyes" -o "x$1" = "x0" ] ; then return 0 else return 1 fi } start_puppet_master() { if is_true "$START" ; then start-stop-daemon --start --quiet --pidfile /var/run/puppet/${NAME}.pid \ --startas $DAEMON -- $NAME $DAEMON_OPTS --masterport=$PORT else echo "" echo "puppetmaster not configured to start, please edit /etc/default/puppetmaster to enable" fi } stop_puppet_master() { - start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/puppet/${NAME}.pid + start-stop-daemon --stop --retry TERM/10/KILL/5 --quiet --oknodo --pidfile /var/run/puppet/${NAME}.pid } status_puppet_master() { if ( ! type status_of_proc > /dev/null 2>&1 ) ; then status_of_proc() { local pidfile daemon name status pidfile= OPTIND=1 while getopts p: opt ; do case "$opt" in p) pidfile="$OPTARG";; esac done shift $(($OPTIND - 1)) if [ -n "$pidfile" ]; then pidfile="-p $pidfile" fi daemon="$1" name="$2" status="0" pidofproc $pidfile $daemon >/dev/null || status="$?" if [ "$status" = 0 ]; then log_success_msg "$name is running" return 0 elif [ "$status" = 4 ]; then log_failure_msg "could not access PID file for $name" return $status else log_failure_msg "$name is not running" return $status fi } fi if is_true "$START" ; then status_of_proc -p "/var/run/puppet/${NAME}.pid" "${DAEMON}" "${NAME}" else echo "" echo "puppetmaster not configured to start" fi } case "$1" in start) log_begin_msg "Starting $DESC" start_puppet_master log_end_msg $? ;; stop) log_begin_msg "Stopping $DESC" stop_puppet_master log_end_msg $? ;; reload) # Do nothing, as Puppetmaster rechecks its config automatically ;; status) status_puppet_master ;; restart|force-reload) log_begin_msg "Restarting $DESC" stop_puppet_master - sleep 1 start_puppet_master log_end_msg $? ;; *) echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2 exit 1 ;; esac # vim: tabstop=4:softtabstop=4:shiftwidth=4:expandtab