rsync 启动脚本

#!/bin/bash

#  This shell script takes care of starting and stopping standalone rsync.

# chkconfig: - 99 50

# config: /etc/rsyncd.conf


# Source function library

. /etc/rc.d/init.d/functions

 

RETVAL=0

prog="rsync"


PPATH="/usr/bin/"


# Your rsync config file path

CFILE="/etc/rsync.conf"


OPTIONS="--daemon -4 --config $CFILE"


start() {

        # Start daemons.

        [ -x $PPATH$prog ] || { echo "No such programme"; exit 4; }

        [ -f $CFILE ] || { echo " config file does not exist"; exit 6; }

        echo -n $"Starting $prog: "

        daemon $PPATH$prog $OPTIONS

        RETVAL=$?

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog

        echo

        return $RETVAL

}


stop() {

        # Stop daemons.

        echo -n $"Shutting down $prog: "

        killproc $prog

        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


你可能感兴趣的:(rsync 启动脚本)