summaryrefslogtreecommitdiffstats
path: root/linhes/linhes-system/lh_restart_needed.sh
diff options
context:
space:
mode:
authorBritney Fransen <brfransen@gmail.com>2023-03-15 21:32:08 (GMT)
committerBritney Fransen <brfransen@gmail.com>2023-03-15 21:32:08 (GMT)
commit1c179b8b08dfedc9b58f72db33116cd5e5bac66c (patch)
tree1cd6f31de888709d45e3db79d85e56713ac3f13b /linhes/linhes-system/lh_restart_needed.sh
parentee18ce7f418ef89e89d79fe804550be9a4918780 (diff)
downloadlinhes_pkgbuild-1c179b8b08dfedc9b58f72db33116cd5e5bac66c.zip
linhes_pkgbuild-1c179b8b08dfedc9b58f72db33116cd5e5bac66c.tar.gz
linhes_pkgbuild-1c179b8b08dfedc9b58f72db33116cd5e5bac66c.tar.bz2
linhes-system: add lh_restart_needed.sh
Diffstat (limited to 'linhes/linhes-system/lh_restart_needed.sh')
-rwxr-xr-xlinhes/linhes-system/lh_restart_needed.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/linhes/linhes-system/lh_restart_needed.sh b/linhes/linhes-system/lh_restart_needed.sh
new file mode 100755
index 0000000..c939a28
--- /dev/null
+++ b/linhes/linhes-system/lh_restart_needed.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+get_boot_kernel() {
+ local get_version=0
+ for field in $(file /boot/vmlinuz*); do
+ if [[ $get_version -eq 1 ]]; then
+ echo $field
+ return
+ elif [[ $field == version ]]; then
+ # the next field contains the version
+ get_version=1
+ fi
+ done
+}
+
+rc=1
+
+libs=$(lsof -n +c 0 2> /dev/null | grep 'DEL.*lib' | awk '1 { print $1 ": " $NF }' | sort -u)
+if [[ -n $libs ]]; then
+ cat <<< $libs
+ echo "# LIBS: reboot required"
+ rc=0
+fi
+
+active_kernel=$(uname -r)
+current_kernel=$(get_boot_kernel)
+#echo $active_kernel
+#echo $current_kernel
+
+if [[ $active_kernel != $current_kernel ]]; then
+ echo "$active_kernel < $current_kernel"
+ echo "# KERNEL: reboot required"
+ rc=0
+fi
+exit $rc