2015-10-22 17:26:24 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
## `echo`s:
|
|
|
|
## * 'true' - if all upgrades have been installed
|
|
|
|
## * 'false' - if there are pending upgrades
|
|
|
|
## * nothing - if apt-get is currently locked
|
|
|
|
##
|
|
|
|
## Forwards the exit code of the package manager.
|
|
|
|
|
|
|
|
if [ -e /etc/system-release ]; then
|
|
|
|
## Fedora
|
|
|
|
yum_output="$(yum -q check-update 2>&1)"
|
|
|
|
exit_code="$?"
|
2015-11-11 17:10:23 +01:00
|
|
|
[ "$exit_code" -eq 100 ] && echo "false" && exit 0
|
|
|
|
[ "$exit_code" -eq 0 ] && echo "true"
|
2015-11-12 00:36:43 +01:00
|
|
|
elif [ -e /etc/debian_version ]; then
|
2015-10-22 17:26:24 +02:00
|
|
|
## Debian
|
2015-11-11 22:13:17 +01:00
|
|
|
set -e
|
|
|
|
set -o pipefail
|
2015-10-22 17:26:24 +02:00
|
|
|
apt_get_output="$(LANG="C" apt-get -s upgrade 2>&1)"
|
|
|
|
exit_code="$?"
|
|
|
|
echo "$apt_get_output" | awk "/^Inst/{ print $2 }" | [ "$(wc -L)" -eq 0 ] && echo "true" || echo "false"
|
2015-11-12 00:36:43 +01:00
|
|
|
else
|
|
|
|
echo "Check not implemented for this distribution" >&2
|
|
|
|
exit 1
|
2015-10-22 17:26:24 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit "$exit_code"
|