@echo off

REM Configure rsync server
REM Arguments:
REM 1) Source servers allowed to connect to this rsync server
REM Comma-separated list of IP addresses, for example:
REM 192.168.1.15,192.168.4.12
REM 2) Directory with virtual hosts. Example:
REM /cygdrive/c/inetpub/vhosts
REM This directory will be available as 'vhosts'
REM 3) Migrator directory - directory for temporary files
REM used by migrator. Example:
REM /cygdrive/c/migrator
REM This directory will be available as 'migrator'
REM 4) User allowed to connect to the rsync server. Example:
REM admin
REM 5) Password of a user allowed to connect to the rsync server. Example:
REM 123qwe

cd %~dp0

REM Write rsyncd.conf
echo use chroot = false> rsyncd.conf
echo strict modes = false>> rsyncd.conf
echo hosts allow = %1>> rsyncd.conf
echo log file = rsyncd.log>> rsyncd.conf
echo secrets file = rsyncd.secrets>> rsyncd.conf
echo( >> rsyncd.conf
echo [vhosts]>> rsyncd.conf
echo path = %2>> rsyncd.conf
echo read only = true>> rsyncd.conf
echo transfer logging = yes>> rsyncd.conf
echo auth users = %4>> rsyncd.conf
echo( >> rsyncd.conf
echo [migrator]>> rsyncd.conf
echo path = %3>> rsyncd.conf
echo read only = false >> rsyncd.conf
echo transfer logging = yes>>rsyncd.conf
echo auth users = %4>> rsyncd.conf

REM Write rsyncd.secrets
echo %4:%5> rsyncd.secrets
