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

fix iPkg2Update on empty package list

parent 05b8d8f9
Branches
No related tags found
1 merge request!20add sudo when calling yum
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
# 2021-12-17 v1.7 <axel.hahn@iml.unibe.ch> show non matching packages in section "other" # 2021-12-17 v1.7 <axel.hahn@iml.unibe.ch> show non matching packages in section "other"
# 2021-12-20 v1.8 <axel.hahn@iml.unibe.ch> show all packages if no filter matched # 2021-12-20 v1.8 <axel.hahn@iml.unibe.ch> show all packages if no filter matched
# 2022-06-03 v1.9 <axel.hahn@iml.unibe.ch> call yum with path; shellcheck updates; plugin like package managers # 2022-06-03 v1.9 <axel.hahn@iml.unibe.ch> call yum with path; shellcheck updates; plugin like package managers
# 2022-06-07 v1.10 <axel.hahn@iml.unibe.ch> fix iPkg2Update on empty package list
# rename package manager functions
# ====================================================================== # ======================================================================
...@@ -88,11 +90,17 @@ Get packages that must be updated on this system ...@@ -88,11 +90,17 @@ Get packages that must be updated on this system
Licence: GNU GPL 3 Licence: GNU GPL 3
______________________________________________________________________ ______________________________________________________________________
Get packages that must be updated on this system ans show found Get packages that must be updated on this system and show found
packages in groups. packages in groups.
For groups and their search filters see files in subdir RELATED FILES:
check_packages2install-data. 1) For groups and their search filters see files in subdir
check_packages2install-data.
2) In the subdir check_packages2install-pkgmanager are scripts
for supported package managers (with aded ".sh").
OUTPUT:
It returns UNKNOWN if package manager is not supported.
It returns OK if the system is up to date. It returns OK if the system is up to date.
It returns WARNING or ERROR if count of found pakackes is greater than It returns WARNING or ERROR if count of found pakackes is greater than
...@@ -111,13 +119,12 @@ $_self [options] ...@@ -111,13 +119,12 @@ $_self [options]
OPTIONS: OPTIONS:
-h show this help
-w custom warning level; default: $iWarnDefault -w custom warning level; default: $iWarnDefault
-c custom critical level; default: $iCriticalDefault -c custom critical level; default: $iCriticalDefault
PARAMETERS: PARAMETERS:
None. -h show this help
EOF EOF
} }
...@@ -153,7 +160,7 @@ function _detectPkgManager(){ ...@@ -153,7 +160,7 @@ function _detectPkgManager(){
function showFilteredPackages(){ function showFilteredPackages(){
# filtered package view # filtered package view
if [ ! -z "$packages2install" ]; then if [ -n "$packages2install" ]; then
typeset -i iTotal typeset -i iTotal
iTotal=$( echo "$packages2install" | wc -l ) iTotal=$( echo "$packages2install" | wc -l )
typeset -i iFound=0 typeset -i iFound=0
...@@ -194,7 +201,6 @@ function showFilteredPackages(){ ...@@ -194,7 +201,6 @@ function showFilteredPackages(){
# total packages # total packages
echo Total packages to install: $iTotal echo Total packages to install: $iTotal
ph.perfadd "updates-available" "$iTotal" ${iWarnLimit} ${iCriticalLimit}
fi fi
...@@ -224,7 +230,7 @@ fi ...@@ -224,7 +230,7 @@ fi
# load functions for the detected package manager # load functions for the detected package manager
. "${dir_pkg}/${pkgmanager}.sh" || exit 2 . "${dir_pkg}/${pkgmanager}.sh" || exit 2
packagemanOut=$( ${pkgmanager}GetUpdates ) packagemanOut=$( ${pkgmanager}.GetUpdates )
if [ -z "$packagemanOut" ]; then if [ -z "$packagemanOut" ]; then
ph.setStatus "critical" ph.setStatus "critical"
...@@ -232,9 +238,9 @@ if [ -z "$packagemanOut" ]; then ...@@ -232,9 +238,9 @@ if [ -z "$packagemanOut" ]; then
else else
# generated function names - package manager is prefix # generated function names - package manager is prefix
function2install="${pkgmanager}Packages" function2install="${pkgmanager}.getPackageList"
_functionExists "${pkgmanager}Status" && functionStatus="${pkgmanager}Status" _functionExists "${pkgmanager}.getStatusLine" && functionStatus="${pkgmanager}.getStatusLine"
_functionExists "${pkgmanager}Critical" && functionCritical="${pkgmanager}Critical" _functionExists "${pkgmanager}.getCriticalList" && functionCritical="${pkgmanager}.getCriticalList"
# count of packages ... to install ... critical (centos only) # count of packages ... to install ... critical (centos only)
typeset -i iPkg2Update=0 typeset -i iPkg2Update=0
...@@ -242,7 +248,7 @@ else ...@@ -242,7 +248,7 @@ else
# get list of packages 2 install # get list of packages 2 install
packages2install=$( $function2install ) packages2install=$( $function2install )
iPkg2Update=$( echo "$packages2install" | wc -l ) iPkg2Update=$( test -n "$packages2install" && echo "$packages2install" | wc -l )
# custom: status text # custom: status text
test -n "$functionStatus" && statusLabel="[$pkgmanager] $( $functionStatus )" test -n "$functionStatus" && statusLabel="[$pkgmanager] $( $functionStatus )"
...@@ -259,6 +265,7 @@ else ...@@ -259,6 +265,7 @@ else
else else
ph.setStatusByLimit ${iPkg2Update} ${iWarnLimit} ${iCriticalLimit} ph.setStatusByLimit ${iPkg2Update} ${iWarnLimit} ${iCriticalLimit}
fi fi
ph.perfadd "updates-available" "${iPkg2Update}" "${iWarnLimit}" "${iCriticalLimit}"
# set label for status line # set label for status line
if [ -z "$statusLabel" ]; then if [ -z "$statusLabel" ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment