2 # This must be called as (note the trailing dot):
4 # stunnel-rsync HOSTNAME rsync --server --daemon .
6 # ... which is typically done via the rsync-ssl script, which results in something like this:
8 # rsync --rsh=stunnel-rsync -aiv HOSTNAME::module [ARGS]
10 # This SSL setup based on the files by: http://dozzie.jarowit.net/trac/wiki/RsyncSSL
11 # Note that this requires at least version 4.x of stunnel.
13 # The current environment can override using the RSYNC_SSL_* values:
14 if [ x"$RSYNC_SSL_CERT" = x ]; then
17 cert="cert = $RSYNC_SSL_CERT"
19 if [ x"$RSYNC_SSL_CA_CERT" ]; then
23 cafile="CAfile = $RSYNC_SSL_CA_CERT"
26 port=${RSYNC_SSL_PORT:-874}
28 # If the user specified USER@HOSTNAME::module, then rsync passes us
29 # the -l USER option too, so we must be prepared to ignore it.
30 if [ x"$1" = x"-l" ]; then
37 if [ x"$hostname" = x -o x"$1" != x"rsync" -o x"$2" != x"--server" -o x"$3" != x"--daemon" ]; then
38 echo "Usage: stunnel-rsync HOSTNAME rsync --server --daemon ." 1>&2
42 # devzero@web.de came up with this no-tmpfile calling syntax:
43 @stunnel4@ -fd 10 11<&0 <<EOF 10<&0 0<&11 11<&-
46 connect = $hostname:$port