#! /bin/bash # # ambari-agent Bring up/down ambari-agent # # chkconfig: 345 20 80 # description: Starts and stops the agent # # /etc/rc.d/init.d/ambari-agent # See how we were called. #/* # * Licensed to the Apache Software Foundation (ASF) under one # * or more contributor license agreements. See the NOTICE file # * distributed with this work for additional information # * regarding copyright ownership. The ASF licenses this file # * to you under the Apache License, Version 2.0 (the # * "License"); you may not use this file except in compliance # * with the License. You may obtain a copy of the License at # * # * http://www.apache.org/licenses/LICENSE-2.0 # * # * Unless required by applicable law or agreed to in writing, software # * distributed under the License is distributed on an "AS IS" BASIS, # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # * See the License for the specific language governing permissions and # * limitations under the License. # */ # # RPM Init file for puppet agent # PATH=/usr/bin:/sbin:/bin:/usr/sbin export PATH [ -f /etc/sysconfig/puppet ] && . /etc/sysconfig/puppet lockfile=${LOCKFILE-/var/lock/subsys/puppet} pidfile=${PIDFILE-/var/run/puppet/agent.pid} puppetd=${PUPPETD-/usr/bin/puppet} RETVAL=0 # Source function library. . /etc/rc.d/init.d/functions # Determine if we can use the -p option to daemon, killproc, and status. # RHEL < 5 can't. if status | grep -q -- '-p' 2>/dev/null; then daemonopts="--pidfile $pidfile" pidopts="-p $pidfile" fi hmc_server=`cat /etc/hmc/ambari-agent.conf` PUPPET_OPTS="agent --verbose --confdir=/etc/puppet/agent --listen --runinterval 5 --server $hmc_server --report --no-client --waitforcert 10 --configtimeout 600 --debug --logdest=/var/log/puppet_agent.log --httplog /var/log/puppet_agent_http.log --autoflush --use_cached_catalog" start() { echo -n $"Starting puppet: " daemon $daemonopts $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL } stop() { echo -n $"Stopping puppet: " killproc $puppetd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile} return $RETVAL } reload() { echo -n $"Restarting puppet: " killproc $puppetd -HUP RETVAL=$? echo return $RETVAL } restart() { stop start } rh_status() { status $puppetd RETVAL=$? return $RETVAL } rh_status_q() { rh_status >/dev/null 2>&1 } genconfig() { echo -n $"Generate configuration puppet: " $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} --genconfig } case "$1" in start) start ;; stop) stop ;; restart) restart ;; reload|force-reload) reload ;; condrestart|try-restart) rh_status_q || exit 0 restart ;; status) rh_status ;; once) shift $puppetd -o ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} $@ ;; genconfig) genconfig ;; *) echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once|genconfig}" exit 1 esac exit $RETVAL