rsync启动脚本

说明:
rsync自启动脚本,非常好用,虽然还看不太懂!!!比如killproc,系统命令就没有
 

#!/bin/bash
#
# rsyncd      This shell script takes care of starting and stopping
#             standalone rsync.
#
# chkconfig: - 99 50
# description: rsync is a file transport daemon
# processname: rsync
# config: /etc/rsyncd.conf

# Source function library
. /etc/rc.d/init.d/functions

RETVAL=0
rsync="/usr/bin/rsync"
prog="rsync"
CFILE="/etc/rsyncd.conf"

start() {
        # Start daemons.
        [ -x $rsync ] || \
            { echo "FATAL: No such programme";exit 4; }
        [ -f $CFILE ] || \
            { echo "FATAL: config file does not exist";exit 6; }
        echo -n $"Starting $prog: "
        daemon $rsync --daemon --config=$CFILE
        RETVAL=$?
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
        echo
        return $RETVAL
}

stop() {
        # Stop daemons.
        echo -n $"Stopping $prog: "
        killproc $prog -QUIT
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
        return $RETVAL
}

# call the function we defined
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|status}"
        exit 2
esac

exit $RETVAL

发表评论

邮箱地址不会被公开。 必填项已用*标注