~hexperides/hexperides/main

« back to all changes in this revision

Viewing changes to etc/init.d/rsync

  • Committer: RicardoCardenes
  • Date: 2005-06-10 15:49:54 UTC
  • Revision ID: RicardoCardenes-8124e411ce351a4aa8b751fa1054a3c0e680bad5
movemos el contenido actual dentro de "trunk"

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh
 
2
set -e
 
3
 
 
4
# /etc/init.d/rsync: start and stop the rsync daemon
 
5
 
 
6
DAEMON=/usr/bin/rsync
 
7
RSYNC_ENABLE=false
 
8
RSYNC_OPTS=''
 
9
RSYNC_DEFAULTS_FILE=/etc/default/rsync
 
10
RSYNC_CONFIG_FILE=/etc/rsyncd.conf
 
11
 
 
12
test -x $DAEMON || exit 0
 
13
 
 
14
if [ -s $RSYNC_DEFAULTS_FILE ]; then
 
15
    . $RSYNC_DEFAULTS_FILE
 
16
    case "x$RSYNC_ENABLE" in
 
17
        xtrue|xfalse)   ;;
 
18
        xinetd)         exit 0
 
19
                        ;;
 
20
        *)              echo "Value of RSYNC_ENABLE in $RSYNC_DEFAULTS_FILE must be either 'true' or 'false';"
 
21
                        echo "not starting rsync daemon."
 
22
                        exit 1
 
23
                        ;;
 
24
    esac
 
25
fi
 
26
 
 
27
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
 
28
 
 
29
case "$1" in
 
30
  start)
 
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."
 
35
                exit 0
 
36
            fi
 
37
            if [ ! -s "$RSYNC_CONFIG_FILE" ]; then
 
38
                echo " missing or empty config file $RSYNC_CONFIG_FILE"
 
39
                exit 1
 
40
            fi
 
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
 
45
            echo "."
 
46
        else
 
47
            if [ -s "$RSYNC_CONFIG_FILE" ]; then
 
48
                echo "rsync daemon not enabled in /etc/default/rsync"
 
49
            fi
 
50
        fi
 
51
        ;;
 
52
  stop)
 
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
 
56
        echo "."
 
57
        ;;
 
58
 
 
59
  reload|force-reload)
 
60
        echo "Reloading rsync daemon: not needed, as the daemon"
 
61
        echo "re-reads the config file whenever a client connects."
 
62
        ;;
 
63
 
 
64
  restart)
 
65
        set +e
 
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
 
70
                sleep 1
 
71
            else
 
72
                rm -f /var/run/rsync.pid
 
73
            fi
 
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
 
78
            then
 
79
                echo "start failed?"
 
80
                rm -f /var/run/rsync.pid
 
81
            fi
 
82
            echo "."
 
83
        else
 
84
            echo "rsync daemon not enabled in /etc/default/rsync"
 
85
        fi
 
86
        ;;
 
87
 
 
88
  *)
 
89
        echo "Usage: /etc/init.d/rsync {start|stop|reload|force-reload|restart}"
 
90
        exit 1
 
91
esac
 
92
 
 
93
exit 0