-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
74 lines (62 loc) · 1.65 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# Arch-based
if [ ! -f /etc/arch-release ]; then
echo "This script only works on Arch-based systems."
exit 1
fi
# function to check if a package is installed
pkg_installed() {
pacman -Qq "$1" &> /dev/null
}
# function to perform updates
update_system() {
echo "Starting the system update..."
# Update Official packages
echo "Updating Official packages..."
sudo pacman -Syu
# Update AUR packages
if pkg_installed yay; then
echo "Updating AUR packages using yay..."
yay -Syu
elif pkg_installed paru; then
echo "Updating AUR packages using paru..."
paru -Syu
else
echo "AUR helper not installed, skipping AUR updates."
fi
# Update Flatpak packages
if pkg_installed flatpak; then
echo "Updating Flatpak packages..."
flatpak update
else
echo "Flatpak not installed, skipping Flatpak updates."
fi
echo "System update completed."
}
# check for Official updates
ofc=$( (while pgrep -x checkupdates > /dev/null ; do sleep 1; done) ; checkupdates | wc -l)
# Check for AUR updates
if pkg_installed yay; then
aur=$(yay -Qua | wc -l)
elif pkg_installed paru; then
aur=$(paru -Qua | wc -l)
else
aur="AUR helper not installed"
fi
# Check for Flatpak updates
if pkg_installed flatpak; then
fpk=$(flatpak remote-ls --updates | wc -l)
else
fpk="Flatpak not installed"
fi
# Output the update status
echo "[Official] $ofc"
echo "[AUR] $aur"
echo "[Flatpak] $fpk"
# ask user
read -p "Do you want to update the system? (Y/N): " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
update_system
else
echo "Update canceled."
fi