refactor
This commit is contained in:
32
image/substitution.sh
Executable file
32
image/substitution.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
current_file=""
|
||||
root="/kitchen/overlay"
|
||||
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
\#\ /*)
|
||||
current_file="${line#\# }"
|
||||
;;
|
||||
\#\:*)
|
||||
continue
|
||||
;;
|
||||
*=*)
|
||||
if [ -z "$current_file" ]; then
|
||||
echo "warning: value without file: $line" >&2
|
||||
continue
|
||||
fi
|
||||
key="${line%%=*}"
|
||||
value="${line#*=}"
|
||||
key_esc=$(printf '%s' "$key" | sed 's/[]\/$*.^[]/\\&/g')
|
||||
value_esc=$(printf '%s' "$value" | sed 's/[\/&]/\\&/g')
|
||||
sed -i "s/_${key_esc}_/${value_esc}/g" "$root$current_file"
|
||||
;;
|
||||
"")
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
echo "unknown line: $line" >&2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
Reference in New Issue
Block a user