fixed updates not displaying

This commit is contained in:
pyr0ball 2023-03-08 13:25:19 -08:00
parent 3983cf6721
commit 5d829b31d8

View file

@ -42,44 +42,43 @@ cache=$(echo "${cachefile_location}/${cachefile}")
################################ ################################
quickinfo-cache (){ quickinfo-cache (){
#check for updates # Uses a wide variety of methods to check which distro this is run on
packages_cache=$(/usr/lib/update-notifier/apt-check --human-readable | grep "can be") if type lsb_release >/dev/null 2>&1; then
supdates_cache=$(/usr/lib/update-notifier/apt-check --human-readable | grep "security updates") # linuxbase.org
# Uses a wide variety of methods to check which distro this is run on OS=$(lsb_release -si)
if type lsb_release >/dev/null 2>&1; then VER=$(lsb_release -sr)
# linuxbase.org elif [ -f /etc/debian_version ]; then
OS=$(lsb_release -si) # Older Debian/Ubuntu/etc.
VER=$(lsb_release -sr) OS=Debian
elif [ -f /etc/debian_version ]; then VER=$(cat /etc/debian_version)
# Older Debian/Ubuntu/etc. elif [ -f /etc/os-release ]; then
OS=Debian # freedesktop.org and systemd
VER=$(cat /etc/debian_version) . /etc/os-release
elif [ -f /etc/os-release ]; then OS=$NAME
# freedesktop.org and systemd VER=$VERSION_ID
. /etc/os-release elif [ -f /etc/lsb-release ]; then
OS=$NAME # For some versions of Debian/Ubuntu without lsb_release command
VER=$VERSION_ID . /etc/lsb-release
elif [ -f /etc/lsb-release ]; then OS=$DISTRIB_ID
# For some versions of Debian/Ubuntu without lsb_release command VER=$DISTRIB_RELEASE
. /etc/lsb-release elif [ -f /etc/debian_version ]; then
OS=$DISTRIB_ID # Older Debian/Ubuntu/etc.
VER=$DISTRIB_RELEASE OS=Debian
elif [ -f /etc/debian_version ]; then VER=$(cat /etc/debian_version)
# Older Debian/Ubuntu/etc. elif [ -f /etc/SuSe-release ]; then
OS=Debian # Older SuSE/etc.
VER=$(cat /etc/debian_version) ...
elif [ -f /etc/SuSe-release ]; then elif [ -f /etc/redhat-release ]; then
# Older SuSE/etc. # Older Red Hat, CentOS, etc.
... ...
elif [ -f /etc/redhat-release ]; then else
# Older Red Hat, CentOS, etc. # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
... OS=$(uname -s)
else VER=$(uname -r)
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc. fi
OS=$(uname -s) #check for updates
VER=$(uname -r) packages_cache=$(/usr/lib/update-notifier/apt-check --human-readable | grep "can be")
fi supdates_cache=$(/usr/lib/update-notifier/apt-check --human-readable | grep "security updates")
# Echo the parameters out to the cache file with a "key" marker # Echo the parameters out to the cache file with a "key" marker
# at the beginning of the line. This key is used to pull the specific # at the beginning of the line. This key is used to pull the specific
# line needed for each parameter using grep, then cut out of the # line needed for each parameter using grep, then cut out of the
@ -253,7 +252,7 @@ fi
# Check for release upgrade # Check for release upgrade
if [ -x /usr/lib/ubuntu-release-upgrader/release-upgrade-motd ]; then if [ -x /usr/lib/ubuntu-release-upgrader/release-upgrade-motd ]; then
release_upgrade=`exec /usr/lib/ubuntu-release-upgrader/release-upgrade-motd` release_upgrade=$(cat /var/lib/ubuntu-release-upgrader/release-upgrade-available)
fi fi
if [ "$(lsb_release -sd | cut -d' ' -f4)" = "(development" ]; then if [ "$(lsb_release -sd | cut -d' ' -f4)" = "(development" ]; then
unset release_upgrade unset release_upgrade
@ -269,8 +268,8 @@ fi
################################ ################################
# Check if reboot required by updates # Check if reboot required by updates
if [ -x /usr/lib/update-notifier/update-motd-reboot-required ]; then if [ -f /var/run/reboot-required ]; then
reboot_required=`exec /usr/lib/update-notifier/update-motd-reboot-required` reboot_required=$(cat /var/run/reboot-required)
fi fi
################################ ################################
@ -305,6 +304,18 @@ usages=($(awk '{print $5}' <<< "${diskinfo}"))
freespaces=($(awk '{print $4}' <<< "${diskinfo}")) freespaces=($(awk '{print $4}' <<< "${diskinfo}"))
################################ ################################
#check for updates
packages=$(/usr/lib/update-notifier/apt-check --human-readable | grep "can be")
supdates=$(/usr/lib/update-notifier/apt-check --human-readable | grep "security updates" | cut -d '.' -f1)
packages=${packages%%\.*}
supdates=${supdates%%\.*}
# Check for updates
if [[ $(echo ${packages} | grep -c updates) != 1 ]] || [ -z "${supdates}" ] || [ -z "${release_upgrade}" ] ; then
#if [[ $(echo ${packages} | grep -c ^0\ updates) == 1 ]] ; then
need_updates=false
else
need_updates=true
fi
# Begin echo out of formatted table with aggregated information # Begin echo out of formatted table with aggregated information
@ -331,12 +342,6 @@ for((i=0; i<"${#logicals[@]}"; i++ )); do
boxline "\t$(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})" boxline "\t$(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})"
done done
boxline "" boxline ""
if [[ $(echo ${packages} | grep -c ^0\ updates) != 1 ]] || [ -z "${supdates}" ] || [ -z "${release_upgrade}" ] ; then
#if [[ $(echo ${packages} | grep -c ^0\ updates) == 1 ]] ; then
need_updates=false
else
need_updates=true
fi
if [[ "$need_updates" == "true" ]] ; then if [[ "$need_updates" == "true" ]] ; then
boxline "${bld}${unl}Updates${dfl}" boxline "${bld}${unl}Updates${dfl}"
boxline " ${packages}" boxline " ${packages}"