From e7ffd7fb7fa336417f8946f7ef34a482da410e2e Mon Sep 17 00:00:00 2001 From: Ryan Kuba Date: Fri, 29 Mar 2019 00:18:44 +0800 Subject: [PATCH] Extract Picons on boot Release-4.2 (#128) * reworking logic to untar on first boot and reducing sample size for chown logic as it is not recursive * bad path in arm variants --- Dockerfile | 10 ++-------- Dockerfile.aarch64 | 10 ++-------- Dockerfile.armhf | 10 ++-------- root/etc/cont-init.d/30-config | 11 ++++++++--- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/Dockerfile b/Dockerfile index a3ed0a1..d252cbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -311,14 +311,8 @@ RUN \ echo "**** Add Picons ****" && \ mkdir -p /picons && \ curl -o \ - /tmp/picons.tar.bz2 -L \ - https://lsio-ci.ams3.digitaloceanspaces.com/picons/picons.tar.bz2 && \ - tar xf \ - /tmp/picons.tar.bz2 -C \ - /picons && \ - echo "**** cleanup ****" && \ - rm -rf \ - /tmp/* + /picons.tar.bz2 -L \ + https://lsio-ci.ams3.digitaloceanspaces.com/picons/picons.tar.bz2 # copy local files and buildstage artifacts COPY --from=buildstage /tmp/argtable-build/usr/ /usr/ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 61e78b2..7ba6207 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -311,14 +311,8 @@ RUN \ echo "**** Add Picons ****" && \ mkdir -p /picons && \ curl -o \ - /tmp/picons.tar.bz2 -L \ - https://lsio-ci.ams3.digitaloceanspaces.com/picons/picons.tar.bz2 && \ - tar xf \ - /tmp/picons.tar.bz2 -C \ - /picons && \ - echo "**** cleanup ****" && \ - rm -rf \ - /tmp/* + /picons.tar.bz2 -L \ + https://lsio-ci.ams3.digitaloceanspaces.com/picons/picons.tar.bz2 # copy local files and buildstage artifacts COPY --from=buildstage /tmp/argtable-build/usr/ /usr/ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index 835ebb9..1152c7e 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -311,14 +311,8 @@ RUN \ echo "**** Add Picons ****" && \ mkdir -p /picons && \ curl -o \ - /tmp/picons.tar.bz2 -L \ - https://lsio-ci.ams3.digitaloceanspaces.com/picons/picons.tar.bz2 && \ - tar xf \ - /tmp/picons.tar.bz2 -C \ - /picons && \ - echo "**** cleanup ****" && \ - rm -rf \ - /tmp/* + /picons.tar.bz2 -L \ + https://lsio-ci.ams3.digitaloceanspaces.com/picons/picons.tar.bz2 # copy local files and buildstage artifacts COPY --from=buildstage /tmp/argtable-build/usr/ /usr/ diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index 7f80035..6c8ff32 100644 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -12,12 +12,17 @@ mkdir -p \ [[ ! -e /config/config ]] && \ (cp /defaults/config /config/config) +# extract picons on first run +[[ -f /picons.tar.bz2 ]] && \ + tar xf \ + /picons.tar.bz2 -C \ + /picons && + rm -f /picons.tar.bz2 - -# function to randomly sample 10 files for their owner and only chown if not abc +# function to randomly sample 5 files for their owner and only chown if not abc chowner () { files=(${1}/*) -for i in {1..10}; do +for i in {1..5}; do user=$(stat -c '%U' $(printf "%s\n" "${files[RANDOM % ${#files[@]}]}")) if [ "${user}" != "abc" ]; then chown -R abc:abc ${1}