make cluster-config

This commit is contained in:
2026-03-25 06:29:07 +08:00
parent befd1a470e
commit db19bc72f7
4 changed files with 95 additions and 5 deletions

45
scripts/merge-env.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/sh
set -eu
INPUT="${1:?input file required}"
OUTPUT="${2:?output file required}"
mkdir -p "$(dirname "$OUTPUT")"
awk '
function trim(s) {
sub(/^[[:space:]]+/, "", s)
sub(/[[:space:]]+$/, "", s)
return s
}
BEGIN {
for (k in ENVIRON) {
env[k] = ENVIRON[k]
}
}
/^[[:space:]]*#/ || /^[[:space:]]*$/ {
print
next
}
{
line = $0
eq = index(line, "=")
if (eq == 0) {
print line
next
}
key = trim(substr(line, 1, eq - 1))
val = substr(line, eq + 1)
if (key in env) {
print key "=" env[key]
} else {
print line
}
}
' "$INPUT" > "$OUTPUT"