#!/bin/bash # puppetmaster This shell script enables the puppetmaster server. # # Authors: Duane Griffin # Peter Meier (Mongrel enhancements) # # chkconfig: - 65 45 # # description: Server for the puppet system management tool. # processname: puppetmaster PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH lockfile=/var/lock/subsys/puppetmaster # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/puppetmaster ]; then . /etc/sysconfig/puppetmaster fi PUPPETMASTER_OPTS="" [ -n "$PUPPETMASTER_MANIFEST" ] && PUPPETMASTER_OPTS="--manifest=${PUPPETMASTER_MANIFEST}" if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then PUPPETMASTER_OPTS="$PUPPETMASTER_OPTS --servertype=mongrel" elif [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -eq 1 ]; then PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --masterport=${PUPPETMASTER_PORTS[0]}" fi [ -n "$PUPPETMASTER_LOG" ] && PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} --logdest=${PUPPETMASTER_LOG}" PUPPETMASTER_OPTS="${PUPPETMASTER_OPTS} \ ${PUPPETMASTER_EXTRA_OPTS}" RETVAL=0 prog=puppetmasterd PUPPETMASTER=/usr/sbin/$prog start() { echo -n $"Starting puppetmaster: " # Confirm the manifest exists if [ -r $PUPPETMASTER_MANIFEST ]; then if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}" daemon $PUPPETMASTER $PUPPETMASTER_OPTS --masterport=${PUPPETMASTER_PORTS[$i]} --pidfile=/var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid ret=$?; [ $ret != 0 ] && RETVAL=$ret done else daemon $PUPPETMASTER $PUPPETMASTER_OPTS RETVAL=$? fi else failure $"Manifest does not exist: $PUPPETMASTER_MANIFEST" echo return 1 fi [ $RETVAL -eq 0 ] && touch "$lockfile" echo return $RETVAL } stop() { echo -n $"Stopping puppetmaster: " if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}" killproc -p /var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid puppetmaster ret=$?; [ $ret != 0 ] && RETVAL=$ret done else killproc $PUPPETMASTER RETVAL=$? fi echo [ $RETVAL -eq 0 ] && rm -f "$lockfile" return $RETVAL } restart() { stop start } genconfig() { echo -n $"Generate configuration puppetmaster: " $PUPPETMASTER $PUPPETMASTER_OPTS --genconfig } puppetmaster_status() { if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do echo -en "Port ${PUPPETMASTER_PORTS[$i]}: " status -p /var/run/puppet/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid puppetmaster ret=$?; [ $ret != 0 ] && RETVAL=$ret done else status $PUPPETMASTER RETVAL=$? fi return $RETVAL } case "$1" in start) start ;; stop) stop ;; restart|reload|force-reload) restart ;; condrestart) [ -f "$lockfile" ] && restart ;; status) puppetmaster_status ;; genconfig) genconfig ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|genconfig}" exit 1 esac exit $RETVAL