-
Notifications
You must be signed in to change notification settings - Fork 5
/
eos-reboot-required2
executable file
·84 lines (74 loc) · 2.47 KB
/
eos-reboot-required2
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
#!/bin/bash
# Avoid unnecessary reboots: don't notify if an updated package is
# - not currently running (e.g. alternative kernel)
# - not in use (e.g. alternative driver)
IsRunningKernel() {
if [ -z "$running_kernel" ] ; then
running_kernel=$(eos_running_kernel)
fi
test "$1" = "$running_kernel"
}
DoNotify() {
local logfile=/var/log/reboot-recommendation-trigger.log
echo "[$(/bin/date "+%x %X")] Reboot recommendation triggered by updating package: $target" > $logfile
chmod o-rwx $logfile
systemctl enable --now eos-reboot-required.timer 2>/dev/null
sleep 1
exit 0
}
Main() {
[ "$EUID" = "0" ] || return 0 # require elevated privileges
source /usr/share/endeavouros/scripts/eos-script-lib-yad --limit-icons || return 0
eos_is_in_chroot && return 0
[ "$EOS_REBOOT_RECOMMENDING" = "no" ] && return 0
local targets=$(cat) # list of updated package names from the hook (stdin)
local target
local running_kernel=""
# do not notify if the updated package is not in use
for target in $targets ; do
case "$target" in
linux | linux-lts | linux-zen | linux-hardened | linux-rt | linux-rt-lts | linux-lts?? | linux-lts???)
# Note: only official and older LTS kernels are checked.
if IsRunningKernel "$target" ; then
DoNotify
fi
;;
nvidia)
if IsRunningKernel linux ; then
DoNotify
fi
;;
nvidia-lts)
if IsRunningKernel linux-lts ; then
DoNotify
fi
;;
amd-ucode)
if [ "$(device-info --cpu)" = "AuthenticAMD" ] ; then
DoNotify
fi
;;
intel-ucode)
if [ "$(device-info --cpu)" = "GenuineIntel" ] ; then
DoNotify
fi
;;
btrfs-progs)
# Notify only if btrfs is in use
if [ -n "$(/usr/bin/df -hT | awk '{print $2}' | grep -w btrfs)" ] ; then
DoNotify
fi
;;
wayland | egl-wayland)
case "$XDG_SESSION_TYPE" in
x11) ;;
*) DoNotify ;;
esac
;;
*)
DoNotify
;;
esac
done
}
Main "$@"