From 53c16e53c3ad1ede500e42335fdab2d748101eaa Mon Sep 17 00:00:00 2001 From: xZero707 Date: Tue, 29 Oct 2024 02:37:13 +0100 Subject: [PATCH] Add helper for loading secrets --- rootfs/usr/local/bin/load_secrets | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 rootfs/usr/local/bin/load_secrets diff --git a/rootfs/usr/local/bin/load_secrets b/rootfs/usr/local/bin/load_secrets new file mode 100755 index 0000000..c9c266e --- /dev/null +++ b/rootfs/usr/local/bin/load_secrets @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +load_dir_env() { + local dir="$1" + + shopt -s nullglob + + for file in "$dir"/*; do + if [ -f "$file" ] && [[ "$(basename "$file")" != *=* ]]; then + varName="$(basename "$file")" + value="$(<"$file")" + export "${varName}=${value}" + fi + done +} + +main() { + load_dir_env /run/secrets_normalized +} + +main