move check for backup location to function
This commit is contained in:
		
							
								
								
									
										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
 | 
			
		||||
 | 
			
		||||
if [ ! -d $BACKUP_LOCATION ]; then
 | 
			
		||||
    echo -e "${IYELLOW}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 "$BACKUP_LOCATION" ;;
 | 
			
		||||
        [Nn]) exit 0;;
 | 
			
		||||
        * ) exit 0 ;;
 | 
			
		||||
    esac
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ $SECONDARY_BACKUP_LOCATION ]; then 
 | 
			
		||||
    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
 | 
			
		||||
check_for_valid_backup_location() {
 | 
			
		||||
    if [ $1 ]; then 
 | 
			
		||||
        if [ ! -d $1 ]; then
 | 
			
		||||
            echo -e "${IYELLOW}$1 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 "$1" ;;
 | 
			
		||||
                [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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -8,4 +8,4 @@ BACKUP_LOCATION=~
 | 
			
		||||
PACMAN_WRAPPER=yay
 | 
			
		||||
 | 
			
		||||
# how many different backups to keep
 | 
			
		||||
BACKUP_AMOUNT=2
 | 
			
		||||
BACKUP_AMOUNT=10
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user