diff --git a/Dockerfile b/Dockerfile index b383ec905b75a1e6090b43bbe24cbe9c6e7f9d0a..b2650f3df63047cc8f42b26b71443412ae499534 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,16 +13,10 @@ ENTRYPOINT [ "/entrypoint.sh" ] RUN set -x && \ apk --no-cache add sudo rsync && \ - rm -rf /var/cache/apk/* && \ - addgroup -S openwrt && \ - adduser -S openwrt -G openwrt -h /home/openwrt && \ - mkdir /srv/openwrt && \ - chown -R openwrt:openwrt /tmp/openwrt /srv/openwrt + rm -rf /var/cache/apk/* COPY entrypoint.sh /entrypoint.sh RUN chmod a+x /entrypoint.sh -USER openwrt:openwrt - FROM runtime AS release diff --git a/entrypoint.sh b/entrypoint.sh index 2e65382b76cd28e683455b2e483e032443f5f0e4..fc41ad4e7f15b4f8022008e57548397c47f7f3d3 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,13 +5,15 @@ die() { exit 1 } -test -n "$OPENWRT_SSH_CONFIG" && echo "$OPENWRT_SSH_CONFIG" > /srv/openwrt/config -test -n "$OPENWRT_SSH_KEY_ED25519" && echo "$OPENWRT_SSH_KEY_ED25519" > /srv/openwrt/id_ed25519 -test -n "$OPENWRT_SSH_KNOWN_HOSTS" && echo "$OPENWRT_SSH_KNOWN_HOSTS" > /srv/openwrt/known_hosts +mkdir /root/openwrt -rsync -a -og --chown=openwrt:openwrt /srv/openwrt/ /home/openwrt/.ssh/ || die "Couldn't rsync user ssh settings" -chown -R openwrt:openwrt /home/openwrt/.ssh || die "Couldn't change ownership for user ssh settings" -chmod -R a-rwx,u+rwX /home/openwrt/.ssh || die "Couldn't change access rights for user ssh settings" +test -n "$OPENWRT_SSH_CONFIG" && echo "$OPENWRT_SSH_CONFIG" > /root/openwrt/config +test -n "$OPENWRT_SSH_KEY_ED25519" && echo "$OPENWRT_SSH_KEY_ED25519" > /root/openwrt/id_ed25519 +test -n "$OPENWRT_SSH_KNOWN_HOSTS" && echo "$OPENWRT_SSH_KNOWN_HOSTS" > /root/openwrt/known_hosts + +rsync -a -og --chown=root:root /root/openwrt/ /root/.ssh/ || die "Couldn't rsync user ssh settings" +chown -R root:root /root/.ssh || die "Couldn't change ownership for user ssh settings" +chmod -R a-rwx,u+rwX /root/.ssh || die "Couldn't change access rights for user ssh settings" rsync -acxv --delete-after --exclude '*-opkg' -e "ssh -p ${OPENWRT_SSH_PORT:-22}" "${OPENWRT_SSH_HOST:-root@192.168.1.1}:/overlay/upper/" overlay/ || die "Couldn't rsync router config"