4
# /etc/init.d/rsync: start and stop the rsync daemon
9
RSYNC_DEFAULTS_FILE=/etc/default/rsync
10
RSYNC_CONFIG_FILE=/etc/rsyncd.conf
12
test -x $DAEMON || exit 0
14
if [ -s $RSYNC_DEFAULTS_FILE ]; then
15
. $RSYNC_DEFAULTS_FILE
16
case "x$RSYNC_ENABLE" in
20
*) echo "Value of RSYNC_ENABLE in $RSYNC_DEFAULTS_FILE must be either 'true' or 'false';"
21
echo "not starting rsync daemon."
27
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
31
if "$RSYNC_ENABLE"; then
32
echo -n "Starting rsync daemon: rsync"
33
if [ -s /var/run/rsync.pid ] && kill -0 $(cat /var/run/rsync.pid) >/dev/null 2>&1; then
34
echo " apparently already running."
37
if [ ! -s "$RSYNC_CONFIG_FILE" ]; then
38
echo " missing or empty config file $RSYNC_CONFIG_FILE"
41
start-stop-daemon --start --quiet --background \
42
--pidfile /var/run/rsync.pid --make-pidfile \
43
--exec /usr/bin/rsync \
44
-- --no-detach --daemon --config "$RSYNC_CONFIG_FILE" $RSYNC_OPTS
47
if [ -s "$RSYNC_CONFIG_FILE" ]; then
48
echo "rsync daemon not enabled in /etc/default/rsync"
53
echo -n "Stopping rsync daemon: rsync"
54
start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/rsync.pid
55
rm -f /var/run/rsync.pid
60
echo "Reloading rsync daemon: not needed, as the daemon"
61
echo "re-reads the config file whenever a client connects."
66
if $RSYNC_ENABLE; then
67
echo -n "Restarting rsync daemon: rsync"
68
if [ -s /var/run/rsync.pid ] && kill -0 $(cat /var/run/rsync.pid) >/dev/null 2>&1; then
69
start-stop-daemon --stop --quiet --oknodo --pidfile /var/run/rsync.pid || true
72
rm -f /var/run/rsync.pid
74
if ! start-stop-daemon --start --quiet --background \
75
--pidfile /var/run/rsync.pid --make-pidfile \
76
--exec /usr/bin/rsync \
77
-- --no-detach --daemon --config "$RSYNC_CONFIG_FILE" $RSYNC_OPTS
80
rm -f /var/run/rsync.pid
84
echo "rsync daemon not enabled in /etc/default/rsync"
89
echo "Usage: /etc/init.d/rsync {start|stop|reload|force-reload|restart}"