diff --git a/blueprints/unifi/install.sh b/blueprints/unifi/install.sh index 66e46d16..e1c90466 100755 --- a/blueprints/unifi/install.sh +++ b/blueprints/unifi/install.sh @@ -63,10 +63,7 @@ iocage exec "${1}" sysrc unifi_enable=YES iocage exec "${1}" service unifi start # shellcheck disable=SC2154 -if [[ ! "${!POLLER}" ]]; then - echo "Installation complete!" - echo "Unifi Controller is accessible at https://${JAIL_IP}:8443." -else +if [ "${!POLLER}" = true ]; then # Check if influxdb container exists, create unifi database if it does, error if it is not. echo "Checking if the database jail and database exist..." if [[ -d /mnt/"${global_dataset_iocage}"/jails/"${!DB_JAIL}" ]]; then @@ -116,4 +113,7 @@ else echo "Unifi Controller is accessible at https://${JAIL_IP}:8443." echo "Please login to the Unifi Controller and add ${UP_USER} as a read-only user." echo "In Grafana, add Unifi-Poller as a data source." +else + echo "Installation complete!" + echo "Unifi Controller is accessible at https://${JAIL_IP}:8443." fi diff --git a/blueprints/unifi/update.sh b/blueprints/unifi/update.sh index f40a1b24..5577ceb6 100755 --- a/blueprints/unifi/update.sh +++ b/blueprints/unifi/update.sh @@ -2,25 +2,28 @@ # This file contains the update script for unifi # Unifi Controller is updated through pkg, Unifi-Poller is not. This script updates Unifi-Poller -if [[ ! "${!POLLER}" ]]; then - echo "Skipping Unifi Poller for update, not installed" +POLLER="jail_${1}_unifi_poller" + +# shellcheck disable=SC2154 +if [ "${!POLLER}" = true ]; then + 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 else - - 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 + echo "Skipping Unifi Poller for update, not installed" fi + iocage exec "${1}" service unifi restart -echo "Update complete!" \ No newline at end of file +echo "Update complete!"