diff --git a/root/.gitignore b/root/.gitignore index c54e9be..80f7d03 100644 --- a/root/.gitignore +++ b/root/.gitignore @@ -1 +1,2 @@ data.cdb +preprocessor.sed diff --git a/root/preprocessor.sh b/root/preprocessor.sh new file mode 100755 index 0000000..41b013c --- /dev/null +++ b/root/preprocessor.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +DIR="${0%/*}" + +compile_template() +{ + tr '\n' '|' | sed -e 's/\\/\\\\/g' -e 's/|*$//' -e 's/|/\\n/g' -e 's/$/\\n\n/' -e 's/&/\\&/g' -e 's/,/\\,/g' +} + +for x in $DIR/*.in; do + name="$( echo "$x" | sed -e 's,.*/,,' -e 's,\.in$,,' | tr 'a-z' 'A-Z' )" + value="$( cat $x | compile_template )" + echo "s,@@$name@@,$value,g;" +done + +sed -e '/^#/d;' -e '/^[ \t]*$/d;' -e 's/=/ /' "$DIR/servers.txt" | + while read name value; do + echo "s,@@$name@@,$value,g;" +done