Skip to content
Snippets Groups Projects
Commit 0a3a484f authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch 'fix-check-update-debian' into 'master'

fix debian output on no reboot-required.pkgs

See merge request !41
parents edb41b4a 5cf33871
No related branches found
No related tags found
1 merge request!41fix debian output on no reboot-required.pkgs
...@@ -5,27 +5,81 @@ ...@@ -5,27 +5,81 @@
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# works for sure on # works for sure on
# - centos7 # - centos7,8
# - debian6,7 # - debian6..10
# - ubuntu10,12 # - ubuntu10,12
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2016-08-12 added ouput of packages # 2016-08-12 added ouput of packages
# 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions # 2020-03-05 v1.2 <axel.hahn@iml.unibe.ch> switch to ph.* helper functions
# 2022-10-14 v1.3 <axel.hahn@unibe.ch> fix debian output if /var/run/reboot-required.pkgs does not exist
# Shellfixes; add help
# ====================================================================== # ======================================================================
. `dirname $0`/inc_pluginfunctions . $(dirname $0)/inc_pluginfunctions
distro=`ph.getOS`
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=1.3
distro=$( ph.getOS )
# ----------------------------------------------------------------------
# functions
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
function showHelp(){
cat <<EOF
______________________________________________________________________
$self_APPNAME
v$self_APPVERSION
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
Check if a reboot is required.
It works for Centos and Debian/ Ubuntu.
If the reboot is required:
* On Centos it shows the kernel number that will be installed,
* On Debian7 Ubuntu it shows the packages that require the reboot,
SYNTAX:
$(basename $0)
OPTIONS:
-h or --help show this help.
PARAMETERS:
None.
EXAMPLE:
$(basename $0)
EOF
}
# ----------------------------------------------------------------------
# --- check param -h
case "$1" in
"--help"|"-h")
showHelp
exit 0
;;
*)
esac
case $distro in case $distro in
"centos") "centos")
currentkernel=`uname -r` currentkernel=$(uname -r)
out=`rpm -q --last kernel | head -1 | fgrep $currentkernel` out=$(rpm -q --last kernel | head -1 | fgrep $currentkernel)
if [ -z "$out" ]; then if [ -z "$out" ]; then
ph.setStatus "warning" ph.setStatus "warning"
ph.status "[$distro] need to reboot for kernel `rpm -q --last kernel | head -1` (current: $currentkernel)" ph.status "[$distro] need to reboot for kernel $(rpm -q --last kernel | head -1) (current: $currentkernel)"
else else
ph.status "[$distro] no reboot required (kernel is up to date: $currentkernel)" ph.status "[$distro] no reboot required (kernel is up to date: $currentkernel)"
fi fi
...@@ -36,8 +90,10 @@ case $distro in ...@@ -36,8 +90,10 @@ case $distro in
if [ ! -f /var/run/reboot-required ]; then if [ ! -f /var/run/reboot-required ]; then
ph.status "[$distro] no reboot required" ph.status "[$distro] no reboot required"
else else
byPackages="(I do not know the package that requires it)"
test -f /var/run/reboot-required.pkgs && byPackages="by $( tr '\n' ',' < /var/run/reboot-required.pkgs )"
ph.setStatus "warning" ph.setStatus "warning"
ph.status "[$distro] `cat /var/run/reboot-required` by `tr '\n' ',' </var/run/reboot-required.pkgs`" ph.status "[$distro] $( cat /var/run/reboot-required ) ${byPackages}"
fi fi
;; ;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment