Skip to content

Commit

Permalink
check for and move user file locations
Browse files Browse the repository at this point in the history
  • Loading branch information
rootiest committed May 20, 2023
1 parent 405b98c commit e649961
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 26 deletions.
8 changes: 4 additions & 4 deletions profiles/default/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions profiles/hephaestus/config.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
85 changes: 67 additions & 18 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e649961

Please sign in to comment.