Page MenuHomePhabricator

report-pending-upgrades.sh

Authored By
aborrero
Nov 22 2017, 1:54 PM
Size
1 KB
Referenced Files
None
Subscribers
None

report-pending-upgrades.sh

#!/bin/bash
if [ "$(id -u)" != "0" ] ; then
echo "E: root required" >&2
exit 1
fi
get_binary()
{
BINARY=$(which $1)
if [ ! -x "$BINARY" ] ; then
echo "E: no $1 binary found" >&2
exit 1
fi
echo $BINARY
}
APT_GET=$(get_binary apt-get)
APT_SHOW_VERSIONS=$(get_binary apt-show-versions)
UNATTENDED_UPGRADES=$(get_binary unattended-upgrades)
echo "I: updating package cache"
$APT_GET update >/dev/null
APT_SHOW_VERSIONS_OUTPUT=$($APT_SHOW_VERSIONS | grep upgradeable)
n1=$(echo "$APT_SHOW_VERSIONS_OUTPUT" | grep -v ^$ | wc -l)
UNATTENDED_UPGRADES_OUTPUT=$($UNATTENDED_UPGRADES --dry-run -v -d | grep "Packages that will be upgraded" | awk -F':' '{print $2}' | grep -v ^[[:space:]]*$)
n2=$(echo "$UNATTENDED_UPGARDES_OUTPUT" | grep -v ^$ | wc -l)
if [ "$n1" != "0" ] ; then
echo "I: upgradeable packages: $n1"
echo
echo "$APT_SHOW_VERSIONS_OUTPUT"
echo
fi
if [ "$n2" != "0" ] ; then
echo "I: upgradeable packages by unattended-upgrades: $n2"
echo
echo "$UNATTENDED_UPGARDES_OUTPUT"
echo
fi
echo "I: $n1 upgradeable packages, $n2 upgradeable packages by unatteneded-upgrades"

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5114380
Default Alt Text
report-pending-upgrades.sh (1 KB)

Event Timeline