summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2017-02-24 11:37:31 -0500
committerScott Moser <smoser@brickies.net>2017-02-24 22:47:21 -0500
commit56f66872923e653ba64c9f9baa0ad7a23a9da0c1 (patch)
treed342f3d368ef6efd8d8ea14bcbb007db35d51bca
parente0efe853b805ca3c66155b7307a67af5175b3f46 (diff)
downloadvyos-cloud-init-56f66872923e653ba64c9f9baa0ad7a23a9da0c1.tar.gz
vyos-cloud-init-56f66872923e653ba64c9f9baa0ad7a23a9da0c1.zip
tools/ds-identify: add support for found or maybe contributing config.
A check function that returns found or maybe can also now return config that will be written to the resultant /run/cloud.cfg. They do so by setting the variable _RET_excfg.
-rwxr-xr-xtools/ds-identify32
1 files changed, 23 insertions, 9 deletions
diff --git a/tools/ds-identify b/tools/ds-identify
index c15ba5c0..1cd1118f 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -765,12 +765,22 @@ write_result() {
}
found() {
+ # found(ds1, [ds2 ...], [-- [extra lines]])
local list="" ds=""
# always we write the None datasource last.
- for ds in "$@" None; do
- list="${list:+${list}, }$ds"
+ while [ $# -ne 0 ]; do
+ if [ "$1" = "--" ]; then
+ shift
+ break
+ fi
+ list="${list:+${list}, }$1"
+ shift
done
- write_result "datasource_list: [ $list ]"
+ if [ $# -eq 1 ] && [ -z "$1" ]; then
+ # do not pass an empty line through.
+ shift
+ fi
+ write_result "datasource_list: [ $list ]" "$@"
return
}
@@ -977,7 +987,8 @@ _main() {
return
fi
- local found="" ret="" ds="" maybe=""
+ local found="" ret="" ds="" maybe="" _RET_excfg=""
+ local exfound_cfg="" exmaybe_cfg=""
for ds in ${DI_DSLIST}; do
dscheck_fn="dscheck_${ds}"
debug 2 "Checking for datasource '$ds' via '$dscheck_fn'"
@@ -985,20 +996,23 @@ _main() {
warn "No check method '$dscheck_fn' for datasource '$ds'"
continue
fi
+ _RET_excfg=""
$dscheck_fn
ret="$?"
case "$ret" in
$DS_FOUND)
debug 1 "check for '$ds' returned found";
+ exfound_cfg="${exfound_cfg:+${exfound_cfg}${CR}}${_RET_excfg}"
found="${found} $ds";;
$DS_MAYBE)
- debug 1 "check for $ds returned maybe";
+ debug 1 "check for '$ds' returned maybe";
+ exmaybe_cfg="${exmaybe_cfg:+${exmaybe_cfg}${CR}}${_RET_excfg}"
maybe="${maybe} $ds";;
- *) debug 2 "check for $ds returned not-found[$ret]";;
+ *) debug 2 "check for '$ds' returned not-found[$ret]";;
esac
done
- debug 2 "found=$found maybe=$maybe"
+ debug 2 "found=${found# } maybe=${maybe# }"
set -- $found
if [ $# -ne 0 ]; then
if [ $# -eq 1 ]; then
@@ -1010,14 +1024,14 @@ _main() {
set -- "$1"
fi
fi
- found "$@"
+ found "$@" -- "${exfound_cfg}"
return
fi
set -- $maybe
if [ $# -ne 0 -a "${DI_ON_MAYBE}" != "none" ]; then
debug 1 "$# datasources returned maybe: $*"
- found "$@"
+ found "$@" -- "${exmaybe_cfg}"
return
fi