#!/bin/sh
#chkconfig: 2345 20 80
#description: create by bai
. /etc/init.d/functions
judge=`netstat -lntup|grep rsync|wc -l`
_start(){
if [ $judge -eq 2 ]
then
action "rsync is running" /bin/true
else
rsync --daemon
sleep 1
action "rsync started" /bin/true
fi
}
_stop(){
if [ `netstat -lntup|grep rsync|wc -l` -ge 0 ]
then
killall rsync >/dev/null 2>&1
sleep 3
if [ `netstat -lntup|grep rsync|wc -l` -eq 0 ]
then
action "rsync is stopped" /bin/true
fi
else
action "rsync is stopped" /bin/true
fi
}
case "$1" in
start)
_start
;;
stop)
_stop
;;
restart)
_stop
sleep 2
_start
;;
*)
echo $"usage:$0 {start|stop|restart}"
;;
esac