From e6499619aeb9428ee42b7232ed470501df2932ec Mon Sep 17 00:00:00 2001 From: Chris Date: Sat, 20 May 2023 13:31:59 -0400 Subject: [PATCH] check for and move user file locations --- profiles/default/config.cfg | 8 ++-- profiles/hephaestus/config.cfg | 8 ++-- scripts/setup.sh | 85 +++++++++++++++++++++++++++------- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/profiles/default/config.cfg b/profiles/default/config.cfg index 3ac68f1..dc89869 100644 --- a/profiles/default/config.cfg +++ b/profiles/default/config.cfg @@ -32,18 +32,18 @@ ## Mandatory includes: [include user_profile.cfg] -[include print_macros.cfg] +[include printcfg/print_macros.cfg] ##################################### ## Optional includes: -[include print_extras.cfg] +[include printcfg/print_extras.cfg] ## Unstable Development: -#[include print_dev.cfg] +#[include printcfg/print_dev.cfg] ## Debugging tools: -[include print_debug.cfg] +#[include printcfg/print_debug.cfg] ## Please comment/uncomment any of the ## optional sections above that you would diff --git a/profiles/hephaestus/config.cfg b/profiles/hephaestus/config.cfg index 54c3b48..008c4d6 100644 --- a/profiles/hephaestus/config.cfg +++ b/profiles/hephaestus/config.cfg @@ -32,18 +32,18 @@ ## Mandatory includes: [include user_profile.cfg] -[include print_macros.cfg] +[include printcfg/print_macros.cfg] ##################################### ## Optional includes: -[include print_extras.cfg] +[include printcfg/print_extras.cfg] ## Unstable Development: -#[include print_dev.cfg] +#[include printcfg/print_dev.cfg] ## Debugging tools: -[include print_debug.cfg] +[include printcfg/print_debug.cfg] ## Please comment/uncomment any of the ## optional sections above that you would diff --git a/scripts/setup.sh b/scripts/setup.sh index 3e89d70..f8c1773 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -67,34 +67,83 @@ else fi fi -echo "Checking user profile..." - -# Check that user profile exists -if [ ! -f $user_vars ]; then - # Check if old user profile exists - if [ -f $old_user_vars ]; then - echo -e "\e[31mUser profile location is out of date.\e[0m" - echo "User profile will be moved to $config/user_profile.cfg" - mv $old_user_vars $user_vars - else - echo -e "\e[31mUser profile does not exist.\e[0m" - exit 1 - fi -fi - echo "Checking user config..." # Check that user config exists -if [ ! -f $user_cfg ]; then +if [ ! -f $user_cfg ] +then # Check if old user config exists - if [ -f $old_user_cfg ]; then + if [ -f $old_user_cfg ] + then echo -e "\e[31mUser config location is out of date.\e[0m" - echo "User config will be moved to $config/user_config.cfg" mv $old_user_cfg $user_cfg + # Verify move was successful + if [ -f $user_cfg ] + then + echo "User config moved to $config/user_config.cfg" + else + echo -e "\e[31mUser config move failed.\e[0m" + exit 1 + fi + # Check if old include line exists in printer.cfg + echo "Checking printer.cfg include line..." + if grep -qFx "[include printcfg/user_config.cfg]" "$printer" + then + echo -e "\e[31mInclude line is out of date.\e[0m" + # Remove old include line + sed -i '/\[include printcfg\/user_config.cfg\]/d' "$printer" + # Add new include line + sed -i '1s/^/[include user_config.cfg]\n/' "$printer" + # Verify include line was added + if grep -qFx "[include user_config.cfg]" "$printer" + then + echo "Include line updated." + # User config is up to date + echo -e "\e[32mUser config is now up to date.\e[0m" + else + echo -e "\e[31mInclude line update failed.\e[0m" + exit 1 + fi + else + if grep -qFx "[include user_config.cfg]" "$printer" + then + echo -e "\e[32mUser config is up to date.\e[0m" + else + echo -e "\e[31mInclude line does not exist.\e[0m" + exit 1 + fi + fi else echo -e "\e[31mUser config does not exist.\e[0m" exit 1 fi +else + # User config is up to date + echo -e "\e[32mUser config is up to date.\e[0m" +fi + +echo "Checking user profile..." + +# Check that user profile exists +if [ ! -f $user_vars ] +then + # Check if old user profile exists + if [ -f $old_user_vars ] + then + echo -e "\e[31mUser profile location is out of date.\e[0m" + mv $old_user_vars $user_vars + # Verify move was successful + if [ -f $user_vars ] + then + echo "User profile moved to $config/user_profile.cfg" + else + echo -e "\e[31mUser profile move failed.\e[0m" + exit 1 + fi + else + echo -e "\e[31mUser profile does not exist.\e[0m" + exit 1 + fi fi # Find version of user profile