docker-baseimage-ubuntu/root/etc/cont-init.d/99-custom-scripts

64 wiersze
2.7 KiB
Plaintext
Czysty Zwykły widok Historia

#!/usr/bin/with-contenv bash
2022-08-28 20:28:14 +00:00
# shellcheck shell=bash
# Directories
2022-08-28 20:28:14 +00:00
SCRIPTS_DIR_OLD="/config/custom-cont-init.d"
SERVICES_DIR_OLD="/config/custom-services.d"
SCRIPTS_DIR="/custom-cont-init.d"
SERVICES_DIR="/custom-services.d"
2022-08-28 20:28:14 +00:00
if [[ -z "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]] &&
[[ -z "$(/bin/ls -A ${SCRIPTS_DIR_OLD} 2>/dev/null)" ]]; then
echo "[custom-init] no custom files found, skipping..."
2019-05-15 11:56:34 +00:00
else
2022-08-28 20:28:14 +00:00
# Make sure custom init directory exists and has files in it
if [[ -e "${SCRIPTS_DIR}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]]; then
echo "[custom-init] files found, executing"
for SCRIPT in "${SCRIPTS_DIR}"/*; do
NAME="$(basename "${SCRIPT}")"
if [[ -f "${SCRIPT}" ]]; then
echo "[custom-init] ${NAME}: executing..."
/bin/bash "${SCRIPT}"
echo "[custom-init] ${NAME}: exited $?"
elif [[ ! -f "${SCRIPT}" ]]; then
echo "[custom-init] ${NAME}: is not a file"
fi
done
fi
if [[ -e "${SCRIPTS_DIR_OLD}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR_OLD} 2>/dev/null)" ]]; then
echo "[custom-init] files found, executing"
for SCRIPT in "${SCRIPTS_DIR_OLD}"/*; do
NAME="$(basename "${SCRIPT}")"
if [[ -f "${SCRIPT}" ]]; then
echo "[custom-init] ${NAME}: executing..."
/bin/bash "${SCRIPT}"
echo "[custom-init] ${NAME}: exited $?"
elif [[ ! -f "${SCRIPT}" ]]; then
echo "[custom-init] ${NAME}: is not a file"
fi
done
fi
fi
if [[ -n "$(/bin/ls -A "${SCRIPTS_DIR_OLD}" 2>/dev/null)" ]] ||
[[ -n "$(/bin/ls -A "${SERVICES_DIR_OLD}" 2>/dev/null)" ]]; then
2022-09-02 08:48:36 +00:00
cat << EOF | tee {${SCRIPTS_DIR_OLD}/README.txt,${SERVICES_DIR_OLD}/README.txt} 2>/dev/null
2022-08-28 20:28:14 +00:00
********************************************************
********************************************************
* *
* !!!! *
* Custom scripts or services found in legacy locations *
* !!!! *
* Please move your custom scripts and services *
* to ${SCRIPTS_DIR} and ${SERVICES_DIR} *
* respectively to ensure they continue working. *
* *
* Visit https://linuxserver.io/custom for more info. *
* *
********************************************************
********************************************************
EOF
2019-05-15 11:56:34 +00:00
fi
2022-08-28 20:28:14 +00:00
exit 0