Skip to content
Snippets Groups Projects

add sudo when calling yum

Merged Hahn Axel (hahn) requested to merge 5419-update-check-packages2install into master
1 file
+ 19
12
Compare changes
  • Side-by-side
  • Inline
+ 19
12
@@ -21,6 +21,8 @@
# 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
# 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
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.
For groups and their search filters see files in subdir
check_packages2install-data.
RELATED FILES:
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 WARNING or ERROR if count of found pakackes is greater than
@@ -111,13 +119,12 @@ $_self [options]
OPTIONS:
-h show this help
-w custom warning level; default: $iWarnDefault
-c custom critical level; default: $iCriticalDefault
PARAMETERS:
None.
-h show this help
EOF
}
@@ -153,7 +160,7 @@ function _detectPkgManager(){
function showFilteredPackages(){
# filtered package view
if [ ! -z "$packages2install" ]; then
if [ -n "$packages2install" ]; then
typeset -i iTotal
iTotal=$( echo "$packages2install" | wc -l )
typeset -i iFound=0
@@ -194,7 +201,6 @@ function showFilteredPackages(){
# total packages
echo Total packages to install: $iTotal
ph.perfadd "updates-available" "$iTotal" ${iWarnLimit} ${iCriticalLimit}
fi
@@ -224,7 +230,7 @@ fi
# load functions for the detected package manager
. "${dir_pkg}/${pkgmanager}.sh" || exit 2
packagemanOut=$( ${pkgmanager}GetUpdates )
packagemanOut=$( ${pkgmanager}.GetUpdates )
if [ -z "$packagemanOut" ]; then
ph.setStatus "critical"
@@ -232,9 +238,9 @@ if [ -z "$packagemanOut" ]; then
else
# generated function names - package manager is prefix
function2install="${pkgmanager}Packages"
_functionExists "${pkgmanager}Status" && functionStatus="${pkgmanager}Status"
_functionExists "${pkgmanager}Critical" && functionCritical="${pkgmanager}Critical"
function2install="${pkgmanager}.getPackageList"
_functionExists "${pkgmanager}.getStatusLine" && functionStatus="${pkgmanager}.getStatusLine"
_functionExists "${pkgmanager}.getCriticalList" && functionCritical="${pkgmanager}.getCriticalList"
# count of packages ... to install ... critical (centos only)
typeset -i iPkg2Update=0
@@ -242,7 +248,7 @@ else
# get list of packages 2 install
packages2install=$( $function2install )
iPkg2Update=$( echo "$packages2install" | wc -l )
iPkg2Update=$( test -n "$packages2install" && echo "$packages2install" | wc -l )
# custom: status text
test -n "$functionStatus" && statusLabel="[$pkgmanager] $( $functionStatus )"
@@ -259,6 +265,7 @@ else
else
ph.setStatusByLimit ${iPkg2Update} ${iWarnLimit} ${iCriticalLimit}
fi
ph.perfadd "updates-available" "${iPkg2Update}" "${iWarnLimit}" "${iCriticalLimit}"
# set label for status line
if [ -z "$statusLabel" ]; then
Loading