move check for backup location to function
This commit is contained in:
parent
8b5704f397
commit
6593f087c4
35
update
35
update
@ -9,27 +9,22 @@ DATE="$(date +"%Y-%m-%dT%H:%M:%S%:z")" # RFC 3339 date-time https://datatracker
|
|||||||
|
|
||||||
source "$HOME"/.config/update.conf || exit 1
|
source "$HOME"/.config/update.conf || exit 1
|
||||||
|
|
||||||
if [ ! -d $BACKUP_LOCATION ]; then
|
check_for_valid_backup_location() {
|
||||||
echo -e "${IYELLOW}Backup location doesn't exist${NO_COLOR}"
|
if [ $1 ]; then
|
||||||
read -p "Do you want to create the path and continue? [y/N]" input
|
if [ ! -d $1 ]; then
|
||||||
case $input in
|
echo -e "${IYELLOW}$1 doesn't exist${NO_COLOR}"
|
||||||
[Yy]) mkdir --parents "$BACKUP_LOCATION" ;;
|
read -p "Do you want to create the path and continue? [y/N]" input
|
||||||
[Nn]) exit 0;;
|
case $input in
|
||||||
* ) exit 0 ;;
|
[Yy]) mkdir --parents "$1" ;;
|
||||||
esac
|
[Nn]) exit 0;;
|
||||||
fi
|
* ) exit 0 ;;
|
||||||
|
esac
|
||||||
if [ $SECONDARY_BACKUP_LOCATION ]; then
|
fi
|
||||||
if [ ! -d $SECONDARY_BACKUP_LOCATION ]; then
|
|
||||||
echo -e "${IYELLOW}Secondary Backup location doesn't exist${NO_COLOR}"
|
|
||||||
read -p "Do you want to create the path and continue? [y/N]" input
|
|
||||||
case $input in
|
|
||||||
[Yy]) mkdir --parents "$SECONDARY_BACKUP_LOCATION" ;;
|
|
||||||
[Nn]) exit 0;;
|
|
||||||
* ) exit 0 ;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
|
||||||
|
check_for_valid_backup_location "$BACKUP_LOCATION"
|
||||||
|
check_for_valid_backup_location "$SECONDARY_BACKUP_LOCATION"
|
||||||
|
|
||||||
trap interrupt_function INT
|
trap interrupt_function INT
|
||||||
|
|
||||||
|
@ -8,4 +8,4 @@ BACKUP_LOCATION=~
|
|||||||
PACMAN_WRAPPER=yay
|
PACMAN_WRAPPER=yay
|
||||||
|
|
||||||
# how many different backups to keep
|
# how many different backups to keep
|
||||||
BACKUP_AMOUNT=2
|
BACKUP_AMOUNT=10
|
||||||
|
Loading…
Reference in New Issue
Block a user