puppet本身并没有在redhat中自带启停要命令。为了方便,简单编写了一个客户端启停脚本。现在共享出来。希望对大家有帮助。
1.注意脚本中的server这个变量的赋值。
2.脚本在启动时并未添加listen的选项。因为我是写在配置文件里的。如果有需要,可以在启动时添加上。
cat > /etc/init.d/ppms <#!/bin/bash
#PupPet Manage Script
#Made by leary
#
# Init file for puppet
#
# chkconfig: 2345 55 25
# description: puppet client daemon
#
# processname: puppetd
# config: /etc/puppet.conf
# pidfile: /var/lib/puppet/run/puppetd.pid
# Source function library.
. /etc/rc.d/init.d/functions
RETVAL=0
kpro=”puppetd”
server=”sf-120″
if [ $# -ne 1 ]; then
echo ” Service of $0 Useage:{start|stop|restart}”
exit 1
fi
if [ $EUID != 0 ]; then
echo “You must be root to run this script !”
exit
fi
start(){
single=`ps aux |grep -v grep |grep $kpro|awk ‘{print $2}’|wc -l`
case $single in
0 )
/usr/sbin/puppetd –server $server –listen –report
echo “$kpro is started [ OK ]”
;;
* )
echo “$kpro is already running !”
exit 1
esac
}
stop(){
single=`ps aux |grep -v grep |grep $kpro|awk ‘{print $2}’|wc -l`
case $single in
1 )
pro=`ps aux |grep -v grep |grep $kpro|awk ‘{print $2}’`
kill -9 $pro
echo “$kpro $pro is killed !”
;;
0 )
echo “There is no running $kpro !”
;;
* )
echo “Multi-process of $kpro is running,Please kill it manually !”
esac
}
case $1 in
start )
start
;;
stop )
stop
;;
restart )
stop
start
;;
* )
echo ” Service of $0 Useage:{start|stop|restart}”
esac
You have new mail in /var/spool/mail/root
chmod 755 /etc/init.d/ppms
chkconfig –add ppms
chkconfig ppms on
阅读(1271) | 评论(0) | 转发(0) |