#!/bin/sh # rsync boot file # write by : r.tang # mailto : bashrc@163.com [ -f /etc/init.d/functions ] && . /etc/init.d/functions # basedir=$(dirname $(which rsync)) basedir=/usr/bin pidfile=/var/run/rsyncd.pid function DoAction() { [ $? -eq 0 ] && action "$doAct" /bin/true || action "$doAct" /bin/false } function start() { doAct="Starting Rsync Daemon " [ -e $pidfile ] || $basedir/rsync --daemon DoAction } function stop() { doAct="Stoping Rsync Daemon" [ -e $pidfile ] && kill -9 $(cat $pidfile) && rm -f $pidfile DoAction } function status() { [ -e $pidfile ] && echo "Rsync is Running [ $(cat $pidfile) ]" || echo "Rsync is Stopped" } case $1 in start) start ;; stop) stop ;; restart) stop && sleep 2 start ;; status) status ;; *) echo "Usage: $0 [start|stop|restart|status]" ;; esac
本文出自 “bashrc的博客” 博客,请务必保留此出处http://bashrc.blog.51cto.com/7339808/1360161
原文:http://bashrc.blog.51cto.com/7339808/1360161