Skip to content

Commit

Permalink
Merge pull request #79 from swampdogmash/patch-9
Browse files Browse the repository at this point in the history
Add check in case there ISN'T any update
  • Loading branch information
HenriWahl authored Jul 21, 2024
2 parents 51539e7 + 312909b commit 9cf5b4c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions agents/plugins/yum
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,24 @@ then
fi

# Check last time of installed Updates from yum history
# Added "list all" to the history command as in situations where 20 or more RPM installs have been completed (non updates
# yum commands) have been run, the script will incorrectly report that the server has never updated
# Yum only lists 20 of the last actions when using only the "history" command.
# Added "list all" to the history command as in situations where 20 or more RPM installs have been completed (non updates
# yum commands) have been run, the script will incorrectly report that the server has never updated
# Yum only lists 20 of the last actions when using only the "history" command.

# Switch command based on which Major version we are running
if [ "$MAJOR_VERSION" -ge 8 ]; then
LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history list | awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")

LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history list | awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")
else
LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history list all| awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")
fi
LAST_UPDATE_TIMESTAMP=$(/usr/bin/yum -C --quiet --noplugins history list all| awk '{if(NR>2)print}' | grep ' U \|Upgrade\|Update' | cut -d '|' -f3 | head -n 1 | date -f - +"%s" || echo "-1")
fi
# Add check in case this is a brand new built machine that has had
# up to date pacakges installed during build. In this case, neither
# command above will have yielded a value and LAST_UPDATE_TIMESTAMP
# will be empty

if [ "$LAST_UPDATE_TIMESTAMP" == "" ]; then LAST_UPDATE_TIMESTAMP=-1; fi


echo $BOOT_REQUIRED
echo $UPDATES
Expand Down

0 comments on commit 9cf5b4c

Please sign in to comment.