From f434cd612532b2be253a3d9e83fd3e4a6035355d Mon Sep 17 00:00:00 2001 From: kjeld Schouten-Lebbing Date: Tue, 26 May 2020 14:27:11 +0200 Subject: [PATCH] Don't try to update unifi poller if it isn't installed Fixes #111 --- blueprints/unifi/update.sh | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/blueprints/unifi/update.sh b/blueprints/unifi/update.sh index a585afab..f40a1b24 100755 --- a/blueprints/unifi/update.sh +++ b/blueprints/unifi/update.sh @@ -2,20 +2,25 @@ # This file contains the update script for unifi # Unifi Controller is updated through pkg, Unifi-Poller is not. This script updates Unifi-Poller -FILE_NAME=$(curl -s https://api.github.com/repos/unifi-poller/unifi-poller/releases/latest | jq -r ".assets[] | select(.name | contains(\"amd64.txz\")) | .name") -DOWNLOAD=$(curl -s https://api.github.com/repos/unifi-poller/unifi-poller/releases/latest | jq -r ".assets[] | select(.name | contains(\"amd64.txz\")) | .browser_download_url") - -# Check to see if there is an update. -# shellcheck disable=SC2154 -if [[ -f /mnt/"${global_dataset_config}"/"${1}"/"${FILE_NAME}" ]]; then - echo "Unifi-Poller is up to date." - exit 1 +if [[ ! "${!POLLER}" ]]; then + echo "Skipping Unifi Poller for update, not installed" else - # Download and install the package - iocage exec "${1}" fetch -o /config "${DOWNLOAD}" - iocage exec "${1}" pkg install -qy /config/"${FILE_NAME}" - iocage exec "${1}" service unifi restart - iocage exec "${1}" service unifi_poller restart + + FILE_NAME=$(curl -s https://api.github.com/repos/unifi-poller/unifi-poller/releases/latest | jq -r ".assets[] | select(.name | contains(\"amd64.txz\")) | .name") + DOWNLOAD=$(curl -s https://api.github.com/repos/unifi-poller/unifi-poller/releases/latest | jq -r ".assets[] | select(.name | contains(\"amd64.txz\")) | .browser_download_url") + + # Check to see if there is an update. + # shellcheck disable=SC2154 + if [[ -f /mnt/"${global_dataset_config}"/"${1}"/"${FILE_NAME}" ]]; then + echo "Unifi-Poller is up to date." + exit 1 + else + # Download and install the package + iocage exec "${1}" fetch -o /config "${DOWNLOAD}" + iocage exec "${1}" pkg install -qy /config/"${FILE_NAME}" + + iocage exec "${1}" service unifi_poller restart + fi fi - -echo "Update complete!" +iocage exec "${1}" service unifi restart +echo "Update complete!" \ No newline at end of file