文件路徑/etc/init.d/my_rsync.sh
腳本作用:管理應(yīng)用的啟停
#!/bin/bash
# 結(jié)果的美化日志
###############
lsb_functions="/lib/lsb/init-functions"
if test -f $lsb_functions ; then
. $lsb_functions
else
# Include non-LSB RedHat init functions to make systemctl redirect work
init_functions="/etc/init.d/functions"
if test -f $init_functions ; then
. $init_functions
fi
log_success_msg()
{ echo " SUCCESS! $@"
}
log_failure_msg()
{ echo " ERROR! $@"
}
fi
####################
# 開發(fā)rsync腳本
function usage(){echo "Usage: $0 {start|stop|restart}"
exit 1
}
# 開發(fā)start功能
function start(){/usr/bin/rsync --daemon
sleep 1
if [ `netstat -tunlp|grep rsync|wc -l` -ge "1" ]
then
log_success_msg "rsyncd is started!"
else
log_failure_msg "rsync isn't started!"
fi
}
function stop(){killall rsync &>/dev/null
sleep
if [ `netstat -tunlp|grep rsync|wc -l` -eq 0 ]
then
log_success_msg "rsyncd is stopped!"
else
log_failure_msg "rsyncd isn't stopped!"
fi
}
function restart(){echo ""
}
# 開發(fā)c語言風(fēng)格的腳本,更專業(yè),更美觀,更容易維護
function main(){if [ "$#" -ne 1 ]
then
usage
fi
if [ "$1" = "start" ]
then
start
elif [ "$1" = "stop" ]
then
stop
elif [ "$1" = "restart" ]
then
stop
sleep 1
start
else
usage
fi
}
# 調(diào)用程序入口函數(shù)
main $*
運行示例
你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機房具備T級流量清洗系統(tǒng)配攻擊溯源,準確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧