永不落伍 发表于 2018-8-22 09:41:45

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

#!/bin/bash  

  
#chkconfig: 234520 80                     #这两行加入kconfig
  
#description: Saves and restores system entropypool
  
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 ]
  
    thenaction "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]
  
    thenaction "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 $*


页: [1]
查看完整版本: 利用shell开发rsync服务启动脚本