From 97cefde6cd7042899e96b780f02c0b1d58e2a4a1 Mon Sep 17 00:00:00 2001 From: TheSpad Date: Sat, 10 Dec 2022 18:26:13 +0000 Subject: [PATCH] Remove legacy custom file & service handlers --- README.md | 1 + docker-mods.v3 | 86 +------------------------------------------------- 2 files changed, 2 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 41e006f..4f6fe96 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,5 @@ These files are used by Linuxserver build processes to handle mods in our images. Not for end-user consumption. +* **01.01.23:** - Remove support for legacy custom script/service locations. * **25.09.22:** - Initial Release. diff --git a/docker-mods.v3 b/docker-mods.v3 index e059c9e..6fc7182 100755 --- a/docker-mods.v3 +++ b/docker-mods.v3 @@ -6,9 +6,7 @@ MOD_SCRIPT_VER="3" # Define custom folder paths -SCRIPTS_DIR_OLD="/config/custom-cont-init.d" SCRIPTS_DIR="/custom-cont-init.d" -SERVICES_DIR_OLD="/config/custom-services.d" SERVICES_DIR="/custom-services.d" # Set executable bit on cont-init and services built into the image @@ -38,38 +36,6 @@ tamper_check() { fi } -tamper_check_legacy() { - # Tamper check custom script locations - if [[ -d "${SCRIPTS_DIR_OLD}" ]] && [[ -n "$(find ${SCRIPTS_DIR_OLD} ! -user root 2>/dev/null)" ]]; then - echo "[custom-init] **** Potential tampering with custom scripts detected ****" - randstr=$( - tr /dev/null)" ]]; then - echo "[custom-init] **** The folder '${SCRIPTS_DIR_OLD}' or some of its contents have write permissions for others, which is a security risk. ****" - echo "[custom-init] **** Please review the permissions of this folder and its contents to make sure they are owned by root, and can only be modified by root. ****" - fi - - # Tamper check custom service locations - if [[ -d "${SERVICES_DIR_OLD}" ]] && [[ -n "$(find ${SERVICES_DIR_OLD} ! -user root 2>/dev/null)" ]]; then - echo "[custom-init] **** Potential tampering with custom scripts detected ****" - randstr=$( - tr /dev/null)" ]]; then - echo "[custom-init] **** The folder '${SERVICES_DIR_OLD}' or some of its contents have write permissions for others, which is a security risk. ****" - echo "[custom-init] **** Please review the permissions of this folder and its contents to make sure they are owned by root, and can only be modified by root. ****" - fi -} - process_custom_services() { # Remove all existing custom services before continuing to ensure # we aren't running anything the user may have removed @@ -100,51 +66,6 @@ process_custom_services() { else echo "[custom-init] No custom services found, skipping..." fi - - # Remove legacy folder if it's empty - if [[ -e "${SERVICES_DIR_OLD}" ]] && [[ -z "$(/bin/ls -A ${SERVICES_DIR_OLD} 2>/dev/null)" ]]; then - echo "[custom-init] Legacy service folder ${SERVICES_DIR_OLD} is empty, deleting..." - rm -rf "${SERVICES_DIR_OLD}" - fi -} - -process_custom_services_legacy() { - - # Remove all existing custom services before continuing to ensure - # we aren't running anything the user may have removed - if [[ -n "$(/bin/ls -A /etc/s6-overlay/s6-rc.d/custom-svc-* 2>/dev/null)" ]]; then - echo "[custom-init] removing existing custom services..." - rm -rf /etc/s6-overlay/s6-rc.d/custom-svc-* - rm /etc/s6-overlay/s6-rc.d/user/contents.d/custom-svc-* - fi - - # Make sure custom service directory exists and has files in it - if [[ -e "${SERVICES_DIR_OLD}" ]] && [[ -n "$(/bin/ls -A ${SERVICES_DIR_OLD} 2>/dev/null)" ]]; then - echo "[custom-init] Service files found in ${SERVICES_DIR_OLD}" - for SERVICE in "${SERVICES_DIR_OLD}"/*; do - NAME="$(basename "${SERVICE}")" - if [[ -f "${SERVICE}" ]]; then - echo "[custom-init] ${NAME}: service detected, copying..." - mkdir -p /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/dependencies.d/ - cp "${SERVICE}" /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/run - chmod +x /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/run - echo "longrun" >/etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/type - touch /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/dependencies.d/init-services - touch /etc/s6-overlay/s6-rc.d/user/contents.d/custom-svc-"${NAME}" - echo "[custom-init] ${NAME}: copied" - elif [[ ! -f "${SERVICE}" ]]; then - echo "[custom-init] ${NAME}: is not a file" - fi - done - else - echo "[custom-init] No custom services found, skipping..." - fi - - # Remove legacy folder if it's empty - if [[ -e "${SERVICES_DIR_OLD}" ]] && [[ -z "$(/bin/ls -A ${SERVICES_DIR_OLD} 2>/dev/null)" ]]; then - echo "[custom-init] Legacy service folder ${SERVICES_DIR_OLD} is empty, deleting..." - rm -rf "${SERVICES_DIR_OLD}" - fi } #Create our noisy chown alias to handle read-only/remote volumes @@ -302,12 +223,7 @@ if [[ ${S6_VERBOSITY} -ge 2 ]]; then echo "[mod-init] Version ${MOD_SCRIPT_VER}" fi -if [[ ! -d "${SCRIPTS_DIR}" ]] && [[ ! -d "${SERVICES_DIR}" ]]; then - # Tamper check legacy custom folders - tamper_check_legacy - process_custom_services_legacy -else - # Tamper check new custom folders +if [[ -d "${SCRIPTS_DIR}" ]] || [[ -d "${SERVICES_DIR}" ]]; then tamper_check process_custom_services fi