make cluster-config
This commit is contained in:
45
scripts/merge-env.sh
Executable file
45
scripts/merge-env.sh
Executable 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"
|
||||
Reference in New Issue
Block a user