From cff99160ac80e67d7e26a733dde3231c0d6ec8d8 Mon Sep 17 00:00:00 2001 From: Dmitriy Safronov Date: Wed, 15 Jan 2025 14:15:46 +0400 Subject: [PATCH] root Signed-off-by: Dmitriy Safronov --- Dockerfile | 8 +------- entrypoint.sh | 14 ++++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index b383ec9..b2650f3 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 2e65382..fc41ad4 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" -- GitLab