-
-
Save Duske/d1ad66f3d77ac829a2625208b1814484 to your computer and use it in GitHub Desktop.
run script for alpine linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine | |
RUN apk --update add rsync | |
EXPOSE 873 | |
COPY ./run /usr/local/bin/run | |
ENTRYPOINT ["/usr/local/bin/run"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
VOLUME=${VOLUME:-/docker} | |
ALLOW=${ALLOW:-192.168.0.0/16 172.16.0.0/12} | |
OWNER=${OWNER:--nobody} | |
GROUP=${GROUP:--nogroup} | |
OWNERID=${OWNERID:-1000} | |
GROUPID=${GROUPID:-1000} | |
id -u $GROUP &>/dev/null || (addgroup -g $GROUPID $GROUP && echo "created group $GROUP with id $GROUPID") | |
# option -N does not seem to be available, | |
# option -D sets no pw for user | |
id -u $OWNER &>/dev/null || (adduser -D -G $GROUP -u $OWNERID $OWNER -h $VOLUME && echo "created user $OWNER with id $OWNERID") | |
mkdir -p $VOLUME | |
chown "${OWNER}:${GROUP}" "${VOLUME}" | |
# updated condition if rsyncd.conf exist | |
if [ -f /etc/rsyncd.conf ]; | |
then | |
cat <<EOF >> /etc/rsyncd.conf | |
uid = ${OWNER} | |
gid = ${GROUP} | |
use chroot = yes | |
log file = /dev/stdout | |
reverse lookup = no | |
[volume] | |
hosts deny = * | |
hosts allow = ${ALLOW} | |
read only = false | |
path = ${VOLUME} | |
comment = docker volume | |
EOF | |
exec /usr/bin/rsync --no-detach --daemon --config="/etc/rsyncd.conf" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment