#!/bin/bash # chkconfig: 345 96 55 # description: rsyncd service # INIT SCRIPT FOR RSYNCD RSYNC_CMD="/usr/bin/rsync" CONFIG_FILE="/etc/rsyncd/rsyncd.conf" PID_FILE="/var/run/rsyncd.pid" PROG_NAME="rsyncd" function start() { $RSYNC_CMD --daemon --config "$CONFIG_FILE" sleep 3 echo -e "Rsyncd start\t\t\t[ OK ]" } function stop() { kill -9 $(cat "$PID_FILE") rm -f "$PID_FILE" sleep 2 echo -e "Rsyncd stop\t\t\t[ OK ]" } function restart() { stop sleep 1 start } function status() { if [ -f "$PID_FILE" ] then echo "$PROG_NAME is started ($(cat $PID_FILE))" else echo "$PROG_NAME is stopped" fi } function usage() { echo -e "$PROG_NAME usage:\n\t\t$0 {start|stop|restart}" } case $1 in start) start ;; stop) stop ;; restart) stop start ;; status) status ;; *) usage ;; esac