Skip to content

Commit

Permalink
Merge pull request #15 from gamegine/env-config
Browse files Browse the repository at this point in the history
 rsyncd.conf server config from env
  • Loading branch information
srstsavage authored Feb 20, 2024
2 parents d7b45e6 + a33457c commit cadbc54
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ total size is 0 speedup is 0.00

Variable options (on run)

* `USERNAME` - the `rsync` username. defaults to `user`
* `PASSWORD` - the `rsync` password. defaults to `pass`
* `VOLUME` - the path for `rsync`. defaults to `/data`
* `ALLOW` - space separated list of allowed sources. defaults to `10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 127.0.0.1/32`.
| Parameter | Function |
| :---------------: | -------- |
| `USERNAME` | the `rsync` username. defaults to `user`|
| `PASSWORD` | the `rsync` password. defaults to `pass`|
| `AUTHORIZED_KEYS` | the `ssh` key (for root user). defaults empty |
| `VOLUME` | the path for `rsync`. defaults to `/data`|
| `PUID` | UserID used to transfer files when running the rsync . defaults to `root`|
| `GUID` | GroupID used to transfer files when running the rsync . defaults to `root`|
| `DENY` | space separated list of allowed sources. defaults to `*`|
| `ALLOW` | space separated list of allowed sources. defaults to `10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 127.0.0.1/32`.|
| `RO` | `rsync` volume read only. defaults to `false`|
| `CUSTOMCONFIG` | rsyncd.conf custom config for subsection volume (`\n\t` for new line ex: `uid = root\n\tgid = root`). defaults empty |

### Simple server on port 873

Expand Down
24 changes: 18 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/bin/bash
set -e

# AUTHORIZED_KEYS
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}
PUID=${PUID:-root}
GUID=${GUID:-root}
DENY=${DENY:-"*"}
ALLOW=${ALLOW:-10.0.0.0/8 192.168.0.0/16 172.16.0.0/12 127.0.0.1/32}
RO=${RO:-false}
# CUSTOMCONFIG


setup_sshd(){
Expand All @@ -14,6 +19,9 @@ setup_sshd(){
else
mkdir -p /root/.ssh
chown root:root /root/.ssh
if [ ! -z "$AUTHORIZED_KEYS" ]; then
echo "$AUTHORIZED_KEYS" > /root/.ssh/authorized_keys
fi
fi
chmod 750 /root/.ssh
echo "root:$PASSWORD" | chpasswd
Expand All @@ -29,16 +37,20 @@ max connections = 10
port = 873
[volume]
uid = root
gid = root
hosts deny = *
uid = ${PUID}
gid = ${GUID}
hosts deny = ${DENY}
hosts allow = ${ALLOW}
read only = false
read only = ${RO}
path = ${VOLUME}
comment = ${VOLUME} directory
auth users = ${USERNAME}
secrets file = /etc/rsyncd.secrets
EOF

if [ ! -z "$CUSTOMCONFIG" ]; then
echo -e "\t${CUSTOMCONFIG}" >> /etc/rsyncd.conf
fi
}


Expand Down

0 comments on commit cadbc54

Please sign in to comment.