This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 286
/
Copy pathsystem_update
executable file
·112 lines (107 loc) · 3.24 KB
/
system_update
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
# Perform system upgrade via apt
function update_system {
echo_message title "Performing system update..."
# Draw window
if (whiptail --title "System Update" --yesno "Check for system software updates?" 8 56) then
# Update repository information
echo_message info 'Refreshing repository information...'
# Admin privileges
superuser_do 'apt update -y -qq'
echo_message success 'Repository information updated.'
# List upgrades
if [ $(apt list --upgradeable | wc -l) = 1 ]; then
# Cancelled
echo_message info "System is up to date."
whiptail --title "Finished" --msgbox "No updates available. System is up to date." 8 56
system_update
else
# Move on to package upgrade
if (eval `resize` && whiptail \
--title "System Upgrade" \
--yesno "Current list of packages to be updated: \n\n$(apt list --upgradeable | sed 's/\/.*//;/^Listing.../d') \n\nAre you sure you want proceed?" \
$LINES $COLUMNS $(( $LINES - 12 )) \
--scrolltext ) then
# Upgrade
echo_message info 'Upgrading packages...'
superuser_do "apt dist-upgrade -y"
# Finished
echo_message success "System update complete."
whiptail --title "Finished" --msgbox "System update complete." 8 56
system_update
else
# Cancelled
echo_message info "System update cancelled."
system_update
fi
fi
else
# Cancelled
echo_message info "Installation of ${2} cancelled."
system_update
fi
}
# Check for snap updates
function update_snap_apps {
# check if flatpak is installed
check_package "snapd" system_update
# continue
echo_message info "Updating installed snap packages..."
superuser_do "snap refresh"
if [ $? = 0 ]; then
# Finished
echo_message success "All snaps up to date."
whiptail --title "Finished" --msgbox "All snaps up to date." 8 56
system_update
else
# Finished
echo_message success "Snap package update complete."
whiptail --title "Finished" --msgbox "Snap package update complete." 8 56
system_update
fi
}
# Check for flatpak updates
function update_flatpak_apps {
# check if flatpak is installed
check_package "flatpak" system_update
# continue
echo_message info "Updating installed flatpak packages..."
flatpak update
if [ $? = 0 ]; then
# Finished
echo_message success "All flatpaks up to date."
whiptail --title "Finished" --msgbox "All flatpaks up to date." 8 56
system_update
else
# Finished
echo_message success "Flatpak package update complete."
whiptail --title "Finished" --msgbox "Flatpak package update complete." 8 56
system_update
fi
}
# Perform system updates
function system_update {
# install
echo_message title "Starting system updates..."
# Draw window
UPDATE=$(eval `resize` && whiptail \
--notags \
--title "Install $NAME" \
--menu "\nWhat ${NAME,,} would you like to install?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'update_system' 'Check for system updates' \
'update_snap_apps' 'Check for Snap app updates' \
'update_flatpak_apps' 'Check for Flatpak app updates' \
3>&1 1>&2 2>&3)
# check exit status
if [ $? = 0 ]; then
echo_message header "Starting '$UPDATE' function..."
$UPDATE
else
# Cancelled
echo_message info "System updates cancelled."
main
fi
}