diff options
author | Scott Moser <smoser@brickies.net> | 2017-03-01 12:12:15 -0500 |
---|---|---|
committer | Scott Moser <smoser@brickies.net> | 2017-03-03 01:30:15 -0500 |
commit | 51a24555e5e7af709caa8dab1a5e6c7e7f317b17 (patch) | |
tree | 3b0765ba4911e5c91466044810e7e5947357fc08 /tools | |
parent | ade8c2e0266b020089145075e8236b95c000a3cb (diff) | |
download | vyos-cloud-init-51a24555e5e7af709caa8dab1a5e6c7e7f317b17.tar.gz vyos-cloud-init-51a24555e5e7af709caa8dab1a5e6c7e7f317b17.zip |
tools/ds-identify: make report mode write namespaced results.
Now, when ds-identify runs in report mode, it still writes to
/run/cloud-init.cfg as search does, but it will namespace the
result under the top level 'di_report' entry.
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/ds-identify | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/ds-identify b/tools/ds-identify index 9711a234..fd2a46c8 100755 --- a/tools/ds-identify +++ b/tools/ds-identify @@ -10,8 +10,9 @@ # default setting is: # search,found=all,maybe=all,notfound=disable # -# report: write config to /run/cloud-init/cloud.cfg.report (instead of -# /run/cloud-init/cloud.cfg, which effectively makes this dry-run). +# report: write config to /run/cloud-init/cloud.cfg, but +# namespaced under 'di_report'. Thus cloud-init can still see +# the result, but has no affect. # enable: do nothing # ds-identify writes no config and just exits success # the caller (cloud-init-generator) then enables cloud-init to run @@ -867,15 +868,16 @@ _print_info() { } write_result() { - local runcfg="${PATH_RUN_CI_CFG}" ret="" line="" - if [ "$DI_REPORT" = "true" ]; then - # if report is true, then we write to .report, but touch the other. - : > "$runcfg" - runcfg="$runcfg.report" - fi - for line in "$@"; do - echo "$line" - done > "$runcfg" + local runcfg="${PATH_RUN_CI_CFG}" ret="" line="" pre="" + { + if [ "$DI_REPORT" = "true" ]; then + echo "di_report:" + pre=" " + fi + for line in "$@"; do + echo "${pre}$line"; + done + } > "$runcfg" ret=$? [ $ret -eq 0 ] || { error "failed to write to ${runcfg}" @@ -956,6 +958,7 @@ _read_config() { if [ "$keyname" = "_unset" ]; then return 1 fi + _RET="" return 0 } |