Skip to content

Commit

Permalink
Check Reboot
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-pickin-epi committed Dec 6, 2023
1 parent 380a5ba commit ae6244f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions bin/check_reboot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

VERSION=0.1

RedHat() {
OUTPUT=$(needs-restarting -r 2>&1)
case $? in
0) printf "%s\nVersion: %s." "$OUTPUT" "$VERSION"
exit 0
;;
1) printf "%s\nVersion: %s." "$OUTPUT" "$VERSION"
exit 2
;;
*) printf "%s\nVersion: %s." "$OUTPUT" "$VERSION"
exit 3
;;
esac
}

Debian() {
if [ -f /var/run/reboot-required ]
then
KERNEL=$(uname -r)
echo "Reboot Required. Version: $VERSION.";
echo "Current kernel: $KERNEL"
PKG=linux-$(echo $KERNEL | cut -d- -f3)
dpkg --status $PKG
exit 2
fi
echo "No Reboot Required. Version: $VERSION.";
exit 0
}

if [ -f /etc/redhat-release ]
then
RedHat
elif [ -f /etc/os-release ]
then
Debian
fi

echo "OS Type unknown. Version: $VERSION."
echo 3

0 comments on commit ae6244f

Please sign in to comment.