Allow multiple shares

This commit is contained in:
2023-04-23 13:58:25 +02:00
parent 52216f7e33
commit cb50c08680

View File

@@ -1,29 +1,55 @@
#!/bin/bash #!/bin/bash
set -e set -e
USERNAME=${USERNAME:-user}
PASSWORD=${PASSWORD:-pass}
ALLOW=${ALLOW:-10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 127.0.0.1/32}
VOLUME=${VOLUME:-/data}
echo "$USERNAME:$PASSWORD" > /etc/rsyncd.secrets
chmod 0400 /etc/rsyncd.secrets
cat > /etc/rsyncd.conf <<EOF cat > /etc/rsyncd.conf <<EOF
log file = /dev/stdout log file = /dev/stdout
timeout = 300 timeout = 300
max connections = 10 max connections = 10
port = 873 port = 873
[volume] EOF
uid = root
gid = root for i in {0..9} ; do
testvar=RSYNC_VOLUME_$i
if [ "${!testvar}" != "" ] ; then
VOLUME=${!testvar}
echo "Configuring $VOLUME"
testvar=RSYNC_PATH_$i
DIRECTORY=${!testvar:-/data/$VOLUME}
testvar=RSYNC_USERNAME_$i
USERNAME=${!testvar:-user}
testvar=RSYNC_PASSWORD_$i
PASSWORD=${!testvar:-pass}
testvar=RSYNC_ALLOW_$i
ALLOW=${!testvar:-10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 127.0.0.1/32}
testvar=RSYNC_UID_$i
USERID=${!testvar:-root}
testvar=RSYNC_GID_$i
GROUPID=${!testvar:-root}
testvar=RSYNC_READONLY_$i
READONLY=${!testvar:-false}
echo "$USERNAME:$PASSWORD" >> /etc/rsyncd.secrets
cat >> /etc/rsyncd.conf <<EOF
[${VOLUME}]
uid = ${USERID}
gid = ${GROUPID}
hosts deny = * hosts deny = *
hosts allow = ${ALLOW} hosts allow = ${ALLOW}
read only = false read only = ${READONLY}
path = ${VOLUME} path = ${DIRECTORY}
comment = ${VOLUME} directory comment = ${VOLUME} directory
auth users = ${USERNAME} auth users = ${USERNAME}
secrets file = /etc/rsyncd.secrets secrets file = /etc/rsyncd.secrets
EOF EOF
mkdir -p $VOLUME mkdir -p $VOLUME
exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf fi
done
chmod 0400 /etc/rsyncd.secrets
cat /etc/rsyncd.conf
#exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf