custom services are now copied into easily identifiable directory so we can remove and 'start fresh' every container run. This allows users to remove services and the changes to take effect on a restart rather than having to rebuild the container
This commit is contained in:
parent
9b0dd02566
commit
68483bc920
|
|
@ -4,12 +4,9 @@
|
||||||
SCRIPTS_DIR="/config/custom-cont-init.d"
|
SCRIPTS_DIR="/config/custom-cont-init.d"
|
||||||
SERVICES_DIR="/config/custom-services.d"
|
SERVICES_DIR="/config/custom-services.d"
|
||||||
|
|
||||||
# Make sure custom directories exist and have files in them
|
# Make sure custom init directory exists and has files in it
|
||||||
if ([ -e "${SCRIPTS_DIR}" ] && \
|
if ([ -e "${SCRIPTS_DIR}" ] && \
|
||||||
[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]) || \
|
[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]); then
|
||||||
([ -e "${SERVICES_DIR}" ] && \
|
|
||||||
[ -n "$(/bin/ls -A ${SERVICES_DIR} 2>/dev/null)" ]); then
|
|
||||||
if [ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]; then
|
|
||||||
echo "[custom-init] files found in ${SCRIPTS_DIR} executing"
|
echo "[custom-init] files found in ${SCRIPTS_DIR} executing"
|
||||||
for SCRIPT in ${SCRIPTS_DIR}/*; do
|
for SCRIPT in ${SCRIPTS_DIR}/*; do
|
||||||
NAME="$(basename "${SCRIPT}")"
|
NAME="$(basename "${SCRIPT}")"
|
||||||
|
|
@ -21,25 +18,35 @@ if ([ -e "${SCRIPTS_DIR}" ] && \
|
||||||
echo "[custom-init] ${NAME}: is not a file"
|
echo "[custom-init] ${NAME}: is not a file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
else
|
||||||
if [ -n "$(/bin/ls -A ${SERVICES_DIR} 2>/dev/null)" ]; then
|
echo "[custom-init] no custom init files found"
|
||||||
echo "[custom-init] service files found in ${SERVICES_DIR} copying"
|
fi
|
||||||
|
|
||||||
|
# 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/services.d/custom-service-* 2>/dev/null)" ]; then
|
||||||
|
echo "[custom-init] removing existing custom services..."
|
||||||
|
rm -rf /etc/services.d/custom-service-*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make sure custom services directory exists and has files in it
|
||||||
|
if [ -e "${SERVICES_DIR}" ] && \
|
||||||
|
[ -n "$(/bin/ls -A ${SERVICES_DIR} 2>/dev/null)" ]; then
|
||||||
|
echo "[custom-init] service files found in ${SERVICES_DIR}"
|
||||||
for SERVICE in ${SERVICES_DIR}/*; do
|
for SERVICE in ${SERVICES_DIR}/*; do
|
||||||
NAME="$(basename "${SERVICE}")"
|
NAME="$(basename "${SERVICE}")"
|
||||||
if ! $(cmp -s ${SERVICE} /etc/services.d/${NAME}/run) && \
|
if [ -f "${SERVICE}" ]; then
|
||||||
[ -f "${SERVICE}" ]; then
|
echo "[custom-init] ${NAME}: service detected, copying..."
|
||||||
echo "[custom-init] ${NAME}: new file detected copying..."
|
mkdir -p /etc/services.d/custom-service-${NAME}/
|
||||||
mkdir -p /etc/services.d/${NAME}/
|
cp ${SERVICE} /etc/services.d/custom-service-${NAME}/run
|
||||||
cp ${SERVICE} /etc/services.d/${NAME}/run
|
chmod +x /etc/services.d/custom-service-${NAME}/run
|
||||||
chmod +x /etc/services.d/${NAME}/run
|
|
||||||
echo "[custom-init] ${NAME}: copied"
|
echo "[custom-init] ${NAME}: copied"
|
||||||
elif [ ! -f "${SERVICE}" ]; then
|
elif [ ! -f "${SERVICE}" ]; then
|
||||||
echo "[custom-init] ${NAME}: is not a file"
|
echo "[custom-init] ${NAME}: is not a file"
|
||||||
else
|
|
||||||
echo "[custom-init] ${NAME}: is up to date"
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "[custom-init] no custom files found exiting..."
|
echo "[custom-init] no custom services files found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "[custom-init] done"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue