-
Notifications
You must be signed in to change notification settings - Fork 5
/
check-updates.sh
executable file
·40 lines (35 loc) · 1.11 KB
/
check-updates.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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.2.1
PREV_RELEASE="8.2"
LATEST_RELEASE=$(curl --silent https://www.netacad.com/courses/packet-tracer/faq | \
grep --only-matching --perl-regexp "What’s new in Cisco 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