This commit is contained in:
Jason Swank
2025-12-19 21:13:02 +00:00
parent d34800d5b9
commit 9ba8e7c04e
4 changed files with 36 additions and 24 deletions

View File

@@ -0,0 +1,15 @@
export-secret() {
local name="$1"
local file="/run/secrets/${name}"
if [[ ! -f "$file" ]]; then
echo "Error: secret file not found: $file" >&2
return 1
fi
# Read first line, remove trailing spaces/tabs, convert nulls to newlines
local value
value=$(head -n1 "$file" | sed 's/[ \t]*$//' | tr '\0' '\n')
export "${name}=${value}"
}