-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-system
More file actions
executable file
·56 lines (50 loc) · 1.52 KB
/
update-system
File metadata and controls
executable file
·56 lines (50 loc) · 1.52 KB
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
#!/bin/bash
# Return the package name of the kernel currently in use
# (for determining whether the package has been updated
# and therefore a reboot is needed)
kernel_package() {
local USED_KERNEL=kernel
if uname -r |grep -q rc; then
USED_KERNEL=${USED_KERNEL}-rc
fi
if uname -r |grep -q server; then
USED_KERNEL=${USED_KERNEL}-server
else
USED_KERNEL=${USED_KERNEL}-desktop
fi
if uname -r |grep -q gcc; then
USED_KERNEL=${USED_KERNEL}-gcc
fi
# "custom" kernels have been built from the kernel-source
# package -- let's not mess with them, they don't get updated
# through package management
if uname -r |grep -q custom; then
USED_KERNEL=""
fi
# A kernel that doesn't have an OMV tag doesn't come from
# our packages (likely an upstream kernel built from source),
# so don't mess with that either
if ! uname -r |grep -q omv; then
USED_KERNEL=""
fi
echo $USED_KERNEL
}
if [ -e /etc/sysconfig/system-update ]; then
. /etc/sysconfig/system-update
fi
if [ -z "$KERNEL_PACKAGE" -a "$NO_REBOOT_ON_KERNEL_UPDATE" != "1" ]; then
KERNEL_PACKAGE="$(kernel_package)"
fi
if [ -n "$KERNEL_PACKAGE" ]; then
OLD_KERNELS="$(rpm -q $KERNEL_PACKAGE |sort)"
fi
[ -z "$NO_ALLOWERASING" ] && ALLOWERASING=--allowerasing
[ "$NO_INSTALL" = "1" ] && DOWNLOADONLY=--downloadonly
dnf -y --refresh $DOWNLOADONLY distro-sync $ALLOWERASING
if [ -n "$KERNEL_PACKAGE" ]; then
NEW_KERNELS="$(rpm -q $KERNEL_PACKAGE |sort)"
if [ "$OLD_KERNELS" != "$NEW_KERNELS" ]; then
echo "Rebooting because $KERNEL_PACKAGE has been updated"
reboot
fi
fi