1
0
mirror of https://github.com/librenms/librenms-agent.git synced 2024-05-09 09:54:52 +00:00

Add support for PhotonOS's tdnf. (#411)

Example output:

root [ /home/ives ]# tdnf -q check-update
Linux-PAM.x86_64                             1.4.0-5.ph4          photon-updates
cloud-init.noarch                           22.2.2-1.ph4          photon-updates
curl.x86_64                                 7.83.1-2.ph4          photon-updates
curl-libs.x86_64                            7.83.1-2.ph4          photon-updates
openssl.x86_64                               3.0.3-3.ph4          photon-updates

So a simple line count should suffice. Output of the script:

root [ /home/ives ]# /bin/docker-osupdate
5
This commit is contained in:
Ives van der Flaas
2022-07-10 11:51:11 +02:00
committed by GitHub
parent 027e848069
commit ba373fc2dc

View File

@@ -20,6 +20,8 @@ BIN_YUM='/usr/bin/env yum'
CMD_YUM='-q check-update'
BIN_DNF='/usr/bin/env dnf'
CMD_DNF='-q check-update'
BIN_TDNF='/usr/bin/env tdnf'
CMD_TDNF='-q check-update'
BIN_APT='/usr/bin/env apt-get'
CMD_APT='-qq -s upgrade'
BIN_PACMAN='/usr/bin/env pacman'
@@ -51,6 +53,15 @@ elif command -v dnf &>/dev/null ; then
else
echo "0";
fi
elif command -v tdnf &>/dev/null ; then
# PhotonOS
# shellcheck disable=SC2086
UPDATES=$($BIN_TDNF $CMD_TDNF | $BIN_WC $CMD_WC)
if [ "$UPDATES" -ge 1 ]; then
echo "$UPDATES";
else
echo "0";
fi
elif command -v pacman &>/dev/null ; then
# Arch
# calling pacman -Sup does not refresh the package list from the mirrors,