From 7f8aa05e80102dc03719b2b79b4f594b97c5a1a8 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Mon, 11 Jul 2016 13:23:54 +1000 Subject: [PATCH] Add printconfig command This new command will print the file that each config option is taken from. --- tools/arkmanager | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/arkmanager b/tools/arkmanager index 5c0e97b..3197a44 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -2088,6 +2088,23 @@ doListAllInstances(){ fi } +doPrintConfig(){ + declare -A vars + declare -A vals + for v in $(eval echo \$\{\!{a..z}\*\} \$\{\!{A..Z}\*\} \$\{\!_\*\}); do + vals["$v"]="${!v}" + done + for cfgfile in "$configfile" "$HOME/.arkmanager.cfg" "/etc/arkmanager/arkmanager.cfg"; do + while read v; do + val="$(source "$cfgfile"; echo "${!v}")" + if [[ "$val" = "${vals[$v]}" && -z "${vars[$v]}" ]]; then + vars["$v"]="$cfgfile" + echo "${cfgfile} => ${v}" + fi + done < <(sed -n 's/^[[:space:]]*\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' <"$cfgfile") + done +} + useConfig() { configfile= if [ -f "/etc/arkmanager/instances/${1}.cfg" ]; then @@ -2377,6 +2394,9 @@ main(){ rconcmd) rconcmd "${args[@]}" ;; + printconfig) + doPrintConfig + ;; status) printStatus ;;