#!/sbin/runscript # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 depend() { need localmount net use dns logger slapd netmount nfsmount } checkconfig() { if [ ! -d "${PUPPETMASTER_PID_DIR}" ] ; then eerror "Please make sure PUPPETMASTER_PID_DIR is defined and points to a existing directory" return 1 fi return 0 } start() { checkconfig || return $? local options="" if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then options="${options} --servertype=mongrel" elif [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -eq 1 ]; then options="${options} --masterport=${PUPPETMASTER_PORTS[0]}" fi [ -n "${PUPPETMASTER_EXTRA_OPTS}" ] && options="${options} ${PUPPETMASTER_EXTRA_OPTS}" ebegin "Starting puppetmaster" RETVAL=0 if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}" pidfile="${PUPPETMASTER_PID_DIR}/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid" start-stop-daemon --start --quiet \ --pidfile ${pidfile} \ --exec /usr/bin/puppetmasterd -- ${options} \ --masterport=${PUPPETMASTER_PORTS[$i]} \ --pidfile=${pidfile} ret=$?; [ $ret != 0 ] && RETVAL=$ret done else start-stop-daemon --start --quiet \ --pidfile "${PUPPETMASTER_PID_DIR}/puppetmasterd.pid" \ --exec /usr/bin/puppetmasterd -- ${options} RETVAL=$? fi eend ${RETVAL} "Failed to start puppetmaster" } stop() { ebegin "Stopping puppetmaster" RETVAL=0 if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do echo -en "\nPort: ${PUPPETMASTER_PORTS[$i]}" pidfile="${PUPPETMASTER_PID_DIR}/puppetmaster.${PUPPETMASTER_PORTS[$i]}.pid" start-stop-daemon --stop --quiet \ --pidfile ${pidfile} ret=$?; [ $ret != 0 ] && RETVAL=$ret done else start-stop-daemon --stop --quiet \ --pidfile "${PUPPETMASTER_PID_DIR}/puppetmasterd.pid" RETVAL=$? fi eend ${RETVAL} "Failed to stop puppetmaster" rm -f "${PUPPETMASTER_PID_DIR}/puppetmasterd.pid" return ${RETVAL} } status() { if [ -n "$PUPPETMASTER_PORTS" ] && [ ${#PUPPETMASTER_PORTS[@]} -gt 1 ]; then for ((i=0; i<${#PUPPETMASTER_PORTS[@]}; i++)); do # TODO ret=$?; [ $ret != 0 ] && RETVAL=$ret done fi }