rsyncd启动脚本

时间:2022-06-22 02:15:47
#!/bin/bash
##############################################################
# File Name: -.sh
# Version: V1.
# Author: guojintao
# Organization: https://www.cnblogs.com/guojintao/
# Created Time : -- ::
# Description:
##############################################################
. /etc/init.d/functions
RETVAL=
prog="rsyncd"
rsyncd=/usr/bin/rsync
pid_file=/var/run/rsyncd.pid
lockfile=/var/lock/subsys/$prog
conf_file=/etc/rsyncd.conf if [ -f $conf_file ];then
grep "pid file=$pid_file" $conf_file |grep -v "^#" >/dev/null || {
action "pid file undefined in $conf_file" /bin/false
exit
}
else
action "$conf_file not exist" /bin/false
exit
fi
start(){
echo -n $"Starting $prog: "
rsync --daemon && success || failure
RETVAL=$?
[ $RETVAL -eq ] && touch $lockfile
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $prog: "
killproc -p $pid_file $rsyncd
RETVAL=$?
[ $RETVAL -eq ] && rm -f $lockfile
echo
}
rh_status() {
status -p $pid_file rsyncd
}
rh_status_q() {
rh_status >/dev/null >&
}
case "$1" in
"start")
rh_status_q && exit
start
;;
"stop")
if ! rh_status_q; then
rm -f $lockfile
exit
fi
stop
;;
"status")
rh_status
RETVAL=$?
if [ $RETVAL -eq -a -f $lockfile ] ; then
RETVAL=
fi
;;
"restart")
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
RETVAL=
esac
exit $RETVAL