diff --git a/cdist/conf/type/__ini_value/files/gen-awk.sh b/cdist/conf/type/__ini_value/files/gen-awk.sh deleted file mode 100755 index a73a3f7b..00000000 --- a/cdist/conf/type/__ini_value/files/gen-awk.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -e -# __ini_value/files/gen-awk.sh - -# Generates the awk script that will modify the line -# -# Arguments: -# 1: the file to modify -# 2: the should_state - -strip_comments() { - grep -v '^[[:space:]]*\($\|#\)' -} - - -file="$1" -state="$2" - - -# Generate the basic awk struct -cat < "\$tmpfile" <<'AWK' -SHELL - - -# generate the awk script and strip unnecessary things -{ - # basic functions which everyone needs - cat "$__type/files/common.awk" - - # generate the script and strip - awk -v state="$state" ' - function parse(line) { - if(match(line, /^[ \t]*# %code_print%$/) > 0) { - if(state == "present") - print "v_print()" - else if(state == "commented") - print "v_print_commented()" - else - print "print \"script compile error! cdist state " state " unkown!\" > /dev/stderr" - } - else print line - } - { - if(match($0, /^[ \t]*# %codeblock_([^%]+)%$/) > 0) { - split($2, result, "_"); type = substr(result[2], 1, length(result[2]) - 1) - file = (ENVIRON["__type"] "/files/parts/" state "/" type ".awk") - while((getline line < file) > 0) - parse(line) - close(file) - } - else print - }' "$__type/files/base.awk" -} | strip_comments - - -# end of here-doc -cat < "\$tmpfile" <<'AWK' +SHELL + + # generate the awk script and strip unnecessary things + { + # basic functions which everyone needs + cat "$__type/files/common.awk" + + # generate the script + awk -v state="$state_should" ' + function parse(line) { + if(match(line, /^[ \t]*# %code_print%$/) > 0) { + if(state == "present") + print "v_print()" + else if(state == "commented") + print "v_print_commented()" + else + print "print \"script compile error! cdist state " state " unkown!\" > /dev/stderr" + } + else print line + } + { + if(match($0, /^[ \t]*# %codeblock_([^%]+)%$/) > 0) { + split($2, result, "_"); type = substr(result[2], 1, length(result[2]) - 1) + file = (ENVIRON["__type"] "/files/parts/" state "/" type ".awk") + while((getline line < file) > 0) + parse(line) + close(file) + } + else print + }' "$__type/files/base.awk" + } | strip_comments + + # end of here-doc + cat < '%s'\n" "$file" + printf "%s cdist-generated file by %s/%s\n" "$comment_sign" \ + "${__type##*/}" "$__object_id" + echo + + # print values if available + section="$__object/parameter/section" + if [ -f "$section" ]; then + cat "$section" + echo + fi + comment="$__object/parameter/comment" + if [ -f "$comment" ]; then + printf "%s%s " "$i_indent" "$comment_sign" + cat "$comment" + fi + + # print the value + printf "%s%s%s%s%s%s%s\n" \ + "$i_indent" \ + "$(if [ "$state_should" = "commented" ]; then + printf "%s" "$comment_sign"; + fi)" \ + "$key" "$i_del_space" "$delimiter" "$i_del_space" "$value" + echo + + # terminate HERE-DOC + echo "FILE" + fi ;; *)