1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
| #!/bin/sh
. /etc/init.d/functions function usage () { echo $"usage:$0{start|stop|restart}" exit 1 } function start () { rsync --daemon sleep 1 if [ `netstat -lntup|grep rsync|wc -l` -ge 1 ] then action "rsyncd is started." /bin/true else action "rsyncd is started." /bin/false fi } function stop () { pkill rsync &>/dev/null sleep 2 if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ] then action "rsyncd is stopped." /bin/true else action "rsyncd is stopped." /bin/false fi } function main () { if [ $# -ne 1 ] then usage fi if [ "$1" = "start" ] then start elif [ "$1" = "stop" ] then stop elif [ "$1" = "restart" ] then stop sleep 2 start else usage fi } main $*
|