scale-catalog/jails/unifi/update.sh
Matt Coleman 66e997069a
Add Unifi Controller with integrated Unifi-Poller (#75)
* Add Unifi Controller with integrated Unifi-Poller
Install & Update uses 'latest' release. Persistent data using influxdb.

Unifi Poller now optional

* fix global dataset refs

* move unifi_poller bootscript into rc folder

* Apply suggestions from code review

* Update jails/unifi/includes/rc/mongod

Forgot to add one suggestion from review.

* Added shellcheck ignores for all RC scripts

Shellcheck doesn't play nice with RC scripts, those advices are often either wrong, or very hard (not worth it) to change enough to get it to pass and work.

* Last rc ignores for shellcheck

* Update jails/unifi/install.sh

* Shellcheck to shellcheck

Making shellcheck lowercase for parsing

Co-authored-by: Kjeld Schouten-Lebbing <kjeld@schouten-lebbing.nl>
2020-04-29 18:40:14 +02:00

23 lines
1.0 KiB
Bash

#!/usr/local/bin/bash
# This file contains the update script for unifi
# Unifi Controller is updated through pkg, Unifi-Poller is not. This script updates Unifi-Poller
JAIL_NAME="unifi"
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}"/"${JAIL_NAME}"/"${FILE_NAME}" ]]; then
echo "Unifi-Poller is up to date."
exit 1
else
# Download and install the package
iocage exec "${JAIL_NAME}" fetch -o /config "${DOWNLOAD}"
iocage exec "${JAIL_NAME}" pkg install -qy /config/"${FILE_NAME}"
iocage exec "${JAIL_NAME}" service unifi restart
iocage exec "${JAIL_NAME}" service unifi_poller restart
fi
echo "Update complete!"