#!/bin/bash

CONFIG="~/config/.uppy.conf"
# Colors
RED='\033[0;31m'
LRED="\033[1;31m"
BLUE="\033[0;34m"
LBLUE="\033[1;34m"
GREEN="\033[0;32m"
LGREEN="\033[1;32m"
YELLOW="\033[1;33m"
CYAN="\033[0;36m"
LCYAN="\033[1;36m"
PURPLE="\033[0;35m"
LPURPLE="\033[1;35m"
BWHITE="\e[1m"
NC='\033[0m' # No Color

if [ ! -f /usr/bin/apt ];then
    echo -e "${LRED}Apt is missing!..exiting!${NC}\n"
    exit 1
fi


if [ ! -f ${CONFIG} ];then
    echo -e "${LBLUE}Creating config in ${CONFIG}${NC}\n"
    touch ${CONFIG}
fi

if grep -Fxq "AUTOCONFIRM='true'" ${CONFIG};then
    AUTO="yes"

else

    echo -n "Do you want to skip confirmations?[n/Y]"
    read confirm
    if [  "${confirm}" = "y" ];then

        echo "AUTOCONFIRM='true'" > ${CONFIG}
        
    fi
fi


echo -e "${LBLUE}Checking Sources...${NC}\n"

sudo apt update

echo -e "${LBLUE}Starting Upgrade...${NC}\n"

if [ "${AUTO}" = "yes" ];then

sudo apt -y upgrade

else

sudo apt upgrade

fi

