Should work properly now

This commit is contained in:
René Fuhry 2023-04-03 19:18:43 +02:00 committed by GitHub
parent 9b66f59fc2
commit b587f13ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

29
update
View File

@ -4,7 +4,7 @@
source "$HOME"/.config/update.conf
VER="1.9"
VER="2.0.0"
IGREEN="\033[0;92m" # Intense Green
IYELLOW="\033[0;93m" # Intense Red
NC="\033[0m" # Text Reset
@ -27,11 +27,12 @@ Help() {
echo "-g shutdowns the computer afterwards"
echo "-r reboots the computer afterwards"
echo "--help displays this message"
echo "-P, --preview shows a preview of which pkg's can be updated"
echo "--preview shows a preview of which pkg's can be updated"
echo "--version prints out the version number"
}
check_for_dblck() {
while [ -f /var/lib/pacman/db.lck ]; do {
if [ -f /var/lib/pacman/db.lck ]; do {
echo -e "${IYELLOW}->${NC} /var/lib/pacman/db.lck exists"
echo -e "${IYELLOW}->${NC} there might be another instance of pacman running. exiting..."
exit 1
@ -65,13 +66,12 @@ after_backup() {
tar -cJf "$TMP"/after-backup_"$DATE".tar.xz.new "$TMP"/after-backup_"$DATE" &> /dev/null
cp "$TMP"/after-backup_"$DATE".tar.xz.new "$BACKUP_LOCATION"
rename after-backup_"$DATE".tar.xz.new after-backup_"$DATE".tar.xz "$BACKUP_LOCATION"/after-backup_"$DATE".tar.xz.new
[[ $FINAL_COMMAND ]] && sleep 3s && $FINAL_COMMAND && exit 0
}
update_with_pacman_wrapper() {
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
"$PACMAN_WRAPPER"
pacman -Q > "$TMP"/after-backup_"$DATE"/pacman-after.txt
after_backup && echo -e "${IGREEN}after-backup complete${NC}"
}
update_with_flatpak() {
@ -86,12 +86,7 @@ interrupt_function() {
exit 1
}
final() {
rm -r "$TMP" &> /dev/null
[[ $FINAL_COMMAND ]] && sleep 3s && $FINAL_COMMAND && exit 0
}
[[ $1 ]] || update_with_pacman_wrapper
[[ $1 ]] || before_backup && echo -e "${IGREEN}pre-backup complete${NC}" && update_with_pacman_wrapper
if [[ ${1:0:2} = -- ]]; then
case "${1:2}" in
help)
@ -104,30 +99,26 @@ if [[ ${1:0:2} = -- ]]; then
Help && exit 1;;
esac
else
before_backup && echo -e "${IGREEN}pre-backup complete${NC}"
while getopts 'fpagr' OPTIONS; do
case $OPTIONS in
P)
sudo pacman -Sy &> /dev/null && sudo pacman -Qu && exit 0;;
f)
update_with_flatpak;;
p)
update_with_pacman_wrapper ;;
a)
update_with_flatpak; update_with_pacman_wrapper ;;
update_with_pacman_wrapper; update_with_flatpak ;;
g)
[[ $1 = -g ]] && update_with_pacman_wrapper
FINAL_COMMAND="shutdown now" ;;
r)
[[ $1 = -r ]] && update_with_pacman_wrapper
FINAL_COMMAND="reboot" ;;
h)
Help && exit 0;;
V)
echo "$VER" && exit 0;;
?)
Help && exit 1;;
esac
done
fi
final
after_backup && echo -e "${IGREEN}after-backup complete${NC}"