mirror of
https://github.com/napnap75/multiarch-docker-images.git
synced 2025-12-15 19:24:19 +01:00
Allow multiple shares
This commit is contained in:
@@ -1,29 +1,55 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
log file = /dev/stdout
|
||||
timeout = 300
|
||||
max connections = 10
|
||||
port = 873
|
||||
[volume]
|
||||
uid = root
|
||||
gid = root
|
||||
EOF
|
||||
|
||||
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 allow = ${ALLOW}
|
||||
read only = false
|
||||
path = ${VOLUME}
|
||||
read only = ${READONLY}
|
||||
path = ${DIRECTORY}
|
||||
comment = ${VOLUME} directory
|
||||
auth users = ${USERNAME}
|
||||
secrets file = /etc/rsyncd.secrets
|
||||
EOF
|
||||
|
||||
mkdir -p $VOLUME
|
||||
exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf
|
||||
mkdir -p $VOLUME
|
||||
fi
|
||||
done
|
||||
|
||||
chmod 0400 /etc/rsyncd.secrets
|
||||
|
||||
cat /etc/rsyncd.conf
|
||||
|
||||
#exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf
|
||||
|
||||
Reference in New Issue
Block a user