From aa476c6d991a21e5ec641fb564ea7826d0b6ff40 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 14 Jun 2019 00:37:44 -0700 Subject: [PATCH 1/7] fix merge conflict. --- integrations/influxunifi/.gitignore | 1 - integrations/influxunifi/.travis.yml | 12 +++-- integrations/influxunifi/Makefile | 46 ++++--------------- ...com.github.davidnewhall.unifi-poller.plist | 26 ----------- .../init/systemd/unifi-poller.service | 10 ++-- 5 files changed, 22 insertions(+), 73 deletions(-) delete mode 100644 integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist diff --git a/integrations/influxunifi/.gitignore b/integrations/influxunifi/.gitignore index 33dc61bd..f225ae10 100644 --- a/integrations/influxunifi/.gitignore +++ b/integrations/influxunifi/.gitignore @@ -4,7 +4,6 @@ /unifi-poller*.1 /unifi-poller*.deb /unifi-poller*.rpm -/unifi-poller*.pkg /unifi-poller.macos /unifi-poller.linux /unifi-poller.rb diff --git a/integrations/influxunifi/.travis.yml b/integrations/influxunifi/.travis.yml index be362792..4ae0bb79 100644 --- a/integrations/influxunifi/.travis.yml +++ b/integrations/influxunifi/.travis.yml @@ -1,17 +1,19 @@ language: go -# so we can build an osx package. -os: osx addons: - homebrew: + apt: packages: + - ruby-dev - rpm - - gnu-tar + - build-essential + - git + - libgnome-keyring-dev + - fakeroot go: - 1.12.x before_install: - mkdir -p $GOPATH/bin # Download the `dep` binary to bin folder in $GOPATH -- curl -sLo $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.3/dep-darwin-amd64 +- curl -sLo $GOPATH/bin/dep https://github.com/golang/dep/releases/download/v0.5.3/dep-linux-amd64 - chmod +x $GOPATH/bin/dep # download super-linter: golangci-lint - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin latest diff --git a/integrations/influxunifi/Makefile b/integrations/influxunifi/Makefile index 5669ea21..99f44221 100644 --- a/integrations/influxunifi/Makefile +++ b/integrations/influxunifi/Makefile @@ -5,7 +5,6 @@ BINARY:=unifi-poller URL:=https://github.com/davidnewhall/$(BINARY) MAINT=David Newhall II DESC=This daemon polls a Unifi controller at a short interval and stores the collected measurements in an Influx Database. -OSX_PKG_PREFIX=com.github.davidnewhall GOLANGCI_LINT_ARGS=--enable-all -D gochecknoglobals PACKAGE:=./cmd/$(BINARY) LIBRARY:=./pkg/$(BINARY) @@ -35,7 +34,7 @@ release: clean test $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$( clean: # Cleaning up. rm -f $(BINARY){.macos,.linux,.1,}{,.gz} $(BINARY).rb - rm -f $(BINARY){_,-}*.{deb,rpm,pkg} md2roff v$(VERSION).tar.gz.sha256 + rm -f $(BINARY){_,-}*.{deb,rpm,pkg} md2roff v*.tar.gz.sha256 rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html rm -rf package_build_* release @@ -108,38 +107,9 @@ $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb: check_fpm package_build_linux --description "$(DESC)" \ --chdir package_build_linux -osxpkg: clean $(BINARY)-$(VERSION).pkg -$(BINARY)-$(VERSION).pkg: check_fpm package_build_osx - @echo "Building 'osx' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." - fpm -s dir -t osxpkg \ - --name $(BINARY) \ - --version $(VERSION) \ - --iteration $(ITERATION) \ - --after-install scripts/after-install.sh \ - --osxpkg-identifier-prefix $(OSX_PKG_PREFIX) \ - --license MIT \ - --url $(URL) \ - --maintainer "$(MAINT)" \ - --description "$(DESC)" \ - --chdir package_build_osx - docker: docker build -t $(DOCKER_REPO)/$(BINARY) . -# OSX packages use /usr/local because Apple doesn't allow writing many other places. -package_build_osx: readme man macos - # Building package environment for macOS. - mkdir -p $@/usr/local/bin $@/usr/local/etc/$(BINARY) $@/Library/LaunchAgents - mkdir -p $@/usr/local/share/man/man1 $@/usr/local/share/doc/$(BINARY)/examples $@/usr/local/var/log/$(BINARY) - # Copying the binary, config file and man page into the env. - cp $(BINARY).macos $@/usr/local/bin/$(BINARY) - cp *.1.gz $@/usr/local/share/man/man1 - cp examples/*.conf.example $@/usr/local/etc/$(BINARY)/ - cp LICENSE *.html examples/{*dash.json,up.conf.example} $@/usr/local/share/doc/$(BINARY)/ - # These go to their own folder so the img src in the html pages continue to work. - cp examples/*.png $@/usr/local/share/doc/$(BINARY)/examples - cp init/launchd/$(OSX_PKG_PREFIX).$(BINARY).plist $@/Library/LaunchAgents/ - # Build an environment that can be packaged for linux. package_build_linux: readme man linux # Building package environment for linux. @@ -203,16 +173,16 @@ uninstall: @echo " ==> You must run make uninstall as root on Linux. Recommend not running as root on macOS." [ -x /bin/systemctl ] && /bin/systemctl disable $(BINARY) || true [ -x /bin/systemctl ] && /bin/systemctl stop $(BINARY) || true - [ -x /bin/launchctl ] && [ -f ~/Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist ] \ - && /bin/launchctl unload ~/Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist || true - [ -x /bin/launchctl ] && [ -f /Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist ] \ - && /bin/launchctl unload /Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist || true + [ -x /bin/launchctl ] && [ -f ~/Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist ] \ + && /bin/launchctl unload ~/Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist || true + [ -x /bin/launchctl ] && [ -f /Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist ] \ + && /bin/launchctl unload /Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist || true rm -rf /usr/local/{etc,bin,share/doc}/$(BINARY) - rm -f ~/Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist - rm -f /Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist || true + rm -f ~/Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist + rm -f /Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist || true rm -f /etc/systemd/system/$(BINARY).service /usr/local/share/man/man1/$(BINARY).1.gz [ -x /bin/systemctl ] && /bin/systemctl --system daemon-reload || true - @[ -f /Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist ] && echo " ==> Unload and delete this file manually:" && echo " sudo launchctl unload /Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist" && echo " sudo rm -f /Library/LaunchAgents/$(OSX_PKG_PREFIX).$(BINARY).plist" || true + @[ -f /Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist ] && echo " ==> Unload and delete this file manually:" && echo " sudo launchctl unload /Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist" && echo " sudo rm -f /Library/LaunchAgents/com.github.davidnewhall.$(BINARY).plist" || true # Don't run this unless you're ready to debug untested vendored dependencies. deps: diff --git a/integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist b/integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist deleted file mode 100644 index cffcd1d9..00000000 --- a/integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - Label - com.github.davidnewhall.unifi-poller - ProgramArguments - - /usr/local/bin/unifi-poller - -c - /usr/local/etc/unifi-poller/up.conf - - RunAtLoad - - KeepAlive - - StandardErrorPath - /usr/local/var/log/unifi-poller/log - StandardOutPath - /usr/local/var/log/unifi-poller/log - UserName - nobody - GroupName - nobody - - diff --git a/integrations/influxunifi/init/systemd/unifi-poller.service b/integrations/influxunifi/init/systemd/unifi-poller.service index ab5220ad..97ed57f3 100644 --- a/integrations/influxunifi/init/systemd/unifi-poller.service +++ b/integrations/influxunifi/init/systemd/unifi-poller.service @@ -1,11 +1,15 @@ +# Sytemd service unit for unifi-poller. + [Unit] -Description=Unifi Poller - Ubiquiti Metrics->InfluxDB +Description=Unifi Poller - Stores Unifi Metrics in InfluxDB After=network.target Requires=network.target [Service] -ExecStart=/usr/bin/unifi-poller --config=/etc/unifi-poller/up.conf -Restart=always +ExecStart=/usr/bin/unifi-poller $DAEMON_OPTS +EnvironmentFile=-/etc/default/unifi-poller +EnvironmentFile=-/etc/sysconfig/unifi-poller +Restart=on-error StandardOutput=syslog StandardError=syslog SyslogIdentifier=unifi-poller From 0c2e1b516764db03529afa5377e44cc2635d53c1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 13 Jun 2019 20:57:42 -0700 Subject: [PATCH 2/7] fix ruby version in new linux build fix rvm try 1.9.2? install rvm newer ruby? --- integrations/influxunifi/.travis.yml | 5 +++-- integrations/influxunifi/Makefile | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/integrations/influxunifi/.travis.yml b/integrations/influxunifi/.travis.yml index 4ae0bb79..7a8d8f5a 100644 --- a/integrations/influxunifi/.travis.yml +++ b/integrations/influxunifi/.travis.yml @@ -18,11 +18,12 @@ before_install: # download super-linter: golangci-lint - curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin latest #- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest +- rvm install 2.0.0 install: - dep ensure -- rvm $brew_ruby do gem install --no-document fpm +- rvm 2.0.0 do gem install --no-document fpm script: -- rvm $brew_ruby do make release +- rvm 2.0.0 do make release # get deploy key for golift/homebrew-mugs. after_success: - | diff --git a/integrations/influxunifi/Makefile b/integrations/influxunifi/Makefile index 99f44221..c28989d9 100644 --- a/integrations/influxunifi/Makefile +++ b/integrations/influxunifi/Makefile @@ -20,13 +20,13 @@ RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) all: man build # Prepare a release. Called in Travis CI. -release: clean test $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb $(BINARY)-$(VERSION).pkg +release: clean test $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb macos # Prepareing a release! mkdir -p release gzip -9 $(BINARY).linux gzip -9 $(BINARY).macos mv $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$(VERSION)-$(ITERATION)_amd64.deb \ - $(BINARY)-$(VERSION).pkg $(BINARY).macos.gz $(BINARY).linux.gz release/ + $(BINARY).macos.gz $(BINARY).linux.gz release/ # Generating File Hashes openssl dgst -sha256 release/* | tee release/$(BINARY)_checksums_$(VERSION)-$(ITERATION).txt @@ -34,7 +34,7 @@ release: clean test $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)_$( clean: # Cleaning up. rm -f $(BINARY){.macos,.linux,.1,}{,.gz} $(BINARY).rb - rm -f $(BINARY){_,-}*.{deb,rpm,pkg} md2roff v*.tar.gz.sha256 + rm -f $(BINARY){_,-}*.{deb,rpm} md2roff v*.tar.gz.sha256 rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html rm -rf package_build_* release From f9830fab9e28d4e4ea6bf8d3d6fd8f0f8fb05446 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 13 Jun 2019 21:26:59 -0700 Subject: [PATCH 3/7] more updates. --- integrations/influxunifi/.travis.yml | 2 +- integrations/influxunifi/Makefile | 2 +- integrations/influxunifi/README.md | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/integrations/influxunifi/.travis.yml b/integrations/influxunifi/.travis.yml index 7a8d8f5a..79b654c8 100644 --- a/integrations/influxunifi/.travis.yml +++ b/integrations/influxunifi/.travis.yml @@ -20,8 +20,8 @@ before_install: #- curl -sL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest - rvm install 2.0.0 install: -- dep ensure - rvm 2.0.0 do gem install --no-document fpm +- dep ensure script: - rvm 2.0.0 do make release # get deploy key for golift/homebrew-mugs. diff --git a/integrations/influxunifi/Makefile b/integrations/influxunifi/Makefile index c28989d9..ddbe1ec8 100644 --- a/integrations/influxunifi/Makefile +++ b/integrations/influxunifi/Makefile @@ -120,7 +120,7 @@ package_build_linux: readme man linux cp *.1.gz $@/usr/share/man/man1 cp examples/*.conf.example $@/etc/$(BINARY)/ cp examples/up.conf.example $@/etc/$(BINARY)/up.conf - cp LICENSE *.html examples/{*dash.json,up.conf.example} $@/usr/share/doc/$(BINARY)/ + cp LICENSE *.html examples/*dash.json examples/up.conf.example $@/usr/share/doc/$(BINARY)/ # These go to their own folder so the img src in the html pages continue to work. cp examples/*.png $@/usr/share/doc/$(BINARY)/examples cp init/systemd/$(BINARY).service $@/lib/systemd/system/ diff --git a/integrations/influxunifi/README.md b/integrations/influxunifi/README.md index 7857859a..345afe00 100644 --- a/integrations/influxunifi/README.md +++ b/integrations/influxunifi/README.md @@ -53,7 +53,7 @@ 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. Update: The installation has been simplified tremendously with the -[creation of binary packages](https://github.com/davidnewhall/unifi-poller/wiki/Package-Install). +[creation of binary packages](https://github.com/davidnewhall/unifi-poller/wiki/Installation). More to come! - Radios, Frequencies, Interfaces, vAPs @@ -86,5 +86,5 @@ sites side-by-side. So easy! This screenshot barely does it justice. ## Copyright & License - Copyright © 2016 Garrett Bjerkhoel. -- Copyright © 2018 David Newhall II. -- See [MIT-LICENSE](MIT-LICENSE) for license information. +- Copyright © 2018-2019 David Newhall II. +- See [LICENSE](LICENSE) for license information. From 20565f95b8bb7da213cc231d02f649154cb3ce99 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Thu, 13 Jun 2019 21:31:35 -0700 Subject: [PATCH 4/7] Put plist back --- ...com.github.davidnewhall.unifi-poller.plist | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist diff --git a/integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist b/integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist new file mode 100644 index 00000000..addc8ff1 --- /dev/null +++ b/integrations/influxunifi/init/launchd/com.github.davidnewhall.unifi-poller.plist @@ -0,0 +1,22 @@ + + + + + Label + com.github.davidnewhall.unifi-poller + ProgramArguments + + /usr/local/bin/unifi-poller + -c + /usr/local/etc/unifi-poller/up.conf + + RunAtLoad + + KeepAlive + + StandardErrorPath + /usr/local/var/log/unifi-poller/log + StandardOutPath + /usr/local/var/log/unifi-poller/log + + From ade75ec1fc84327ed7e0067a6c4b9419957aceb1 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 14 Jun 2019 00:35:45 -0700 Subject: [PATCH 5/7] add docker tests --- integrations/influxunifi/.travis.yml | 5 +++++ integrations/influxunifi/Makefile | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/integrations/influxunifi/.travis.yml b/integrations/influxunifi/.travis.yml index 79b654c8..2d219abb 100644 --- a/integrations/influxunifi/.travis.yml +++ b/integrations/influxunifi/.travis.yml @@ -10,6 +10,8 @@ addons: - fakeroot go: - 1.12.x +services: + - docker before_install: - mkdir -p $GOPATH/bin # Download the `dep` binary to bin folder in $GOPATH @@ -22,7 +24,10 @@ before_install: install: - rvm 2.0.0 do gem install --no-document fpm - dep ensure +- docker build -t unifi-poller . +- docker run -d --name unifi-poller script: +- docker ps -a | grep -q unifi-poller - rvm 2.0.0 do make release # get deploy key for golift/homebrew-mugs. after_success: diff --git a/integrations/influxunifi/Makefile b/integrations/influxunifi/Makefile index ddbe1ec8..c4bd78ad 100644 --- a/integrations/influxunifi/Makefile +++ b/integrations/influxunifi/Makefile @@ -147,7 +147,7 @@ lint: # Checking lint. golangci-lint run $(GOLANGCI_LINT_ARGS) -# Deprecated. +# Used for Homebrew only. Other disros can create packages. install: man readme $(BINARY) @echo - Done Building! - @echo - Local installation with the Makefile is only supported on macOS. From 577ba878305e3df769d24b2ecdc9533f12b29287 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 14 Jun 2019 00:41:35 -0700 Subject: [PATCH 6/7] add image name. derp. --- integrations/influxunifi/.travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integrations/influxunifi/.travis.yml b/integrations/influxunifi/.travis.yml index 2d219abb..6266a5ee 100644 --- a/integrations/influxunifi/.travis.yml +++ b/integrations/influxunifi/.travis.yml @@ -25,8 +25,9 @@ install: - rvm 2.0.0 do gem install --no-document fpm - dep ensure - docker build -t unifi-poller . -- docker run -d --name unifi-poller +- docker run -d --name unifi-poller unifi-poller script: + # Once we figure out how to keep it running we can remove the -a in ps args. - docker ps -a | grep -q unifi-poller - rvm 2.0.0 do make release # get deploy key for golift/homebrew-mugs. From e3f1f6ec53c74a42fb466f3279410dc3c405912b Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 14 Jun 2019 00:47:59 -0700 Subject: [PATCH 7/7] Slightly better test? --- integrations/influxunifi/.travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integrations/influxunifi/.travis.yml b/integrations/influxunifi/.travis.yml index 6266a5ee..353221a2 100644 --- a/integrations/influxunifi/.travis.yml +++ b/integrations/influxunifi/.travis.yml @@ -25,10 +25,11 @@ install: - rvm 2.0.0 do gem install --no-document fpm - dep ensure - docker build -t unifi-poller . -- docker run -d --name unifi-poller unifi-poller +- docker run -d --name unifi-poller unifi-poller | tee docker_id script: # Once we figure out how to keep it running we can remove the -a in ps args. - docker ps -a | grep -q unifi-poller +- docker logs $(&1 | grep -Eq "Loaded Configuration[:] /etc/unifi-poller/up.conf" - rvm 2.0.0 do make release # get deploy key for golift/homebrew-mugs. after_success: