Update build procedures. Add rpm and deb package scripts.
This commit is contained in:
parent
2c61dfdbe3
commit
da5d7163cb
|
|
@ -2,6 +2,9 @@
|
|||
/unifi-poller
|
||||
/*.gz
|
||||
/*.1
|
||||
/*.deb
|
||||
/*.rpm
|
||||
/vendor
|
||||
.DS_Store
|
||||
*~
|
||||
/package_build
|
||||
|
|
|
|||
53
Makefile
53
Makefile
|
|
@ -1,10 +1,11 @@
|
|||
PACKAGES=`find ./cmd -mindepth 1 -maxdepth 1 -type d`
|
||||
BINARY=unifi-poller
|
||||
|
||||
all: clean man build
|
||||
all: clean test man build
|
||||
|
||||
clean:
|
||||
for p in $(PACKAGES); do rm -f `echo $${p}|cut -d/ -f3`{,.1,.1.gz}; done
|
||||
rm -rf build unifi-poller_*.deb unifi-poller-*.rpm
|
||||
|
||||
build:
|
||||
for p in $(PACKAGES); do go build -ldflags "-w -s" $${p}; done
|
||||
|
|
@ -12,38 +13,6 @@ build:
|
|||
linux:
|
||||
for p in $(PACKAGES); do GOOS=linux go build -ldflags "-w -s" $${p}; done
|
||||
|
||||
install: man test build
|
||||
@echo "If you get errors, you may need sudo."
|
||||
# Install binary. binary.
|
||||
GOBIN=/usr/local/bin go install -ldflags "-w -s" ./...
|
||||
# Making config folders and installing man page.
|
||||
mkdir -p /usr/local/etc/$(BINARY) /usr/local/share/man/man1
|
||||
mv *.1.gz /usr/local/share/man/man1
|
||||
# Installing config file, man page and launch agent or systemd unit file.
|
||||
test -f /usr/local/etc/$(BINARY)/up.conf || cp up.conf.example /usr/local/etc/$(BINARY)/up.conf
|
||||
test -d ~/Library/LaunchAgents && cp startup/launchd/com.github.davidnewhall.$(BINARY).plist ~/Library/LaunchAgents || true
|
||||
test -d /etc/systemd/system && cp startup/systemd/$(BINARY).service /etc/systemd/system || true
|
||||
# Making systemd happy by telling it to reload.
|
||||
test -x /bin/systemctl && /bin/systemctl --system daemon-reload || true
|
||||
@echo
|
||||
@echo "Installation Complete. Edit the config file @ /usr/local/etc/$(BINARY)/up.conf "
|
||||
@echo "Then start the daemon with:"
|
||||
@test -d ~/Library/LaunchAgents && echo " launchctl load ~/Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist" || true
|
||||
@test -d /etc/systemd/system && echo " sudo /bin/systemctl start $(BINARY)" || true
|
||||
@echo "Examine the log file at: /usr/local/var/log/$(BINARY).log (logs may go elsewhere on linux, check syslog)"
|
||||
|
||||
uninstall:
|
||||
@echo "If you get errors, you may need sudo."
|
||||
# Stopping the daemon
|
||||
test -x /bin/systemctl && /bin/systemctl stop $(BINARY) || true
|
||||
test -x /bin/launchctl && /bin/launchctl unload ~/Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist || true
|
||||
# Deleting config file, binary, man page, launch agent or unit file.
|
||||
rm -rf /usr/local/{etc,bin}/$(BINARY) /usr/local/share/man/man1/$(BINARY).1.gz
|
||||
rm -f ~/Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist
|
||||
rm -f /etc/systemd/system/$(BINARY).service
|
||||
# Making systemd happy by telling it to reload.
|
||||
test -x /bin/systemctl && /bin/systemctl --system daemon-reload || true
|
||||
|
||||
test: lint
|
||||
for p in $(PACKAGES) $(LIBRARYS); do go test -race -covermode=atomic $${p}; done
|
||||
|
||||
|
|
@ -54,8 +23,20 @@ lint:
|
|||
golint $(PACKAGES)
|
||||
go vet $(PACKAGES)
|
||||
|
||||
man:
|
||||
script/build_manpages.sh ./
|
||||
|
||||
deps:
|
||||
dep ensure -update
|
||||
|
||||
man:
|
||||
scripts/build_manpages.sh ./
|
||||
|
||||
rpm: all
|
||||
scripts/build_packages.sh rpm
|
||||
|
||||
deb: all
|
||||
scripts/build_packages.sh deb
|
||||
|
||||
install: all
|
||||
scripts/local_install.sh
|
||||
|
||||
uninstall:
|
||||
scripts/local_uninstall.sh
|
||||
|
|
|
|||
16
README.md
16
README.md
|
|
@ -43,13 +43,6 @@ I only, personally, run this on a Mac 10.13.something. I know others are using
|
|||
Linux and it's working, but I need more feedback. Does the unit file work? Are
|
||||
you able to stop and start the service? Does the Makefile do the right things?
|
||||
|
||||
- I probably suck at InfluxDB.
|
||||
|
||||
I don't know what should be a tag and what should be a field. I think
|
||||
I did my best, but there's certainly room for improvements in both
|
||||
the data input and the Grafana graphs (output). I'm always iterating, but
|
||||
if you find a deficiency or something that can be improved, let me know.
|
||||
|
||||
- Are there other devices that need to be included?
|
||||
|
||||
I have: switch, router, access point. Three total, and the type structs are
|
||||
|
|
@ -64,11 +57,6 @@ Issue and lets discuss.
|
|||
If you're a nerd you can probably figure it out. I'd still like some pretty
|
||||
pictures and maybe even a Twitch VOD.
|
||||
|
||||
- Sanity Checking
|
||||
|
||||
Did I actually graph the right data in the right way? Some validation would
|
||||
be nice.
|
||||
|
||||
- Radios, Frequencies, Interfaces, vAPs
|
||||
|
||||
My access points only seem to have two radios, one interface and vAP per radio.
|
||||
|
|
@ -84,12 +72,12 @@ isolate why this happens. We may need to issue a reconnect and get a new cookie.
|
|||
|
||||
Here's a picture of the Client dashboard.
|
||||
|
||||

|
||||

|
||||
|
||||
Here's a picture of the UAP dashboard. This only shows one device, but you can
|
||||
select multiple to put specific stats side-by-side.
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||
## Copyright & License
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
# Grafana Dashboards & Examples
|
||||
|
||||
This folder contains grafana dashboards to get you started with the new data pool.
|
||||
Import these into Grafana to quickly visualize data from your devices.
|
||||
|
||||
They may/do use a few plugins: Clock, Discrete, Singlestat, Table
|
||||
|
||||
This folder also contains an example configuration file and some dashboard screenshots.
|
||||
|
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 246 KiB |
|
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 141 KiB |
|
|
@ -1,5 +0,0 @@
|
|||
# Grafana Dashboards
|
||||
|
||||
Import these into Grafana to quickly visualize data from your devices.
|
||||
|
||||
They may/do use a few plugins: Clock, Discrete, Singlestat, Table
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file is used by rpm and deb packages. FPM use.
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl restart unifi-poller
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file is used by rpm and deb packages. FPM use.
|
||||
|
||||
systemctl stop unifi-poller
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This file uses ronn to build a man page for unifi-poller.
|
||||
set -o pipefail
|
||||
|
||||
OUTPUT=$1
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script builds a deb or rpm package. Run by the Makefile.
|
||||
# Use: `make rpm` or `make deb`
|
||||
|
||||
OUTPUT=$1
|
||||
BINARY=unifi-poller
|
||||
VERSION=$(git tag -l --merged | tail -n1 | tr -d v)
|
||||
|
||||
if [ "$OUTPUT" != "deb" ] && [ "$OUTPUT" != "rpm" ]; then
|
||||
echo "first argument must be 'deb' or 'rpm'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fpm -h > /dev/null 2>&1
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "fpm missing. Install fpm: https://fpm.readthedocs.io/en/latest/installing.html"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Building '${OUTPUT}' package."
|
||||
|
||||
# Make a build environment.
|
||||
mkdir -p package_build/usr/bin package_build/etc/${BINARY} package_build/lib/systemd/system package_build/usr/share/man/man1
|
||||
|
||||
# Copy the binary, config file and man page into the env.
|
||||
cp ${BINARY} package_build/usr/bin
|
||||
cp *.1.gz package_build/usr/share/man/man1
|
||||
cp examples/up.conf.example package_build/etc/${BINARY}/up.conf
|
||||
|
||||
# Fix the paths in the systemd unit file before copying it into the emv.
|
||||
sed "s#ExecStart.*#ExecStart=/usr/bin/${BINARY} --config=/etc/${BINARY}/up.conf#" \
|
||||
init/systemd/unifi-poller.service > package_build/lib/systemd/system/${BINARY}.service
|
||||
|
||||
fpm -s dir -t ${OUTPUT} \
|
||||
-n ${BINARY} \
|
||||
-v ${VERSION} \
|
||||
--after-install scripts/after-install.sh \
|
||||
-C package_build
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script creates a local installation of unifi-poller.
|
||||
# Recommend using Makefile to invoke: make install
|
||||
# Supports Linux (systemd only) and macOS.
|
||||
|
||||
BINARY=unifi-poller
|
||||
|
||||
echo "Installing unifi-poller. If you get errors, you may need sudo."
|
||||
|
||||
# Install binary.
|
||||
GOBIN=/usr/local/bin go install -ldflags "-w -s" ./...
|
||||
|
||||
# Making config folders and installing man page.
|
||||
mkdir -p /usr/local/etc/${BINARY} /usr/local/share/man/man1
|
||||
mv *.1.gz /usr/local/share/man/man1
|
||||
|
||||
# Installing config file, man page and launch agent or systemd unit file.
|
||||
if [ ! -f /usr/local/etc/${BINARY}/up.conf ]; then
|
||||
cp examples/up.conf.example /usr/local/etc/${BINARY}/up.conf
|
||||
fi
|
||||
if [ -d ~/Library/LaunchAgents ]; then
|
||||
cp init/launchd/com.github.davidnewhall.${BINARY}.plist ~/Library/LaunchAgents
|
||||
fi
|
||||
if [ -d /etc/systemd/system ]; then
|
||||
cp init/systemd/${BINARY}.service /etc/systemd/system
|
||||
fi
|
||||
|
||||
# Making systemd happy by telling it to reload.
|
||||
if [ -x /bin/systemctl ]; then
|
||||
/bin/systemctl --system daemon-reload
|
||||
fi
|
||||
|
||||
echo "Installation Complete. Edit the config file @ /usr/local/etc/${BINARY}/up.conf"
|
||||
echo "Then start the daemon with:"
|
||||
if [ -d ~/Library/LaunchAgents ]; then
|
||||
echo " launchctl load ~/Library/LaunchAgents/com.github.davidnewhall.${BINARY}.plist"
|
||||
fi
|
||||
if [ -d /etc/systemd/system ]; then
|
||||
echo " sudo /bin/systemctl start ${BINARY}"
|
||||
fi
|
||||
echo "Examine the log file at: /usr/local/var/log/${BINARY}.log (logs may go elsewhere on linux, check syslog)"
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script removes a local installation of unifi-poller.
|
||||
# Recommend using Makefile to invoke: make uninstall
|
||||
# Supports Linux (systemd only) and macOS.
|
||||
|
||||
BINARY=unifi-poller
|
||||
|
||||
echo "Uninstall unifi-poller. If you get errors, you may need sudo."
|
||||
|
||||
# Stopping the daemon
|
||||
if [ -x /bin/systemctl ]; then
|
||||
/bin/systemctl stop ${BINARY}
|
||||
fi
|
||||
if [ -x /bin/launchctl ] && [ -f ~/Library/LaunchAgents/com.github.davidnewhall.${BINARY}.plist ]; then
|
||||
/bin/launchctl unload ~/Library/LaunchAgents/com.github.davidnewhall.${BINARY}.plist
|
||||
fi
|
||||
|
||||
# Deleting config file, binary, man page, launch agent or unit file.
|
||||
rm -rf /usr/local/{etc,bin}/${BINARY} /usr/local/share/man/man1/${BINARY}.1.gz
|
||||
rm -f ~/Library/LaunchAgents/com.github.davidnewhall.${BINARY}.plist
|
||||
rm -f /etc/systemd/system/${BINARY}.service
|
||||
|
||||
# Making systemd happy by telling it to reload.
|
||||
if [ -x /bin/systemctl ]; then
|
||||
/bin/systemctl --system daemon-reload
|
||||
fi
|
||||
Loading…
Reference in New Issue