From e56ed4f3b84f9fcae63ee8f79ced1a0b289bda56 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Sat, 26 Jan 2019 15:49:58 -0800 Subject: [PATCH] Bump version, fix Makefile. --- Makefile | 48 ++++++++++++++++++++------------------ cmd/unifi-poller/config.go | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 7243fd6c..deac7ecf 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ PACKAGES=`find ./cmd -mindepth 1 -maxdepth 1 -type d` -LIBRARYS=./unidev +LIBRARYS= +BINARY=unifi-poller all: clean man build @@ -14,34 +15,35 @@ linux: install: man test build @echo "If you get errors, you may need sudo." - # Install binary. + # Install binary. binary. GOBIN=/usr/local/bin go install -ldflags "-w -s" ./... - # Make folders and install man page. - mkdir -p /usr/local/etc/unifi-poller /usr/local/share/man/man1 + # 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 - # Install config file, man page and launch agent or systemd unit file. - test -f /usr/local/etc/unifi-poller/up.conf || cp up.conf.example /usr/local/etc/unifi-poller/up.conf - test -d ~/Library/LaunchAgents && cp startup/launchd/com.github.davidnewhall.unifi-poller.plist ~/Library/LaunchAgents || true - test -d /etc/systemd/system && cp startup/systemd/unifi-poller.service /etc/systemd/system || true - # Make systemd happy by telling it to reload. - test -x /bin/systemctl && /bin/systemctl --system daemon-reload - @echo "Installation Complete. Edit the config file @ /usr/local/etc/unifi-poller/up.conf " + # 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.unifi-poller.plist" - @test -d /etc/systemd/system && echo " sudo /bin/systemctl start unifi-poller" - @echo "Examine the log file at: /usr/local/var/log/unifi-poller.log (logs may go elsewhere on linux, check syslog)" + @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." - # Stop the daemon - test -x /bin/systemctl && /bin/systemctl stop unifi-poller - test -x /bin/launchctl && /bin/launchctl unload ~/Library/LaunchAgents/com.github.davidnewhall.unifi-poller.plist - # Delete config file, binary, man page, launch agent or unit file. - rm -rf /usr/local/{etc,bin}/unifi-poller /usr/local/share/man/man1/unifi-poller.1.gz - rm -f ~/Library/LaunchAgents/com.github.davidnewhall.unifi-poller.plist - rm -f /etc/systemd/system/unifi-poller.service - # Make systemd happy by telling it to reload. - test -x /bin/systemctl && /bin/systemctl --system daemon-reload + # 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 diff --git a/cmd/unifi-poller/config.go b/cmd/unifi-poller/config.go index cd20c8fa..9b69ad86 100644 --- a/cmd/unifi-poller/config.go +++ b/cmd/unifi-poller/config.go @@ -3,7 +3,7 @@ package main import "time" // Version is loosely followed. -var Version = "v0.3.0" +var Version = "v1.0.0" const ( // App defaults in case they're missing from the config.