-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreboot-check
executable file
·28 lines (26 loc) · 963 Bytes
/
reboot-check
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
#!/usr/bin/env 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)
targets=$(tee /dev/null) # targets from the hook (stdin)
kernelname="$(grep -oP '\(\K.*(?=@.*\))' /proc/version)"
for target in $targets ; do
case "$target" in
"$kernelname")
notify=yes ;;
nvidia)
[ "$kernelname" = "linux" ] && notify=yes ;;
nvidia-lts)
[ "$kernelname" = "linux-lts" ] && notify=yes ;;
linux-cachyos-nvidia*)
[[ "$kernelname" = linux-cachyos* ]] && notify=yes ;;
btrfs-progs)
[ -n "$(mount -t btrfs)" ] && notify=yes ;;
xfsprogs)
[ -n "$(mount -t xfs)" ] && notify=yes ;;
e2fsprogs)
[ -n "$(mount -t ext4)" ] && notify=yes ;;
*) notify=yes ;;
esac
done
[ -n "$notify" ] && exec /usr/local/bin/reboot-notify