shell企业级实用基础脚本(汇总2/2)
#!/bin/bash[ -f /etc/init.d/functions ]&& . /etc/init.d/functions||exit 2
Start(){
if [ `lsof -i:873|wc -l` -gt 0 ];then
echo "rsync is running..."
else
rsync --daemon
[ `lsof -i:873|wc -l` -gt 0 ]&&action "rsync start..." /bin/true
fi
return $RETVAL
}
Stop(){
if [ `lsof -i:873|wc -l` -eq 0 ];then
echo "rsync is not running..."
else
killall rsync
sleep 3
[ `lsof -i:873|wc -l` -eq 0 ]&&action "rsync stop..." /bin/true
fi
return $RETVAL
}
main(){
case "$1" in
start|sTART)
Start
;;
stop|STOP)
Stop
;;
restart|RESTART)
Stop
sleep 2
Start
;;
*)
echo -e "USAGE:$0 {start|stop|restart}"
exit 1
esac
}
main $1
exit $RETVAL
页:
[1]