-
Notifications
You must be signed in to change notification settings - Fork 0
/
update
executable file
·122 lines (107 loc) · 3.37 KB
/
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
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
set -u -o pipefail
# set -e # Do not exit if one command failed
# set -x # Only for debugging
update_container_images() {
echo "[+] Updating container images..."
images=(
'registry.fedoraproject.org/fedora:latest'
'docker.io/antora/antora:latest'
'quay.io/coreos-assembler/coreos-assembler:latest'
)
for img in "${images[@]}"; do
if $(podman image exists "${img}"); then
podman pull "${img}"
fi
done
for img in $(podman images --filter dangling=true --format "{{.ID}}"); do
podman rmi "${img}"
done
echo "[+] Done"
}
update_firmwares() {
echo "[+] Updating firmwares..."
sudo fwupdmgr refresh
sudo fwupdmgr update
echo "[+] Done"
}
update_toolboxes() {
echo "[+] Updating toolboxes..."
# Only update toolbox images currently in use
for img in $(podman images -n --format "{{.Repository}}" | grep "quay.io/travier/toolbox"); do
podman pull "${img}"
local name="${img%:*}"
name="${name##*/}"
toolbox rm --force "${name}" || true
toolbox create --image "${img}" "${name}"
done
for img in $(podman images --filter dangling=true --format "{{.ID}}"); do
podman rmi "${img}"
done
}
update_root_toolboxes() {
echo "[+] Updating rootful toolboxes..."
if [[ -f "/run/.containerenv" ]]; then
echo "[+] Can not (yet) update rootful toolboxes from a rootless container."
return
fi
# Only update toolbox images currently in use
# TODO: Force quay.io/travier/toolbox-root
for img in $(sudo podman images -n --format "{{.Repository}}" | grep "quay.io/travier/toolbox"); do
sudo podman pull "${img}"
local name="${img%:*}"
name="${name##*/}"
sudo toolbox rm --force "${name}" || true
sudo toolbox create --image "${img}" "${name}"
done
for img in $(sudo podman images --filter dangling=true --format "{{.ID}}"); do
sudo podman rmi "${img}"
done
}
main() {
local SYSTEM=false
if [[ "${#}" -gt 0 ]]; then
case "${1}" in
"s"|"sys"|"system")
SYSTEM=true
;;
esac
case "${1}" in
"c"|"cont"|"container")
update_container_images
exit 0
;;
esac
case "${1}" in
"f"|"firm"|"firmware")
update_firmwares
exit 0
;;
esac
case "${1}" in
"t"|"tb"|"tbx"|"toolbox")
update_toolboxes
exit 0
;;
esac
fi
if [[ "${SYSTEM}" == true ]]; then
echo "[+] Updating system (rpm-ostree)..."
rpm-ostree update
echo "[+] Updating system Flatpaks..."
flatpak --system update --assumeyes
flatpak --system remove --unused --assumeyes
fi
# Use a fixed toolbox to avoid issues during a Fedora major version rebase
local -r toolbox="toolbox"
# echo "[+] Updating main toolbox..."
# toolbox run --container "${toolbox}" sudo dnf update -y
echo "[+] Updating Rust crates..."
rustup update
toolbox run --container "${toolbox}" ~/.cargo/bin/cargo install-update -a
# toolbox run --container "${toolbox}" ~/.cargo/bin/cargo cache -a
update_container_images
update_toolboxes
echo "[+] Done"
}
main "${@}"