Files
com.cisco.PacketTracer/check-updates.sh
losuler 8440965ee6 feat: add flag for printing only version
This is for use in the GitHub action.
2022-05-08 01:26:52 +10:00

41 lines
1.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Uncomment for debugging use
# set -o xtrace
set -o errexit
set -o pipefail
set -o nounset
# The FAQ page says 8.1 but it's actually 8.1.1
PREV_RELEASE="8.1"
LATEST_RELEASE=$(curl --silent https://www.netacad.com/courses/packet-tracer/faq | \
grep --only-matching --perl-regexp "Whats new in Packet Tracer (\d\.\d|\.\d)" | \
head -1 | \
grep --only-matching --perl-regexp "(\d\.\d|\.\d)")
function print_release {
if [[ "${LATEST_RELEASE}" != "${PREV_RELEASE}" ]]; then
if [[ "$1" != "version-only" ]]; then
echo "There's a new release of Packet Tracer."
echo "https://www.netacad.com/courses/packet-tracer/faq"
fi
echo "${LATEST_RELEASE} > ${PREV_RELEASE}."
else
if [[ "$1" != "version-only" ]]; then
echo "There's no new release of Packet Tracer."
echo "https://www.netacad.com/courses/packet-tracer/faq"
fi
echo "${LATEST_RELEASE} == ${PREV_RELEASE}."
fi
}
case "$@" in
--version-only)
print_release "version-only"
;;
*)
print_release ""
;;
esac