From 444d00e98a2ec36385c9fc189809343745480c4c Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Mon, 19 Mar 2018 00:59:50 +0200 Subject: [PATCH] Add support for checking latest version of unifi (#356) --- latest-versions.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/latest-versions.sh b/latest-versions.sh index 4ece2e2..a5c312f 100755 --- a/latest-versions.sh +++ b/latest-versions.sh @@ -53,12 +53,30 @@ get_latest() { local current=$(cat "${dir}/Dockerfile" | grep -m 1 VERSION | awk '{print $(NF)}') + compare "$name" "$dir" "$tag" "$current" "https://github.com/${repo}/releases" +} + +get_latest_unifi() { + local latest current + latest=$(curl -sSL http://www.ubnt.com/downloads/unifi/debian/dists/cloudkey-stable/ubiquiti/binary-armhf/Packages \ + | awk 'BEGIN {FS="\n"; RS="";} /^Package: unifi/' \ + | awk '/^Version:/ {print $2}' \ + | cut -d- -f1) + + current=$(grep -m 1 UNIFI_VERSION unifi/Dockerfile | tr '"' ' ' | awk '{print $(NF)}') + + compare unifi unifi "$latest" "$current" https://www.ubnt.com/download/unifi +} + +compare() { + local name="$1" dir="$2" tag="$3" current="$4" releases="$5" + if [[ "$tag" =~ "$current" ]] || [[ "$name" =~ "$current" ]] || [[ "$current" =~ "$tag" ]] || [[ "$current" == "master" ]]; then echo -e "\e[36m${dir}:\e[39m current ${current} | ${tag} | ${name}" else # add to the bad versions bad_versions+=( "${dir}" ) - echo -e "\e[31m${dir}:\e[39m current ${current} | ${tag} | ${name} | https://github.com/${repo}/releases" + echo -e "\e[31m${dir}:\e[39m current ${current} | ${tag} | ${name} | ${releases}" fi } @@ -91,12 +109,19 @@ znc/znc apache/zookeeper ) +other_projects=( +unifi +) + bad_versions=() main() { for p in ${projects[@]}; do get_latest "$p" done + for p in ${other_projects[@]}; do + get_latest_"$p" + done if [[ ${#bad_versions[@]} -ne 0 ]]; then echo