Using shell functions to develop the Rsync service startup script, previously unprofessional
#!/bin/bash#chkconfig: 2345 20 80 #这两行加入kconfig #description: saves and restores system entropy poolsource /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 6fielif [ $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 fielif [ $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 fielse echo "Plz currt int" Fi}main () {if [ $# -ne 1 ] then aafibb $1}main $*
Using the shell to develop the Rsync service startup script