From 178dae5797031c4636e0af645a810c948e740b88 Mon Sep 17 00:00:00 2001
From: thelamer <ryankuba@gmail.com>
Date: Wed, 1 May 2019 14:42:48 -0700
Subject: [PATCH] adding custom script logic to execute user scripts in a
 config directory

---
 root/etc/cont-init.d/99-custom-scripts | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 root/etc/cont-init.d/99-custom-scripts

diff --git a/root/etc/cont-init.d/99-custom-scripts b/root/etc/cont-init.d/99-custom-scripts
new file mode 100644
index 0000000..7e4c16b
--- /dev/null
+++ b/root/etc/cont-init.d/99-custom-scripts
@@ -0,0 +1,15 @@
+#!/usr/bin/with-contenv bash
+
+# Make sure custom script directory exists and has files in it
+SCRIPTS_DIR="/config/custom-init-scripts"
+if [ -e "${SCRIPTS_DIR}" ] && \
+   [ -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
+        echo "[custom-init] ${SCRIPT}: executing..."
+        /bin/bash ${SCRIPT}
+        echo "[custom-init] ${SCRIPT}: exited $?"
+    done
+else
+    echo "[custom-init] no custom scripts found exiting..."
+fi
-- 
GitLab