-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
executable file
·63 lines (55 loc) · 1.16 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
#!/bin/bash
if [[ $EUID -eq 0 ]]; then
echo "This script must NOT be run as root"
exit 1
fi
# Debian
if hash apt-get &>/dev/null; then
sudo apt-get update
sudo apt list --upgradable
read -rp "Okay? Continue? [y/N] " go
if [[ $go != "y" && $go != "Y" ]]; then
exit 0
fi
sudo apt-get --yes upgrade
sudo apt-get --yes dist-upgrade
sudo apt-get --yes autoclean
sudo apt-get --yes autoremove
fi
# Fedora
if hash dnf &>/dev/null; then
sudo dnf upgrade --refresh
fi
# Flatpak
if hash flatpak &>/dev/null; then
sudo flatpak update
fi
# Rust
if hash rustup &>/dev/null; then
rustup update
fi
# Cargo
if hash cargo &>/dev/null; then
if ! cargo install-update --all; then
cargo install cargo-update
cargo install-update --all 2>/dev/null
fi
fi
# Kubectl krew
if hash kubectl krew &>/dev/null; then
kubectl krew update
kubectl krew upgrade
fi
# Check if reboot is required
if hash needs-restarting &>/dev/null; then
needs-restarting --reboothint
elif [ -f /var/run/reboot-required ]; then
read -rp "Reboot required, do it now? [y/N] " boot
if [[ $boot != "y" && $boot != "Y" ]]; then
exit 0
else
sudo systemctl reboot
fi
else
echo "Reboot not required."
fi