🐛 fix(_bump): upgradation lst

This commit is contained in:
eshanized
2024-12-22 02:24:07 +05:30
parent 542e80f524
commit 8b83f336f0

View File

@@ -37,6 +37,7 @@ show_help() {
echo -e " ${GREEN}-v, --verbose${RESET} enable verbose output." echo -e " ${GREEN}-v, --verbose${RESET} enable verbose output."
echo -e " ${GREEN}-d, --dry-run${RESET} show what would be done without making changes." echo -e " ${GREEN}-d, --dry-run${RESET} show what would be done without making changes."
echo -e " ${GREEN}-b, --backup${RESET} backup important configuration files before updating." echo -e " ${GREEN}-b, --backup${RESET} backup important configuration files before updating."
echo -e " ${GREEN}-u, --upgrade${RESET} upgrade the system."
echo -e "" echo -e ""
# provide usage examples for the user # provide usage examples for the user
echo -e "${YELLOW}example usage:${RESET}" echo -e "${YELLOW}example usage:${RESET}"
@@ -44,12 +45,14 @@ show_help() {
echo -e " $0 -v # run in verbose mode." echo -e " $0 -v # run in verbose mode."
echo -e " $0 -d # dry run (preview only)." echo -e " $0 -d # dry run (preview only)."
echo -e " $0 -b # backup configuration files before updating." echo -e " $0 -b # backup configuration files before updating."
echo -e " $0 -u # upgrade the system."
} }
# parse command line options for verbose, dry-run, and backup flags # parse command line options for verbose, dry-run, and backup flags
VERBOSE=false # default to false, verbose output is off VERBOSE=false # default to false, verbose output is off
DRY_RUN=false # default to false, dry-run mode is off DRY_RUN=false # default to false, dry-run mode is off
BACKUP=false # default to false, backup is not done by default BACKUP=false # default to false, backup is not done by default
UPGRADE=false # default to false, upgrade is off
while [[ "$1" != "" ]]; do # loop through each command-line argument while [[ "$1" != "" ]]; do # loop through each command-line argument
case $1 in case $1 in
@@ -57,6 +60,7 @@ while [[ "$1" != "" ]]; do # loop through each command-line argument
-v|--verbose) VERBOSE=true ;; # if -v or --verbose is passed, enable verbose mode -v|--verbose) VERBOSE=true ;; # if -v or --verbose is passed, enable verbose mode
-d|--dry-run) DRY_RUN=true ;; # if -d or --dry-run is passed, enable dry-run mode -d|--dry-run) DRY_RUN=true ;; # if -d or --dry-run is passed, enable dry-run mode
-b|--backup) BACKUP=true ;; # if -b or --backup is passed, enable backup option -b|--backup) BACKUP=true ;; # if -b or --backup is passed, enable backup option
-u|--upgrade) UPGRADE=true ;; # if -u or --upgrade is passed, enable upgrade option
*) echo -e "${RED}❌ invalid option: $1${RESET}"; show_help; exit 1 ;; # handle invalid options *) echo -e "${RED}❌ invalid option: $1${RESET}"; show_help; exit 1 ;; # handle invalid options
esac esac
shift # move to the next argument shift # move to the next argument
@@ -110,6 +114,8 @@ backup_config_files() {
# log the start of the script # log the start of the script
echo -e "$(date) - starting update process" >> $LOG_FILE # log the start with timestamp echo -e "$(date) - starting update process" >> $LOG_FILE # log the start with timestamp
# if the user chooses to upgrade the system
if $UPGRADE; then
# update the package database and upgrade packages # update the package database and upgrade packages
echo -e "${BLUE}🔄 updating the package database...${RESET}" echo -e "${BLUE}🔄 updating the package database...${RESET}"
if $VERBOSE; then # if verbose mode is enabled if $VERBOSE; then # if verbose mode is enabled
@@ -129,6 +135,7 @@ else
sudo pacman -Su --noconfirm || error_handler $LINENO # upgrade normally sudo pacman -Su --noconfirm || error_handler $LINENO # upgrade normally
fi fi
fi fi
fi
# clean up orphaned packages # clean up orphaned packages
echo -e "${BLUE}🧹 cleaning up orphaned packages...${RESET}" echo -e "${BLUE}🧹 cleaning up orphaned packages...${RESET}"