Minor code improvement
This commit is contained in:
parent
3a976e50b5
commit
792504c4fc
34
update
34
update
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
source "$HOME"/.config/update.conf
|
source "$HOME"/.config/update.conf
|
||||||
|
|
||||||
VER="2.0.1"
|
VER="2.0.2"
|
||||||
IGREEN="\033[0;92m" # Intense Green
|
IGREEN="\033[0;92m" # Intense Green
|
||||||
IYELLOW="\033[0;93m" # Intense Red
|
IYELLOW="\033[0;93m" # Intense Red
|
||||||
NC="\033[0m" # Text Reset
|
NC="\033[0m" # Text Reset
|
||||||
@ -16,6 +16,13 @@ FINAL_COMMAND=""
|
|||||||
|
|
||||||
trap interrupt_function INT
|
trap interrupt_function INT
|
||||||
|
|
||||||
|
interrupt_function() {
|
||||||
|
echo "Interrupt has been detected"
|
||||||
|
sudo rm /var/lib/pacman/db.lck &> /dev/null
|
||||||
|
rm -r "$TMP" &> /dev/null
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
Help() {
|
Help() {
|
||||||
echo "Usage: update [OPTION]"
|
echo "Usage: update [OPTION]"
|
||||||
echo
|
echo
|
||||||
@ -79,29 +86,25 @@ update_with_flatpak() {
|
|||||||
flatpak list > "$TMP"/after-backup_"$DATE"/flatpak-after.txt
|
flatpak list > "$TMP"/after-backup_"$DATE"/flatpak-after.txt
|
||||||
}
|
}
|
||||||
|
|
||||||
interrupt_function() {
|
|
||||||
echo "Interrupt has been detected"
|
|
||||||
sudo rm /var/lib/pacman/db.lck &> /dev/null
|
|
||||||
rm -r "$TMP" &> /dev/null
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
[[ -z $1 ]] && before_backup && echo -e "${IGREEN}pre-backup complete${NC}" && update_with_pacman_wrapper
|
[[ -z $1 ]] && before_backup && echo -e "${IGREEN}pre-backup complete${NC}" && update_with_pacman_wrapper
|
||||||
|
|
||||||
if [[ ${1:0:2} = -- ]]; then
|
if [[ ${1:0:2} = -- ]]; then
|
||||||
case "${1:2}" in
|
case "${1:2}" in
|
||||||
help)
|
help)
|
||||||
Help && exit 0;;
|
Help ;;
|
||||||
preview)
|
preview)
|
||||||
sudo pacman -Sy &> /dev/null && sudo pacman -Qu && exit 0;;
|
sudo pacman -Sy &> /dev/null && sudo pacman -Qu ;;
|
||||||
version)
|
version)
|
||||||
echo "$VER" && exit 0;;
|
echo "$VER" ;;
|
||||||
?)
|
?)
|
||||||
Help && exit 1;;
|
Help && exit 1;;
|
||||||
esac
|
esac
|
||||||
else
|
exit 0
|
||||||
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
|
fi
|
||||||
|
|
||||||
while getopts 'fpagr' OPTIONS; do
|
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
|
||||||
|
|
||||||
|
while getopts 'fpagr' OPTIONS; do
|
||||||
case $OPTIONS in
|
case $OPTIONS in
|
||||||
f)
|
f)
|
||||||
update_with_flatpak;;
|
update_with_flatpak;;
|
||||||
@ -118,7 +121,6 @@ else
|
|||||||
?)
|
?)
|
||||||
Help && exit 1;;
|
Help && exit 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
after_backup && echo -e "${IGREEN}after-backup complete${NC}"
|
after_backup && echo -e "${IGREEN}after-backup complete${NC}"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user