From 59f06483ec4063da6a9f1efcc5aeb111c7f7ee6f Mon Sep 17 00:00:00 2001 From: wade ~ Pack3tL0ss Date: Thu, 28 May 2020 19:13:53 -0500 Subject: [PATCH 1/2] Fix remove duplicate cmds to pull optional sections from existing config in update_config() --- installer/config.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/installer/config.sh b/installer/config.sh index 245e1720..f4d2eaa5 100755 --- a/installer/config.sh +++ b/installer/config.sh @@ -94,11 +94,12 @@ update_config() { spaces "debug: ${debug}" "# Turns on additional debugging" >> $yml_temp # echo "" >> $yml_temp if [[ -f $CONFIG_FILE_YAML ]] ; then - sed -n '/debug:/,//p' $CONFIG_FILE_YAML | tail -n +2 >> $yml_temp + # sed -n '/debug:/,//p' $CONFIG_FILE_YAML | tail -n +2 >> $yml_temp + # get all other optional config sections from existing config (POWER, HOSTS, TTYAMA) + awk 'matched; /^ debug:/ { matched = 1 } ' $CONFIG_FILE_YAML | awk '/^[A-Z]*$/ { matched = 1 } matched' >> $yml_temp # Test Below -- Above stays either way - # get all other optional config sections from existing config (POWER, HOSTS, TTYAMA) - awk 'matched; /^OVERRIDES:$/ { matched = 1 } ' $CONFIG_FILE_YAML | awk '/^[A-Z]*$/ { matched = 1 } matched' >> $yml_temp + # awk 'matched; /^OVERRIDES:$/ { matched = 1 } ' $CONFIG_FILE_YAML | awk '/^[A-Z]*$/ { matched = 1 } matched' >> $yml_temp file_diff_update $yml_temp $CONFIG_FILE_YAML rm $yml_temp group=$(stat -c '%G' $CONFIG_FILE_YAML) From 2db92a04d174b81fadc7d7a7671de4e02466be3e Mon Sep 17 00:00:00 2001 From: wade ~ Pack3tL0ss Date: Thu, 28 May 2020 19:20:35 -0500 Subject: [PATCH 2/2] minor Tidy Up --- installer/config.sh | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/installer/config.sh b/installer/config.sh index f4d2eaa5..f5effe2f 100755 --- a/installer/config.sh +++ b/installer/config.sh @@ -94,14 +94,11 @@ update_config() { spaces "debug: ${debug}" "# Turns on additional debugging" >> $yml_temp # echo "" >> $yml_temp if [[ -f $CONFIG_FILE_YAML ]] ; then - # sed -n '/debug:/,//p' $CONFIG_FILE_YAML | tail -n +2 >> $yml_temp # get all other optional config sections from existing config (POWER, HOSTS, TTYAMA) awk 'matched; /^ debug:/ { matched = 1 } ' $CONFIG_FILE_YAML | awk '/^[A-Z]*$/ { matched = 1 } matched' >> $yml_temp - - # Test Below -- Above stays either way - # awk 'matched; /^OVERRIDES:$/ { matched = 1 } ' $CONFIG_FILE_YAML | awk '/^[A-Z]*$/ { matched = 1 } matched' >> $yml_temp file_diff_update $yml_temp $CONFIG_FILE_YAML rm $yml_temp + # TODO Move this to common as a function group=$(stat -c '%G' $CONFIG_FILE_YAML) if [ ! $group == "consolepi" ]; then sudo chgrp consolepi $CONFIG_FILE_YAML 2>> $log_file && @@ -118,20 +115,6 @@ update_config() { logit "Config File Group Permissions already OK" fi fi - # if [[ -f $CONFIG_FILE_YAML ]] ; then - # # TODO check if they are different and keep existing if the same - # cp $CONFIG_FILE_YAML $bak_dir && logit "Backed up existing ConsolePi.yaml to bak dir" || - # logit "Failed to Back up existing ConsolePi.yaml to bak dir" - - # fi - # # -- // Move updated yaml to Config.yaml \\ -- - # if cat $yml_temp > $CONFIG_FILE_YAML ; then - # chgrp consolepi $CONFIG_FILE_YAML 2>>$log_file || logit "Failed to chg group for ConsolePi.yaml to consolepi group" "WARNING" - # chmod g+w $CONFIG_FILE_YAML 2>>$log_file || logit "Failed to make ConsolePi.yaml group writable" "WARNING" - # rm $yml_temp - # else - # logit "Failed to Copy updated yaml Config to ConsolePi.yaml" "ERROR" - # fi if [[ -f $CONFIG_FILE ]] ; then echo "ConsolePi now supports a new Configuration format and is configured via ConsolePi.yaml"