From 5c8959d9388e3bb71b092109d4ef8bc40010bd21 Mon Sep 17 00:00:00 2001 From: xZero707 Date: Fri, 24 May 2024 00:28:52 +0200 Subject: [PATCH] Add new init service "init-wpconfig-verify" --- .../crond/dependencies.d/init-wpconfig-verify | 0 .../dependencies.d/init-wpconfig-verify | 0 .../init-wpconfig-verify/dependencies.d/base | 0 .../s6-rc.d/init-wpconfig-verify/run | 58 +++++++++++++++++++ .../s6-rc.d/init-wpconfig-verify/type | 1 + .../s6-rc.d/init-wpconfig-verify/up | 1 + .../unitd/dependencies.d/init-wpconfig-verify | 0 .../user/contents.d/init-wpconfig-verify | 0 8 files changed, 60 insertions(+) create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/crond/dependencies.d/init-wpconfig-verify create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/init-install-resources/dependencies.d/init-wpconfig-verify create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/dependencies.d/base create mode 100755 rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/run create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/type create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/up create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/unitd/dependencies.d/init-wpconfig-verify create mode 100644 rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wpconfig-verify diff --git a/rootfs/etc/s6-overlay/s6-rc.d/crond/dependencies.d/init-wpconfig-verify b/rootfs/etc/s6-overlay/s6-rc.d/crond/dependencies.d/init-wpconfig-verify new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-install-resources/dependencies.d/init-wpconfig-verify b/rootfs/etc/s6-overlay/s6-rc.d/init-install-resources/dependencies.d/init-wpconfig-verify new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/dependencies.d/base b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/run b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/run new file mode 100755 index 0000000..e93afc2 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/run @@ -0,0 +1,58 @@ +#!/command/with-contenv bash +# shellcheck shell=bash + +checkSaltsEnv() { + if [ -z "${WORDPRESS_AUTH_KEY}" ]; then + echo "- WORDPRESS_AUTH_KEY is not set" + return 1 + fi + + if [ -z "${WORDPRESS_SECURE_AUTH_KEY}" ]; then + echo "- WORDPRESS_SECURE_AUTH_KEY is not set" + return 1 + fi + + if [ -z "${WORDPRESS_LOGGED_IN_KEY}" ]; then + echo "- WORDPRESS_LOGGED_IN_KEY is not set" + return 1 + fi + + if [ -z "${WORDPRESS_NONCE_KEY}" ]; then + echo "- WORDPRESS_NONCE_KEY is not set" + return 1 + fi + + if [ -z "${WORDPRESS_AUTH_SALT}" ]; then + echo "- WORDPRESS_AUTH_SALT is not set" + return 1 + fi + + if [ -z "${WORDPRESS_SECURE_AUTH_SALT}" ]; then + echo "- WORDPRESS_SECURE_AUTH_SALT is not set" + return 1 + fi + + if [ -z "${WORDPRESS_LOGGED_IN_SALT}" ]; then + echo "- WORDPRESS_LOGGED_IN_SALT is not set" + return 1 + fi + + if [ -z "${WORDPRESS_NONCE_SALT}" ]; then + echo "- WORDPRESS_NONCE_SALT is not set" + return 1 + fi +} + +# init-wpconfig-verify main +main() { + # This will prepend service name to all output from here + exec > >(while read -r line; do echo "[init-wpconfig-verify] ${line}"; done) 2>&1 + + echo "Checking salts..." + if ! checkSaltsEnv; then + echo "^^^ Some or all of the salts are not set. Cannot continue." + return 1 + fi + +} +main diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/type b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/type new file mode 100644 index 0000000..3d92b15 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/up b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/up new file mode 100644 index 0000000..55d8ab3 --- /dev/null +++ b/rootfs/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-wpconfig-verify/run \ No newline at end of file diff --git a/rootfs/etc/s6-overlay/s6-rc.d/unitd/dependencies.d/init-wpconfig-verify b/rootfs/etc/s6-overlay/s6-rc.d/unitd/dependencies.d/init-wpconfig-verify new file mode 100644 index 0000000..e69de29 diff --git a/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wpconfig-verify b/rootfs/etc/s6-overlay/s6-rc.d/user/contents.d/init-wpconfig-verify new file mode 100644 index 0000000..e69de29