modified logic to have init script and services folder checks in single check
rodzic
1cf8a446c1
commit
5940cc7169
|
@ -4,9 +4,19 @@
|
|||
SCRIPTS_DIR="/config/custom-cont-init.d"
|
||||
SERVICES_DIR="/config/custom-services.d"
|
||||
|
||||
# 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 init directory exists and has files in it
|
||||
if ([ -e "${SCRIPTS_DIR}" ] && \
|
||||
[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]); then
|
||||
[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]) || \
|
||||
([ -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"
|
||||
for SCRIPT in ${SCRIPTS_DIR}/*; do
|
||||
NAME="$(basename "${SCRIPT}")"
|
||||
|
@ -18,20 +28,8 @@ if ([ -e "${SCRIPTS_DIR}" ] && \
|
|||
echo "[custom-init] ${NAME}: is not a file"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "[custom-init] no custom init files found"
|
||||
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
|
||||
if [ -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
|
||||
NAME="$(basename "${SERVICE}")"
|
||||
|
@ -45,8 +43,8 @@ if [ -e "${SERVICES_DIR}" ] && \
|
|||
echo "[custom-init] ${NAME}: is not a file"
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "[custom-init] no custom services files found"
|
||||
fi
|
||||
|
||||
echo "[custom-init] done"
|
||||
fi
|
||||
else
|
||||
echo "[custom-init] no custom files found exiting..."
|
||||
fi
|
||||
|
|
Ładowanie…
Reference in New Issue