首页 > 系统服务 > 详细

利用shell开发rsync服务启动脚本

时间:2018-02-05 10:28:23      阅读:300      评论:0      收藏:0      [点我收藏+]
利用shell函数开发rsync服务启动脚本,之前的不够专业

#!/bin/bash

#chkconfig: 2345  20 80                       #这两行加入kconfig
#description: Saves and restores system entropy  pool
source /etc/init.d/functions    #调用标准的函数库
aa() {
  echo "plz one canshu"
  exit 5
}
bb() {
if [ $1 == "start" ]; then
  rsync --daemon
  if [ "`netstat -tlnup | grep rsync | wc -l`" -gt 0 ]; then
    action "starting rsgnc..." /bin/true     #注意这里
  else
    action "stoped rsync... "  /bin/flase
  exit 6
fi

elif [ $1 == "stop" ]; then
 # kill  "`ps -ef | grep rsync | grep -v grep | awk -F ' ' '{print $2}'`"
  killall rsync
  sleep 2
  if  [ "`netstat -tlnup | grep rsync | wc -l`" -eq 0 ]
    then  action "rsync is stopped" /bin/true
  else
     action "no stop" /bin/flase
  exit 3
  fi
elif [ $1 == "restart" ]; then
  #kill "`ps -ef | grep rsync | grep -v grep | awk -F ' ' '{print $2}'`"
  killall rsync
  sleep 2
  rsync --daemon
  if [ "`netstat -tlnup | grep rsync | wc -l`" -gt 0  ]
    then  action "rsync is starting"  /bin/true
  else
    action "rsync is stopped"  /bin/flase

    exit 2
  fi
else
  echo "plz currt int"
fi
}

main() {
if [ $# -ne 1 ]
  then
    aa
fi
bb $1
}

main $*

技术分享图片

利用shell开发rsync服务启动脚本

原文:http://blog.51cto.com/11726212/2068818

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!