diff --git a/Dockerfile b/Dockerfile index 073e1ff..8bcd180 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ RUN \ apk add --no-cache \ bash \ curl \ + patch \ + tar \ tzdata \ xz @@ -21,6 +23,29 @@ RUN \ /rootfs.tar.gz -C \ /root-out +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.0.1" +ARG S6_OVERLAY_ARCH="x86_64" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz + +# add s6 optional symlinks +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz + +# copy ci-checks +COPY ci-check/ /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-rc/sources/top/contents.d + +# patch cont-init for docker-mods +COPY patch/ /tmp/patch +RUN patch -u /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-linux-init/skel/rc.init -i /tmp/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch + # Runtime stage FROM scratch COPY --from=rootfs-stage /root-out/ / @@ -29,21 +54,13 @@ ARG VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="TheLamer" -# set version for s6 overlay -ARG OVERLAY_VERSION="v2.2.0.3" -ARG OVERLAY_ARCH="amd64" - -# add s6 overlay -ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer -COPY patch/ /tmp/patch - # set environment variables ARG DEBIAN_FRONTEND="noninteractive" ENV HOME="/root" \ LANGUAGE="en_US.UTF-8" \ LANG="en_US.UTF-8" \ -TERM="xterm" +TERM="xterm" \ +S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" # copy sources COPY sources.list /etc/apt/ @@ -90,7 +107,6 @@ RUN \ apt-get install -y \ curl \ gnupg \ - patch \ tzdata && \ echo "**** generate locale ****" && \ locale-gen en_US.UTF-8 && \ @@ -101,10 +117,7 @@ RUN \ /app \ /config \ /defaults && \ - mv /usr/bin/with-contenv /usr/bin/with-contenvb && \ - patch -u /etc/s6/init/init-stage2 -i /tmp/patch/etc/s6/init/init-stage2.patch && \ echo "**** cleanup ****" && \ - apt-get remove -y patch && \ apt-get autoremove && \ apt-get clean && \ rm -rf \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 69860ae..fda679b 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -8,6 +8,8 @@ RUN \ apk add --no-cache \ bash \ curl \ + patch \ + tar \ tzdata \ xz @@ -21,6 +23,29 @@ RUN \ /rootfs.tar.gz -C \ /root-out +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.0.1" +ARG S6_OVERLAY_ARCH="aarch64" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz + +# add s6 optional symlinks +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz + +# copy ci-checks +COPY ci-check/ /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-rc/sources/top/contents.d + +# patch cont-init for docker-mods +COPY patch/ /tmp/patch +RUN patch -u /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-linux-init/skel/rc.init -i /tmp/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch + # Runtime stage FROM scratch COPY --from=rootfs-stage /root-out/ / @@ -29,21 +54,13 @@ ARG VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="TheLamer" -# set version for s6 overlay -ARG OVERLAY_VERSION="v2.2.0.3" -ARG OVERLAY_ARCH="aarch64" - -# add s6 overlay -ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer -COPY patch/ /tmp/patch - # set environment variables ARG DEBIAN_FRONTEND="noninteractive" ENV HOME="/root" \ LANGUAGE="en_US.UTF-8" \ LANG="en_US.UTF-8" \ -TERM="xterm" +TERM="xterm" \ +S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" # copy sources COPY sources.list.arm /etc/apt/ @@ -90,7 +107,6 @@ RUN \ apt-get install -y \ curl \ gnupg \ - patch \ tzdata && \ echo "**** generate locale ****" && \ locale-gen en_US.UTF-8 && \ @@ -101,15 +117,12 @@ RUN \ /app \ /config \ /defaults && \ - mv /usr/bin/with-contenv /usr/bin/with-contenvb && \ - patch -u /etc/s6/init/init-stage2 -i /tmp/patch/etc/s6/init/init-stage2.patch && \ echo "**** add qemu ****" && \ curl -o \ /usr/bin/qemu-aarch64-static -L \ "https://lsio-ci.ams3.digitaloceanspaces.com/qemu-aarch64-static" && \ chmod +x /usr/bin/qemu-aarch64-static && \ echo "**** cleanup ****" && \ - apt-get remove -y patch && \ apt-get autoremove && \ apt-get clean && \ rm -rf \ diff --git a/Dockerfile.armhf b/Dockerfile.armhf index b02a3f0..4dfbcb6 100644 --- a/Dockerfile.armhf +++ b/Dockerfile.armhf @@ -8,6 +8,8 @@ RUN \ apk add --no-cache \ bash \ curl \ + patch \ + tar \ tzdata \ xz @@ -21,6 +23,29 @@ RUN \ /rootfs.tar.gz -C \ /root-out +# set version for s6 overlay +ARG S6_OVERLAY_VERSION="3.1.0.1" +ARG S6_OVERLAY_ARCH="armhf" + +# add s6 overlay +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-${S6_OVERLAY_ARCH}.tar.xz + +# add s6 optional symlinks +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-noarch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-noarch.tar.xz +ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-symlinks-arch.tar.xz /tmp +RUN tar -C /root-out -Jxpf /tmp/s6-overlay-symlinks-arch.tar.xz + +# copy ci-checks +COPY ci-check/ /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-rc/sources/top/contents.d + +# patch cont-init for docker-mods +COPY patch/ /tmp/patch +RUN patch -u /root-out/package/admin/s6-overlay-${S6_OVERLAY_VERSION}/etc/s6-linux-init/skel/rc.init -i /tmp/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch + # Runtime stage FROM scratch COPY --from=rootfs-stage /root-out/ / @@ -29,21 +54,13 @@ ARG VERSION LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" LABEL maintainer="TheLamer" -# set version for s6 overlay -ARG OVERLAY_VERSION="v2.2.0.3" -ARG OVERLAY_ARCH="arm" - -# add s6 overlay -ADD https://github.com/just-containers/s6-overlay/releases/download/${OVERLAY_VERSION}/s6-overlay-${OVERLAY_ARCH}-installer /tmp/ -RUN chmod +x /tmp/s6-overlay-${OVERLAY_ARCH}-installer && /tmp/s6-overlay-${OVERLAY_ARCH}-installer / && rm /tmp/s6-overlay-${OVERLAY_ARCH}-installer -COPY patch/ /tmp/patch - # set environment variables ARG DEBIAN_FRONTEND="noninteractive" ENV HOME="/root" \ LANGUAGE="en_US.UTF-8" \ LANG="en_US.UTF-8" \ -TERM="xterm" +TERM="xterm" \ +S6_CMD_WAIT_FOR_SERVICES_MAXTIME="0" # copy sources COPY sources.list.arm /etc/apt/ @@ -90,7 +107,6 @@ RUN \ apt-get install -y \ curl \ gnupg \ - patch \ tzdata && \ echo "**** generate locale ****" && \ locale-gen en_US.UTF-8 && \ @@ -101,15 +117,12 @@ RUN \ /app \ /config \ /defaults && \ - mv /usr/bin/with-contenv /usr/bin/with-contenvb && \ - patch -u /etc/s6/init/init-stage2 -i /tmp/patch/etc/s6/init/init-stage2.patch && \ echo "**** add qemu ****" && \ curl -o \ /usr/bin/qemu-arm-static -L \ "https://lsio-ci.ams3.digitaloceanspaces.com/qemu-arm-static" && \ chmod +x /usr/bin/qemu-arm-static && \ echo "**** cleanup ****" && \ - apt-get remove -y patch && \ apt-get autoremove && \ apt-get clean && \ rm -rf \ diff --git a/ci-check/99-ci-service-check b/ci-check/99-ci-service-check new file mode 100644 index 0000000..e69de29 diff --git a/patch/etc/s6/init/init-stage2.patch b/patch/etc/s6/init/init-stage2.patch deleted file mode 100644 index db176f8..0000000 --- a/patch/etc/s6/init/init-stage2.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- init-stage2 2021-01-20 20:21:41.628300700 -0600 -+++ init-stage2_new 2021-01-20 20:23:48.123677700 -0600 -@@ -17,6 +17,12 @@ - backtick -D 0 -n S6_READ_ONLY_ROOT { printcontenv S6_READ_ONLY_ROOT } - importas -u S6_READ_ONLY_ROOT S6_READ_ONLY_ROOT - -+# Docker Mods run logic -+foreground -+{ -+ /docker-mods -+} -+ - foreground - { - if diff --git a/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch b/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch new file mode 100644 index 0000000..b01a7f0 --- /dev/null +++ b/patch/package/admin/s6-overlay-@VERSION@/etc/s6-linux-init/skel/rc.init.patch @@ -0,0 +1,11 @@ +--- rc.init 2022-05-20 17:41:11.195721000 -0500 ++++ rc.init.patched 2022-05-20 17:41:37.646586700 -0500 +@@ -6,6 +6,8 @@ + s6-chmod 0755 /run/s6/container_environment + fi + ++/docker-mods ++ + if profile=`printcontenv S6_RUNTIME_PROFILE` ; then + etc="/etc/cont-profile.d/$profile" + else diff --git a/root/docker-mods b/root/docker-mods index 7dcc41b..9128eb1 100755 --- a/root/docker-mods +++ b/root/docker-mods @@ -1,5 +1,14 @@ #!/usr/bin/with-contenv bash +# Set executable bit on cont-init and services built into the image +set_legacy_executable_bits() { + mkdir -p /etc/{cont-init.d,services.d} + chmod +x \ + /etc/cont-init.d/* \ + /etc/services.d/*/* 2> /dev/null || true +} +set_legacy_executable_bits + # Exit if mods is not set if [ -z ${DOCKER_MODS+x} ]; then exit 0 @@ -119,3 +128,6 @@ for DOCKER_MOD in "${DOCKER_MODS[@]}"; do echo ${SHALAYER} > "/${FILENAME}" fi done + +# Set executable bit on cont-init and services that may have been unpacked by mods +set_legacy_executable_bits diff --git a/root/etc/cont-init.d/01-envfile b/root/etc/cont-init.d/01-envfile old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/02-tamper-check b/root/etc/cont-init.d/02-tamper-check old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/10-adduser b/root/etc/cont-init.d/10-adduser old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/90-custom-folders b/root/etc/cont-init.d/90-custom-folders old mode 100644 new mode 100755 diff --git a/root/etc/cont-init.d/99-custom-scripts b/root/etc/cont-init.d/99-custom-scripts old mode 100644 new mode 100755 diff --git a/root/etc/s6-overlay/s6-rc.d/00-legacy/type b/root/etc/s6-overlay/s6-rc.d/00-legacy/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/00-legacy/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/00-legacy/up b/root/etc/s6-overlay/s6-rc.d/00-legacy/up new file mode 100644 index 0000000..4aa1c27 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/00-legacy/up @@ -0,0 +1 @@ +ln -s /run/s6/legacy-services /run/s6/services diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/base b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/legacy-services b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/legacy-services new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/user b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/dependencies.d/user new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/type b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/up b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/up new file mode 100644 index 0000000..e0f9488 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/99-ci-service-check/up @@ -0,0 +1 @@ +echo "[ls.io-init] done." \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/00-legacy b/root/etc/s6-overlay/s6-rc.d/user/contents.d/00-legacy new file mode 100644 index 0000000..e69de29 diff --git a/root/usr/bin/with-contenv b/root/usr/bin/with-contenv index b535def..212d908 100755 --- a/root/usr/bin/with-contenv +++ b/root/usr/bin/with-contenv @@ -1,7 +1,9 @@ #! /bin/bash -if [[ -f /var/run/s6/container_environment/UMASK ]] && [[ "$(pwdx $$)" =~ "/run/s6/services/" ]]; then - umask $(cat /var/run/s6/container_environment/UMASK) - exec /usr/bin/with-contenvb "$@" -else - exec /usr/bin/with-contenvb "$@" + +if [[ -f /var/run/s6/container_environment/UMASK ]] && \ + { [[ "$(pwdx $$)" =~ "/run/s6/legacy-services/" ]] || \ + [[ "$(pwdx $$)" =~ "/run/s6/services/" ]] || \ + [[ "$(pwdx $$)" =~ "/servicedirs/svc-" ]]; }; then + umask $(cat /var/run/s6/container_environment/UMASK) fi +exec /command/with-contenv "$@"