Skip to content

Commit

Permalink
Added OS Security updates (for YUM only so far)
Browse files Browse the repository at this point in the history
Added OS Security updates (for YUM only so far)

Added OS Security updates (for YUM only so far)

Added OS Security updates (for YUM only so far)

Added OS Security updates (for YUM only so far)

Added OS Security updates (for YUM only so far)
  • Loading branch information
wimg committed Aug 8, 2021
1 parent 5444de8 commit 43ebbd0
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions snmp/osupdate
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BIN_ZYPPER='/usr/bin/env zypper'
CMD_ZYPPER='-q lu'
BIN_YUM='/usr/bin/env yum'
CMD_YUM='-q check-update'
CMD_YUM_SEC='-q updateinfo list sec'
BIN_DNF='/usr/bin/env dnf'
CMD_DNF='-q check-update'
BIN_APT='/usr/bin/env apt-get'
Expand All @@ -37,63 +38,68 @@ if command -v zypper &>/dev/null ; then
# shellcheck disable=SC2086
UPDATES=$($BIN_ZYPPER $CMD_ZYPPER | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 2 ]; then
echo $(($UPDATES-2));
echo $(($UPDATES-2)),Null;
else
echo "0";
echo "0,Null";
fi
elif command -v dnf &>/dev/null ; then
# Fedora
# shellcheck disable=SC2086
UPDATES=$($BIN_DNF $CMD_DNF | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 1 ]; then
echo $(($UPDATES-1));
echo $(($UPDATES-1)),Null;
else
echo "0";
echo "0,Null";
fi
elif command -v pacman &>/dev/null ; then
# Arch
UPDATES=$($BIN_PACMAN $CMD_PACMAN | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 1 ]; then
echo $(($UPDATES-1));
echo $(($UPDATES-1)),Null;
else
echo "0";
echo "0,Null";
fi
elif command -v yum &>/dev/null ; then
# CentOS / Redhat
# shellcheck disable=SC2086
UPDATES=$($BIN_YUM $CMD_YUM | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 1 ]; then
echo $(($UPDATES-1));
UPDATES_SEC=$($BIN_YUM $CMD_YUM_SEC | $BIN_WC $CMD_WC)
if [ "$UPDATES_SEC" -ge 1 ]; then
echo $(($UPDATES)),$(($UPDATES_SEC));
else
echo $(($UPDATES)),Null;
fi
else
echo "0";
echo "0,Null";
fi
elif command -v apt-get &>/dev/null ; then
# Debian / Devuan / Ubuntu
# shellcheck disable=SC2086
UPDATES=$($BIN_APT $CMD_APT | $BIN_GREP $CMD_GREP 'Inst')
if [ "$UPDATES" -ge 1 ]; then
echo "$UPDATES";
echo $(($UPDATES)),Null;
else
echo "0";
echo "0,Null";
fi
elif command -v pkg &>/dev/null ; then
# FreeBSD
# shellcheck disable=SC2086
UPDATES=$($BIN_PKG $CMD_PKG | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 1 ]; then
echo "$UPDATES";
echo $(($UPDATES)),Null;
else
echo "0";
echo "0,Null";
fi
elif command -v apk &>/dev/null ; then
# Alpine
# shellcheck disable=SC2086
UPDATES=$($BIN_APK $CMD_APK | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 2 ]; then
echo $(($UPDATES-1));
echo $(($UPDATES-1)),Null;
else
echo "0";
echo "0,Null";
fi
else
echo "0";
echo "0,Null";
fi

0 comments on commit 43ebbd0

Please sign in to comment.