diff --git a/.gitignore b/.gitignore index 0ce3cb2d..63b2d1c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /up.conf /unifi-poller /unifi-poller*.gz +/unifi-poller*.txz /unifi-poller*.zip /unifi-poller*.1 /unifi-poller*.deb @@ -8,6 +9,8 @@ /unifi-poller*.arm /unifi-poller*.exe /unifi-poller*.macos +/unifi-poller*.freebsd +/unifi-poller*.bsd /unifi-poller*.linux /unifi-poller.rb *.sha256 diff --git a/.metadata.sh b/.metadata.sh index a3346a21..fe0f91d1 100755 --- a/.metadata.sh +++ b/.metadata.sh @@ -4,8 +4,6 @@ # Must match the repo name. BINARY="unifi-poller" -# github username -GHUSER="davidnewhall" # Github repo containing homebrew formula repo. HBREPO="golift/homebrew-mugs" MAINT="David Newhall II " @@ -19,14 +17,14 @@ LICENSE="MIT" # This affects the homebrew formula (launchd) and linux packages (systemd). FORMULA="service" -export BINARY GHUSER HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE FORMULA +export BINARY HBREPO MAINT VENDOR DESC GOLANGCI_LINT_ARGS CONFIG_FILE LICENSE FORMULA # The rest is mostly automatic. # Fix the repo if it doesn't match the binary name. # Provide a better URL if one exists. # Used for source links and wiki links. -SOURCE_URL="https://github.com/${GHUSER}/${BINARY}" +SOURCE_URL="https://github.com/${BINARY}/${BINARY}" # Used for documentation links. URL="${SOURCE_URL}" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 004875b7..29ce4965 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,7 +7,7 @@ making changes to it. ## TravisCI -This repo is tested, built and deployed by [Travis-CI](https://travis-ci.org/davidnewhall/unifi-poller). +This repo is tested, built and deployed by [Travis-CI](https://travis-ci.org/unifi-poller/unifi-poller). The [.travis.yml](.travis.yml) file in this repo coordinates the entire process. As long as this document is kept up to date, this is what the travis file does: @@ -68,6 +68,9 @@ hash it out. I'm reasonable. If you're trying to fix something in the UniFi data collection (ie. you got an unmarshal error, or you want to add something I didn't include) then you -should look at the [UniFi library](https://github.com/golift/unifi). All the +should look at the [UniFi library](https://github.com/unifi-poller/unifi). All the data collection and export code lives there. Contributions and Issues are welcome on that code base as well. + +This application is very dynamic and built using several package repos. +They are all in the [UniFi Poller GitHub Org](https://github.com/unifi-poller). diff --git a/Makefile b/Makefile index 101e78f6..2dadd0f3 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,6 @@ IGNORED:=$(shell bash -c "source .metadata.sh ; env | sed 's/=/:=/;s/^/export /' # md2roff turns markdown into man files and html files. MD2ROFF_BIN=github.com/github/hub/md2roff-bin - # Travis CI passes the version in. Local builds get it from the current git tag. ifeq ($(VERSION),) include .metadata.make @@ -23,6 +22,7 @@ endif # rpm is wierd and changes - to _ in versions. RPMVERSION:=$(shell echo $(VERSION) | tr -- - _) +BINARYU:=$(shell echo $(BINARY) | tr -- - _) PACKAGE_SCRIPTS= ifeq ($(FORMULA),service) @@ -40,7 +40,8 @@ $(PACKAGE_SCRIPTS) \ --maintainer "$(MAINT)" \ --vendor "$(VENDOR)" \ --description "$(DESC)" \ ---config-files "/etc/$(BINARY)/$(CONFIG_FILE)" +--config-files "/etc/$(BINARY)/$(CONFIG_FILE)" \ +--freebsd-origin "$(BINARY)/$(BINARY)" endef PLUGINS:=$(patsubst plugins/%/main.go,%,$(wildcard plugins/*/main.go)) @@ -53,16 +54,16 @@ VERSION_LDFLAGS:= \ # Makefile targets follow. -all: build +all: clean build # Prepare a release. Called in Travis CI. -release: clean macos windows linux_packages +release: clean macos windows linux_packages freebsd_packages # Prepareing a release! mkdir -p $@ - mv $(BINARY).*.macos $(BINARY).*.linux $@/ + mv $(BINARY).*.macos $(BINARY).*.linux $(BINARY).*.freebsd $@/ gzip -9r $@/ for i in $(BINARY)*.exe; do zip -9qm $@/$$i.zip $$i;done - mv *.rpm *.deb $@/ + mv *.rpm *.deb *.txz $@/ # Generating File Hashes openssl dgst -r -sha256 $@/* | sed 's#release/##' | tee $@/checksums.sha256.txt @@ -70,8 +71,8 @@ release: clean macos windows linux_packages # Delete all build assets. clean: # Cleaning up. - rm -f $(BINARY) $(BINARY).*.{macos,linux,exe}{,.gz,.zip} $(BINARY).1{,.gz} $(BINARY).rb - rm -f $(BINARY){_,-}*.{deb,rpm} v*.tar.gz.sha256 examples/MANUAL .metadata.make + rm -f $(BINARY) $(BINARY).*.{macos,freebsd,linux,exe}{,.gz,.zip} $(BINARY).1{,.gz} $(BINARY).rb + rm -f $(BINARY){_,-}*.{deb,rpm,txz} v*.tar.gz.sha256 examples/MANUAL .metadata.make rm -f cmd/$(BINARY)/README{,.html} README{,.html} ./$(BINARY)_manual.html rm -rf package_build_* release @@ -124,9 +125,20 @@ $(BINARY).armhf.linux: main.go macos: $(BINARY).amd64.macos $(BINARY).amd64.macos: main.go - # Building darwin 64-bit x86 binary. GOOS=darwin GOARCH=amd64 go build -o $@ -ldflags "-w -s $(VERSION_LDFLAGS)" +freebsd: $(BINARY).amd64.freebsd +$(BINARY).amd64.freebsd: main.go + GOOS=freebsd GOARCH=amd64 go build -o $@ -ldflags "-w -s $(VERSION_LDFLAGS)" + +freebsd386: $(BINARY).i386.freebsd +$(BINARY).i386.freebsd: main.go + GOOS=freebsd GOARCH=386 go build -o $@ -ldflags "-w -s $(VERSION_LDFLAGS)" + +freebsdarm: $(BINARY).armhf.freebsd +$(BINARY).armhf.freebsd: main.go + GOOS=freebsd GOARCH=arm go build -o $@ -ldflags "-w -s $(VERSION_LDFLAGS)" + exe: $(BINARY).amd64.exe windows: $(BINARY).amd64.exe $(BINARY).amd64.exe: main.go @@ -137,6 +149,8 @@ $(BINARY).amd64.exe: main.go linux_packages: rpm deb rpm386 deb386 debarm rpmarm debarmhf rpmarmhf +freebsd_packages: freebsd_pkg freebsd386_pkg freebsdarm_pkg + rpm: $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm $(BINARY)-$(RPMVERSION)-$(ITERATION).x86_64.rpm: package_build_linux check_fpm @echo "Building 'rpm' package for $(BINARY) version '$(RPMVERSION)-$(ITERATION)'." @@ -185,6 +199,21 @@ $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb: package_build_linux_armhf check_fpm fpm -s dir -t deb $(PACKAGE_ARGS) -a armhf -v $(VERSION) -C $< [ "$(SIGNING_KEY)" == "" ] || expect -c "spawn debsigs --default-key="$(SIGNING_KEY)" --sign=origin $(BINARY)_$(VERSION)-$(ITERATION)_armhf.deb; expect -exact \"Enter passphrase: \"; send \"$(PRIVATE_KEY)\r\"; expect eof" +freebsd_pkg: $(BINARY)-$(VERSION)_$(ITERATION).amd64.txz +$(BINARY)-$(VERSION)_$(ITERATION).amd64.txz: package_build_freebsd check_fpm + @echo "Building 'freebsd pkg' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." + fpm -s dir -t freebsd $(PACKAGE_ARGS) -a amd64 -v $(VERSION) -p $(BINARY)-$(VERSION)_$(ITERATION).amd64.txz -C $< + +freebsd386_pkg: $(BINARY)-$(VERSION)_$(ITERATION).i386.txz +$(BINARY)-$(VERSION)_$(ITERATION).i386.txz: package_build_freebsd_386 check_fpm + @echo "Building 32-bit 'freebsd pkg' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." + fpm -s dir -t freebsd $(PACKAGE_ARGS) -a 386 -v $(VERSION) -p $(BINARY)-$(VERSION)_$(ITERATION).i386.txz -C $< + +freebsdarm_pkg: $(BINARY)-$(VERSION)_$(ITERATION).armhf.txz +$(BINARY)-$(VERSION)_$(ITERATION).armhf.txz: package_build_freebsd_arm check_fpm + @echo "Building 32-bit ARM6/7 HF 'freebsd pkg' package for $(BINARY) version '$(VERSION)-$(ITERATION)'." + fpm -s dir -t freebsd $(PACKAGE_ARGS) -a arm -v $(VERSION) -p $(BINARY)-$(VERSION)_$(ITERATION).armhf.txz -C $< + # Build an environment that can be packaged for linux. package_build_linux: readme man plugins_linux_amd64 linux # Building package environment for linux. @@ -220,6 +249,30 @@ package_build_linux_armhf: package_build_linux armhf [ ! -f *armhf.so ] || cp *armhf.so $@/usr/lib/$(BINARY)/ cp $(BINARY).armhf.linux $@/usr/bin/$(BINARY) +# Build an environment that can be packaged for freebsd. +package_build_freebsd: readme man freebsd + mkdir -p $@/usr/local/bin $@/usr/local/etc/$(BINARY) $@/usr/local/share/man/man1 $@/usr/local/share/doc/$(BINARY) + cp $(BINARY).amd64.freebsd $@/usr/local/bin/$(BINARY) + cp *.1.gz $@/usr/local/share/man/man1 + cp examples/$(CONFIG_FILE).example $@/usr/local/etc/$(BINARY)/ + cp examples/$(CONFIG_FILE).example $@/usr/local/etc/$(BINARY)/$(CONFIG_FILE) + cp LICENSE *.html examples/*?.?* $@/usr/local/share/doc/$(BINARY)/ + [ "$(FORMULA)" != "service" ] || mkdir -p $@/usr/local/etc/rc.d + [ "$(FORMULA)" != "service" ] || \ + sed -e "s/{{BINARY}}/$(BINARY)/g" -e "s/{{BINARYU}}/$(BINARYU)/g" -e "s/{{CONFIG_FILE}}/$(CONFIG_FILE)/g" \ + init/bsd/freebsd.rc.d > $@/usr/local/etc/rc.d/$(BINARY) + [ "$(FORMULA)" != "service" ] || chmod +x $@/usr/local/etc/rc.d/$(BINARY) + +package_build_freebsd_386: package_build_freebsd freebsd386 + mkdir -p $@ + cp -r $ /dev/null || (echo "FPM missing. Install FPM: https://fpm.readthedocs.io/en/latest/installing.html" && false) @@ -282,15 +335,14 @@ lint: # Checking lint. golangci-lint run $(GOLANGCI_LINT_ARGS) -# This is safe; recommended even. -dep: vendor -vendor: go.mod go.sum - go mod download - # Don't run this unless you're ready to debug untested vendored dependencies. -deps: update vendor -update: - go get -u -d +deps: + go get -u github.com/unifi-poller/unifi + go get -u github.com/unifi-poller/influxunifi + go get -u github.com/unifi-poller/promunifi + go get -u github.com/unifi-poller/inputunifi + go get -u github.com/unifi-poller/poller + # Homebrew stuff. macOS only. diff --git a/README.md b/README.md index 8865d83f..66f6b659 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,12 @@ [![twitter](https://badgen.net/twitter/follow/TwitchCaptain?icon=https://simpleicons.now.sh/twitter/0099ff&label=TwitchCaptain&color=0116ff "TwitchCaptain @ Twitter")](https://twitter.com/TwitchCaptain) [![grafana](https://badgen.net/https/golift.io/bd/grafana/dashboard-downloads/10414,10415,10416,10417,10418,11311,11312,11313,11314,11315?icon=https://simpleicons.now.sh/grafana/ED7F38&color=0011ff "Grafana Dashboard Downloads")](http://grafana.com/dashboards?search=unifi-poller) [![pulls](https://badgen.net/docker/pulls/golift/unifi-poller?icon=https://simpleicons.now.sh/docker/38B1ED&label=pulls&color=0011ff "Docker Pulls")](https://hub.docker.com/r/golift/unifi-poller) -[![DLs](https://img.shields.io/github/downloads/unifi-poller/unifi-poller/total.svg?logo=github&color=0116ff "GitHub Downloads")](https://www.somsubhra.com/github-release-stats/?username=davidnewhall&repository=unifi-poller) +[![DLs](https://img.shields.io/github/downloads/unifi-poller/unifi-poller/total.svg?logo=github&color=0116ff "GitHub Downloads")](https://www.somsubhra.com/github-release-stats/?username=unifi-poller&repository=unifi-poller) [![unifi](https://badgen.net/badge/UniFi/5.11.x,5.12.x,UAP,USG,USW,UDM?list=|&icon=https://docs.golift.io/svg/ubiquiti_color.svg&color=0099ee "UniFi Products Supported")](https://github.com/golift/unifi) [![builer](https://badgen.net/badge/go/Application%20Builder?label=&icon=https://docs.golift.io/svg/go.svg&color=0099ee "Go Application Builder")](https://github.com/golift/application-builder) [![stars](https://badgen.net/github/stars/unifi-poller/unifi-poller?icon=https://simpleicons.now.sh/macys/fab&label=&color=0099ee "GitHub Stars")](https://github.com/unifi-poller/unifi-poller) -[![travis](https://badgen.net/travis/davidnewhall/unifi-poller?icon=travis&label=build "Travis Build")](https://travis-ci.org/unifi-poller/unifi-poller) +[![travis](https://badgen.net/travis/unifi-poller/unifi-poller?icon=travis&label=build "Travis Build")](https://travis-ci.org/unifi-poller/unifi-poller) Collect your UniFi controller data and report it to an InfluxDB instance, or export it for Prometheus collection. Prometheus support is @@ -54,10 +54,8 @@ graphs to slice the data any way you choose. Good luck! ## Backstory I found a simple piece of code on GitHub that sorta did what I needed; we all know that story. I wanted more data, so I added more data collection. -I believe I've completely rewritten every piece of original code, except the -copyright/license file and that's fine with me. I probably wouldn't have made -it this far if [Garrett](https://github.com/dewski/unifi) hadn't written the -original code I started with. Many props my man. +I probably wouldn't have made it this far if [Garrett](https://github.com/dewski/unifi) +hadn't written the original code I started with. Many props my man. The original code pulled only the client data. This app now pulls data for clients, access points, security gateways, dream machines and switches. I diff --git a/examples/MANUAL.md b/examples/MANUAL.md index d12c9ed3..8dbfb346 100644 --- a/examples/MANUAL.md +++ b/examples/MANUAL.md @@ -3,7 +3,7 @@ unifi-poller(1) -- Utility to poll UniFi Controller Metrics and store them in In SYNOPSIS --- -`unifi-poller -c /etc/unifi-poller.conf` +`unifi-poller -c /etc/unifi-poller/up.conf` This daemon polls a UniFi controller at a short interval and stores the collected measurements in an Influx Database. The measurements and metrics collected belong @@ -51,9 +51,9 @@ OPTIONS CONFIGURATION --- * Config File Default Location: - * Linux: `/etc/unifi-poller/up.conf` - * macOS: `/usr/local/etc/unifi-poller/up.conf` - * Windows: `C:\ProgramData\unifi-poller\up.conf` + * Mac/BSD: `/usr/local/etc/unifi-poller/up.conf` + * Windows: `C:\\ProgramData\\unifi-poller\\up.conf` + * Others: `/etc/unifi-poller/up.conf` * Config File Default Format: `TOML` * Possible formats: `XML`, `JSON`, `TOML`, `YAML` @@ -67,14 +67,14 @@ is provided so the application can be easily adapted to any environment. Configuration file (up.conf) parameters are documented in the wiki. -* [https://github.com/davidnewhall/unifi-poller/wiki/Configuration](https://github.com/davidnewhall/unifi-poller/wiki/Configuration) +* [https://github.com/unifi-poller/unifi-poller/wiki/Configuration](https://github.com/unifi-poller/unifi-poller/wiki/Configuration) `Shell Environment Parameters` This application can be fully configured using shell environment variables. Find documentation for this feature on the Docker Wiki page. -* [https://github.com/davidnewhall/unifi-poller/wiki/Docker](https://github.com/davidnewhall/unifi-poller/wiki/Docker) +* [https://github.com/unifi-poller/unifi-poller/wiki/Docker](https://github.com/unifi-poller/unifi-poller/wiki/Docker) GO DURATION --- @@ -92,10 +92,10 @@ AUTHOR --- * Garrett Bjerkhoel (original code) ~ 2016 * David Newhall II (rewritten) ~ 4/20/2018 -* David Newhall II (still going) ~ 6/7/2019 +* David Newhall II (still going) ~ 2/1/2020 LOCATION --- -* UniFi Poller: [https://github.com/davidnewhall/unifi-poller](https://github.com/davidnewhall/unifi-poller) +* UniFi Poller: [https://github.com/unifi-poller/unifi-poller](https://github.com/unifi-poller/unifi-poller) * UniFi Library: [https://github.com/golift/unifi](https://github.com/golift/unifi) * Grafana Dashboards: [https://grafana.com/dashboards?search=unifi-poller](https://grafana.com/dashboards?search=unifi-poller) diff --git a/examples/README.md b/examples/README.md index fdefd7d2..93e490f2 100644 --- a/examples/README.md +++ b/examples/README.md @@ -10,4 +10,4 @@ format is always TOML and may have any _other_ suffix. #### Dashboards This folder used to contain Grafana Dashboards. **They are now located at [Grafana.com](https://grafana.com/dashboards?search=unifi-poller).** -Also see [Grafana Dashboards](https://github.com/davidnewhall/unifi-poller/wiki/Grafana-Dashboards) Wiki. +Also see [Grafana Dashboards](https://github.com/unifi-poller/unifi-poller/wiki/Grafana-Dashboards) Wiki. diff --git a/examples/up.xml.example b/examples/up.xml.example index 2ff1eecf..ef3899dd 100644 --- a/examples/up.xml.example +++ b/examples/up.xml.example @@ -1,9 +1,10 @@ diff --git a/examples/up.yaml.example b/examples/up.yaml.example index 4ed27193..a9d9f798 100644 --- a/examples/up.yaml.example +++ b/examples/up.yaml.example @@ -1,7 +1,8 @@ -######################################################## -# UniFi Poller primary configuration file. YAML FORMAT # -# provided values are defaults. See up.conf.example! # -######################################################## +############################################## +# UniFi Poller primary configuration file. # +# YAML FORMAT. Provided values are defaults. # +# See up.conf.example! # +############################################## --- poller: diff --git a/go.mod b/go.mod index 169f31ca..56cd4bb8 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,18 @@ module github.com/unifi-poller/unifi-poller go 1.13 require ( - github.com/unifi-poller/influxunifi v0.0.1 - github.com/unifi-poller/inputunifi v0.0.1 - github.com/unifi-poller/poller v0.0.1 - github.com/unifi-poller/promunifi v0.0.1 - golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 // indirect - gopkg.in/yaml.v2 v2.2.7 // indirect + github.com/github/hub v2.11.2+incompatible // indirect + github.com/golang/protobuf v1.3.3 // indirect + github.com/mattn/go-colorable v0.1.4 // indirect + github.com/mattn/go-isatty v0.0.11 // indirect + github.com/prometheus/client_golang v1.4.0 // indirect + github.com/russross/blackfriday v2.0.0+incompatible // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/unifi-poller/influxunifi v0.0.5 + github.com/unifi-poller/inputunifi v0.0.4 + github.com/unifi-poller/poller v0.0.4-0.20200201081128-86e147a65d82 + github.com/unifi-poller/promunifi v0.0.4 + github.com/unifi-poller/unifi v0.0.3 + golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9 // indirect + gopkg.in/yaml.v2 v2.2.8 // indirect ) diff --git a/go.sum b/go.sum index cec9ab94..8ba3e4c4 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,3 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -6,12 +5,11 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/github/hub v2.11.2+incompatible/go.mod h1:zQrzJEdze2hfWJDgktd/L6sROjAdCThFrzjbxw4keTs= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= @@ -20,18 +18,24 @@ github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/me github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d h1:/WZQPMZNsjZ7IlCpsLGdQBINg5bxKQ1K1sh6awxLtkA= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -43,42 +47,48 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.3.0 h1:miYCvYqFXtl/J9FIy8eNpBfYthAEFg+Ys0XyUVEcDsc= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.1.0 h1:ElTg5tNp4DqfV7UQjDqv2+RJlNzsDtvNAWccbItceIE= github.com/prometheus/client_model v0.1.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.7.0 h1:L+1lyG48J1zAQXA3RBX/nG/B3gjlHq0zTt2tlbJLyCY= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/russross/blackfriday v2.0.0+incompatible/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/unifi-poller/influxunifi v0.0.0-20191229010055-eac7cb2786a8 h1:6tLYxh52e01ZiL+qxBRssEzXHqKjryog9Ez08hnRdbI= -github.com/unifi-poller/influxunifi v0.0.0-20191229010055-eac7cb2786a8/go.mod h1:wYuSwHJnuYHMQyLs9ZnDSoZkAj/otg229+8PytZ6lJw= -github.com/unifi-poller/influxunifi v0.0.1 h1:zHTa1Wf+2bke+qoLoRmgtFjWq/Yr0Cr+ZjtrtawefRM= -github.com/unifi-poller/influxunifi v0.0.1/go.mod h1:wYuSwHJnuYHMQyLs9ZnDSoZkAj/otg229+8PytZ6lJw= -github.com/unifi-poller/inputunifi v0.0.0-20191229005859-343b6711d445 h1:bsEkBa6xK1M9/g/rBrIc6qLeel4kqvtqnNyXLDhu4Uw= -github.com/unifi-poller/inputunifi v0.0.0-20191229005859-343b6711d445/go.mod h1:gmgiDi8RbaAJvtGf9ybDB+eguJzl/xyrpoqH5JUdWEk= -github.com/unifi-poller/inputunifi v0.0.1 h1:97s6pneYypvYV+RPgI5CgsRsrCYJyqqsVtaBoDprgsk= -github.com/unifi-poller/inputunifi v0.0.1/go.mod h1:gmgiDi8RbaAJvtGf9ybDB+eguJzl/xyrpoqH5JUdWEk= -github.com/unifi-poller/poller v0.0.1 h1:/SIsahlUEVJ+v9+C94spjV58+MIqR5DucVZqOstj2vM= -github.com/unifi-poller/poller v0.0.1/go.mod h1:sZfDL7wcVwenlkrm/92bsSuoKKUnjj0bwcSUCT+aA2s= -github.com/unifi-poller/promunifi v0.0.0-20191229005654-36c9f9b67ca7 h1:82q6vD+Ij8RmLoGng5/exRrnFRYm2/tpkKOVhEUH864= -github.com/unifi-poller/promunifi v0.0.0-20191229005654-36c9f9b67ca7/go.mod h1:U1fEJ/lCYTjkHmFhDBdEBMzIECo5Jz2G7ZBKtM7zkAw= -github.com/unifi-poller/promunifi v0.0.1 h1:KMZPE73VyA/BQDuL3Oo6m5+hAU0solGoZ/9m7dAJtoI= -github.com/unifi-poller/promunifi v0.0.1/go.mod h1:U1fEJ/lCYTjkHmFhDBdEBMzIECo5Jz2G7ZBKtM7zkAw= +github.com/unifi-poller/influxunifi v0.0.5-0.20200131061321-a5f6e5bfd703/go.mod h1:TAx1pZCtRHt1KbAw3r7SMpaBB8iAqY2+JFF97LvfbQc= +github.com/unifi-poller/influxunifi v0.0.5-0.20200131114444-25224f222423/go.mod h1:TAx1pZCtRHt1KbAw3r7SMpaBB8iAqY2+JFF97LvfbQc= +github.com/unifi-poller/influxunifi v0.0.5-0.20200201081102-02a27a18861d h1:SGXN2vL7Jc/zaqgVeiIpqf7iHf3ikbrShO7xbCWRjxk= +github.com/unifi-poller/influxunifi v0.0.5-0.20200201081102-02a27a18861d/go.mod h1:TAx1pZCtRHt1KbAw3r7SMpaBB8iAqY2+JFF97LvfbQc= +github.com/unifi-poller/influxunifi v0.0.5 h1:ZgiXMBgJ6pMS8qg4Nwo11rvUVXpUfKZ1r0ZJignK9bg= +github.com/unifi-poller/influxunifi v0.0.5/go.mod h1:TAx1pZCtRHt1KbAw3r7SMpaBB8iAqY2+JFF97LvfbQc= +github.com/unifi-poller/inputunifi v0.0.4/go.mod h1:X1Vd5uAtO5etZveY0WpMVMQBM/iLoMwZ/SvN1iXLxHo= +github.com/unifi-poller/poller v0.0.3/go.mod h1:ugy3FyZEH1rFyC3panBiJpXbLf7EZ4GkjiOtydB2CwQ= +github.com/unifi-poller/poller v0.0.4-0.20200201081128-86e147a65d82 h1:K5l91RBCkWWgLRw1EX3h8JNiGeiT1wBIRsU5XPC0GSA= +github.com/unifi-poller/poller v0.0.4-0.20200201081128-86e147a65d82/go.mod h1:ugy3FyZEH1rFyC3panBiJpXbLf7EZ4GkjiOtydB2CwQ= +github.com/unifi-poller/promunifi v0.0.4-0.20200131114412-f94a42d976b1/go.mod h1:mpIlZfVMsXnSoAeZ2IxzKnkba/VlWgRNnDQSYzRnX7c= +github.com/unifi-poller/promunifi v0.0.4-0.20200201081044-515621008cac h1:vh3sBk0/FuZ6rxuRzXn7eLTpDldOWDAS94onFF9Ml0s= +github.com/unifi-poller/promunifi v0.0.4-0.20200201081044-515621008cac/go.mod h1:mpIlZfVMsXnSoAeZ2IxzKnkba/VlWgRNnDQSYzRnX7c= +github.com/unifi-poller/promunifi v0.0.4 h1:aqrxPDyXT8pH9ZqCN/dtSo6AktI8GBFZBqshzg413v0= +github.com/unifi-poller/promunifi v0.0.4/go.mod h1:mpIlZfVMsXnSoAeZ2IxzKnkba/VlWgRNnDQSYzRnX7c= +github.com/unifi-poller/unifi v0.0.2/go.mod h1:DagVD/I+VMnVUHmTT4Fi76lPI+DHbuMwwtMIzanwMxM= +github.com/unifi-poller/unifi v0.0.3-0.20200131201802-b3ed8bd7d27a h1:erqRCgGquSYxjjD+LNO6J09MKtWfgkl8bewfsDDSisY= +github.com/unifi-poller/unifi v0.0.3-0.20200131201802-b3ed8bd7d27a/go.mod h1:DagVD/I+VMnVUHmTT4Fi76lPI+DHbuMwwtMIzanwMxM= +github.com/unifi-poller/unifi v0.0.3 h1:6pmjW7MuEEDKKvYoxjL3EZlaLOgmhYyxJBAg4X7GliI= +github.com/unifi-poller/unifi v0.0.3/go.mod h1:DagVD/I+VMnVUHmTT4Fi76lPI+DHbuMwwtMIzanwMxM= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -89,22 +99,20 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191220142924-d4481acd189f h1:68K/z8GLUxV76xGSqwTWw2gyk/jwn79LUL43rES2g8o= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8 h1:JA8d3MPx/IToSyXZG/RhwYEtfrKO1Fxrqe8KrkiLXKM= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golift.io/cnfg v0.0.5 h1:HnMU8Z9C/igKvir1dqaHx5BPuNGZrp99FCtdJyP2Z4I= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golift.io/cnfg v0.0.5/go.mod h1:ScFDIJg/rJGHbRaed/i7g1lBhywEjB0JiP2uZr3xC3A= -golift.io/unifi v0.0.400 h1:r8FlE+p+zmm8jnQdT367H2aGVMTgxZTrHSwbsHBcayA= -golift.io/unifi v0.0.400/go.mod h1:4BjegFlwA3am3mPlY0qHAnSKli4eexLQV42QKaRx9OY= -golift.io/unifi v4.1.6+incompatible h1:Yhb/+obX2vT9i6PElGislSuQ1WUtOf+l+sRjVxlY6nM= -golift.io/unifi v4.1.6+incompatible/go.mod h1:Zjw57ZAzTzCMw784pE8CdCFgkYSzVZzmJ++WUttbjto= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= -gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/init/bsd/README.md b/init/bsd/README.md new file mode 100644 index 00000000..78e7f58c --- /dev/null +++ b/init/bsd/README.md @@ -0,0 +1,9 @@ +Generic FreeBSD rc.d service file lives here. + +- Marshal template like so (example in [Makefile](../../Makefile)): +```shell + sed -e "s/{{BINARY}}/app-name/g" \ + -e "s/{{BINARYU}}/app_name/g" \ + -e "s/{{CONFIG_FILE}}/app-name.conf/g" \ + freebsd.rc.d > /usr/local/etc/rc.d/app-name +``` diff --git a/init/bsd/freebsd.rc.d b/init/bsd/freebsd.rc.d new file mode 100755 index 00000000..acfc6990 --- /dev/null +++ b/init/bsd/freebsd.rc.d @@ -0,0 +1,35 @@ +#!/bin/sh +# +# FreeBSD rc.d startup script for {{BINARY}}. +# +# PROVIDE: {{BINARY}} +# REQUIRE: networking syslog +# KEYWORD: + +. /etc/rc.subr + +name="{{BINARYU}}" +real_name="{{BINARY}}" +rcvar="{{BINARYU}}_enable" +{{BINARYU}}_command="/usr/local/bin/${real_name}" +{{BINARYU}}_user="nobody" +{{BINARYU}}_config="/usr/local/etc/${real_name}/{{CONFIG_FILE}}" +pidfile="/var/run/${real_name}/pid" + +# This runs `daemon` as the `{{BINARYU}}_user` user. +command="/usr/sbin/daemon" +command_args="-P ${pidfile} -r -t ${real_name} -T ${real_name} -l daemon ${{{BINARYU}}_command} -c ${{{BINARYU}}_config}" + +load_rc_config ${name} +: ${{{BINARYU}}_enable:=no} + +# Make a place for the pid file. +mkdir -p $(dirname ${pidfile}) +chown -R ${{BINARYU}}_user $(dirname ${pidfile}) + +# Suck in optional exported override variables. +# ie. add something like the following to this file: export UP_POLLER_DEBUG=true +[ -f "/usr/local/etc/defaults/${real_name}" ] && . "/usr/local/etc/defaults/${real_name}" + +# Go! +run_rc_command "$1" diff --git a/init/docker/README.md b/init/docker/README.md index 67b37750..80460d1d 100644 --- a/init/docker/README.md +++ b/init/docker/README.md @@ -14,4 +14,4 @@ in InfluxDB by UniFi Poller. ##### HOWTO **Learn more about how and when to use these *Docker Compose* files in the -[Docker Wiki](https://github.com/davidnewhall/unifi-poller/wiki/Docker).** +[Docker Wiki](https://github.com/unifi-poller/unifi-poller/wiki/Docker).** diff --git a/init/docker/hooks/README.md b/init/docker/hooks/README.md index 29d4d4f1..7bf127f6 100644 --- a/init/docker/hooks/README.md +++ b/init/docker/hooks/README.md @@ -21,7 +21,7 @@ any build. Two environment variables must be passed in from Docker Cloud config. Keep the build simple; see screenshot. This only supports one build tag, but it creates many more. -![UniFi Poller Docker Cloud Build Rules](https://raw.githubusercontent.com/wiki/davidnewhall/unifi-poller/images/unifi-poller-build-rules.png "UniFi Poller Docker Cloud Build Rules") +![UniFi Poller Docker Cloud Build Rules](https://raw.githubusercontent.com/wiki/unifi-poller/unifi-poller/images/unifi-poller-build-rules.png "UniFi Poller Docker Cloud Build Rules") The fancy source tag is `/^v((\d+\.\d+)(?:\.\d+)?)$/` and it allows you to capture the minor version without patch-level in `{\2}`. I no longer use `{\2}` in my build. diff --git a/init/docker/hooks/push b/init/docker/hooks/push index b4c52546..d345b007 100755 --- a/init/docker/hooks/push +++ b/init/docker/hooks/push @@ -25,7 +25,16 @@ done echo "Annotating Images: ${IMAGES}" # Build all the Docker tags if the source branch is a release and not a branch. -[ "v$VERSION" != "$SOURCE_BRANCH" ] || TAGS="latest $VERSION $SHORTVER stable" +if [ "v$VERSION" = "$SOURCE_BRANCH" ]; then + TAGS="$VERSION $(echo $VERSION | cut -d. -f1,2)" + + echo $SOURCE_BRANCH | grep -q -- - + if [ "$?" = "1" ]; then + # tag does not contain a dash, so assume it's a prod tag. + TAGS="$TAGS latest stable" + fi +fi + echo "Version: $VERSION, Source: $SOURCE_BRANCH, Building tags: ${TAGS}" # Create multi-architecture manifests for each tag with all the built images. diff --git a/init/homebrew/service.rb.tmpl b/init/homebrew/service.rb.tmpl index cb10dcb2..00921281 100644 --- a/init/homebrew/service.rb.tmpl +++ b/init/homebrew/service.rb.tmpl @@ -1,4 +1,4 @@ -# Homebrew Formula Template. Built by Makefile: `make fomula` +# macOS Homebrew Formula Template. Built by Makefile: `make fomula` # This is part of Application Builder. # https://github.com/golift/application-builder class {{Class}} < Formula @@ -9,14 +9,12 @@ class {{Class}} < Formula head "{{SOURCE_URL}}" depends_on "go" => :build - depends_on "dep" def install bin_path = buildpath/"#{name}" # Copy all files from their current location to buildpath/#{name} bin_path.install Dir["*",".??*"] cd bin_path do - system "make" "vendor" system "make", "install", "VERSION=#{version}", "ITERATION={{Iter}}", "PREFIX=#{prefix}", "ETC=#{etc}" # If this fails, the user gets a nice big warning about write permissions on their # #{var}/log folder. The alternative could be letting the app silently fail diff --git a/init/launchd/README.md b/init/launchd/README.md index 285631f2..d5a6e8ae 100644 --- a/init/launchd/README.md +++ b/init/launchd/README.md @@ -1,2 +1,2 @@ This file isn't used by the build or for any packages. The homebrew launchd is -in the [homebrew](../homebrew) folder. This file is for reference only. +in the [homebrew](../homebrew) folder. This macOS launchd file is for reference only. diff --git a/init/launchd/com.github.davidnewhall.unifi-poller.plist b/init/launchd/com.github.davidnewhall.unifi-poller.plist index d8a18294..c5370da0 100644 --- a/init/launchd/com.github.davidnewhall.unifi-poller.plist +++ b/init/launchd/com.github.davidnewhall.unifi-poller.plist @@ -3,7 +3,7 @@ Label - com.github.davidnewhall.unifi-poller + com.github.unifi-poller.unifi-poller ProgramArguments /usr/local/bin/unifi-poller diff --git a/init/systemd/template.unit.service b/init/systemd/template.unit.service index 82673d82..15ae80c8 100644 --- a/init/systemd/template.unit.service +++ b/init/systemd/template.unit.service @@ -1,4 +1,4 @@ -# Systemd service unit for {{BINARY}}. +# Linux Systemd service unit for {{BINARY}}. # This is part of Application Builder. # https://github.com/golift/application-builder diff --git a/main.go b/main.go index c39d81fc..c2a5dfc3 100644 --- a/main.go +++ b/main.go @@ -4,8 +4,11 @@ import ( "log" "github.com/unifi-poller/poller" + // Load input plugins! _ "github.com/unifi-poller/inputunifi" + _ "github.com/unifi-poller/unifi" + // Load output plugins! _ "github.com/unifi-poller/influxunifi" _ "github.com/unifi-poller/promunifi" diff --git a/plugins/README.md b/plugins/README.md new file mode 100644 index 00000000..1efd89bf --- /dev/null +++ b/plugins/README.md @@ -0,0 +1,3 @@ +Copy your plugins into this folder and run `make plugins` to build them. +There is an example plugin available: +[https://github.com/unifi-poller/mysqlunifi](https://github.com/unifi-poller/mysqlunifi) diff --git a/scripts/after-install.sh b/scripts/after-install.sh index acf7bafe..a465fdf4 100755 --- a/scripts/after-install.sh +++ b/scripts/after-install.sh @@ -1,11 +1,14 @@ -#!/bin/bash +#!/bin/sh -# This file is used by deb and rpm packages. -# FPM adds this as the after-install script. +# This file is used by txz, deb and rpm packages. +# FPM adds this as the after-install script to all packages. if [ -x "/bin/systemctl" ]; then # Reload and restart - this starts the application as user nobody. /bin/systemctl daemon-reload /bin/systemctl enable unifi-poller /bin/systemctl restart unifi-poller +elif [ -x /usr/sbin/service ]; then + # Do not start or restart on freebsd. That's "bad practice." + /usr/sbin/service unifi-poller enabled || /usr/sbin/service unifi-poller enable fi diff --git a/scripts/before-remove.sh b/scripts/before-remove.sh index 83ae4004..a6f2fce3 100755 --- a/scripts/before-remove.sh +++ b/scripts/before-remove.sh @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/sh -# This file is used by rpm and deb packages. FPM use. +# This file is used by txz, rpm and deb packages. FPM use. if [ "$1" = "upgrade" ] || [ "$1" = "1" ] ; then exit 0 @@ -9,4 +9,7 @@ fi if [ -x "/bin/systemctl" ]; then /bin/systemctl stop unifi-poller /bin/systemctl disable unifi-poller +elif [ -x /usr/sbin/service ]; then + /usr/sbin/service unifi-poller stop + /usr/sbin/service unifi-poller disable fi diff --git a/scripts/formula-deploy.sh b/scripts/formula-deploy.sh index 843c5139..b93d92e5 100755 --- a/scripts/formula-deploy.sh +++ b/scripts/formula-deploy.sh @@ -16,23 +16,6 @@ git config --global user.name "${BINARY}-auto-releaser" rm -rf homebrew_release_repo git clone git@github.com:${HBREPO}.git homebrew_release_repo -# If a bitly token file exists, we'll use that to shorten the link (and allow download counting). -if [ -f "bitly_token" ]; then - API=https://api-ssl.bitly.com/v4/bitlinks - # Request payload. In single quotes with double quotes escaped. :see_no_evil: - JSON='{\"domain\": \"bit.ly\",\"title\": \"${BINARY}.v${VERSION}-${ITERATION}.tgz\", \ - \"tags\": [\"${BINARY}\"], \"long_url\": \"${SOURCE_PATH}\"}' - # Request with headers and data. Using bash -c to hide token from bash -x in travis logs. - OUT=$(bash -c "curl -s -X POST -H 'Content-type: application/json' ${API} -H \"\$( ${BINARY}.rb.new - if [ "$?" = "0" ] && [ "$LINK" != "null?v=v${VERSION}" ] && [ "$LINK" != "?v=v${VERSION}" ]; then - mv ${BINARY}.rb.new ${BINARY}.rb - fi -fi - cp ${BINARY}.rb homebrew_release_repo/Formula pushd homebrew_release_repo git add Formula/${BINARY}.rb diff --git a/scripts/install.sh b/scripts/install.sh index ee025434..e395b315 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,36 +1,55 @@ -#!/bin/bash +#!/bin/sh # This is a quick and drity script to install the latest Linux package. # -# Use it like this: (sudo is optional) -# === -# curl https://raw.githubusercontent.com/davidnewhall/unifi-poller/master/scripts/install.sh | sudo bash -# === -# If you're on redhat, this installs the latest rpm. If you're on Debian, it installs the latest deb package. +# Use it like this, pick curl or wget: (sudo is optional) +# ---- +# curl -s https://raw.githubusercontent.com/unifi-poller/unifi-poller/master/scripts/install.sh | sudo sh +# wget -qO- https://raw.githubusercontent.com/unifi-poller/unifi-poller/master/scripts/install.sh | sudo sh +# ---- +# +# - If you're on RedHat/CentOS/Fedora, installs the latest rpm package. +# - If you're on Debian/Ubuntu/Gentoo, installs the latest deb package. +# - If you're on FreeBSD, installs the latest txz package. # # This is part of application-builder. # https://github.com/golift/application-builder -REPO=davidnewhall/unifi-poller +REPO=unifi-poller/unifi-poller +BREW=golift/mugs/unifi-poller LATEST=https://api.github.com/repos/${REPO}/releases/latest +ISSUES=https://github.com/${REPO}/issues/new ARCH=$(uname -m) +OS=$(uname -s) +P=" ==>" + +# Nothing else needs to be changed. Unless you're fixing things! +echo "<-------------------------------------------------->" + +if [ "$OS" = "Darwin" ]; then + echo "${P} On a mac? Use Homebrew:" + echo " brew install ${BREW}" + exit +fi # $ARCH is passed into egrep to find the right file. if [ "$ARCH" = "x86_64" ] || [ "$ARCH" = "amd64" ]; then ARCH="x86_64|amd64" -elif [[ $ARCH == *386* ]] || [[ $ARCH == *686* ]]; then +elif [[ $ARCH = *386* ]] || [[ $ARCH = *686* ]]; then ARCH="i386" -elif [[ $ARCH == *arm64* ]] || [[ $ARCH == *armv8* ]] || [[ $ARCH == *aarch64* ]]; then +elif [[ $ARCH = *arm64* ]] || [[ $ARCH = *armv8* ]] || [[ $ARCH = *aarch64* ]]; then ARCH="arm64" -elif [[ $ARCH == *armv6* ]] || [[ $ARCH == *armv7* ]]; then +elif [[ $ARCH = *armv6* ]] || [[ $ARCH = *armv7* ]]; then ARCH="armhf" else - echo "Unknown Architecture. Submit a pull request to fix this, please." - echo ==> $ARCH + echo "${P} [ERROR] Unknown Architecture: ${ARCH}" + echo "${P} $(uname -a)" + echo "${P} Please report this, along with the above OS details:" + echo " ${ISSUES}" exit 1 fi -if [ "$1" == "deb" ] || [ "$1" == "rpm" ]; then +if [ "$1" = "deb" ] || [ "$1" = "rpm" ] || [ "$1" = "txz" ]; then FILE=$1 else # If you have both, rpm wins. @@ -41,28 +60,36 @@ else dpkg --version > /dev/null 2>&1 if [ "$?" = "0" ]; then FILE=deb + else + pkg --version > /dev/null 2>&1 + if [ "$?" = "0" ]; then + FILE=txz + fi fi fi fi if [ "$FILE" = "" ]; then - echo "No dpkg or rpm package managers found!" + echo "${P} [ERROR] No pkg (freebsd), dpkg (debian) or rpm (redhat) package managers found; not sure what package to download!" + echo "${P} $(uname -a)" + echo "${P} If you feel this is a mistake, please report this along with the above OS details:" + echo " ${ISSUES}" exit 1 fi # curl or wget? curl --version > /dev/null 2>&1 if [ "$?" = "0" ]; then - CMD="curl -L" + CMD="curl -sL" else wget --version > /dev/null 2>&1 if [ "$?" = "0" ]; then - CMD="wget -O-" + CMD="wget -qO-" fi fi if [ "$CMD" = "" ]; then - echo "Need curl or wget - could not find either!" + echo "${P} [ERROR] Could not locate curl nor wget - please install one to download packages!" exit 1 fi @@ -70,27 +97,32 @@ fi URL=$($CMD ${LATEST} | egrep "browser_download_url.*(${ARCH})\.${FILE}\"" | cut -d\" -f 4) if [ "$?" != "0" ] || [ "$URL" = "" ]; then - echo "Error locating latest release at ${LATEST}" + echo "${P} [ERROR] Missing latest release for '${FILE}' file ($OS/${ARCH}) at ${LATEST}" + echo "${P} $(uname -a)" + echo "${P} Please report error this, along with the above OS details:" + echo " ${ISSUES}" exit 1 fi INSTALLER="rpm -Uvh" if [ "$FILE" = "deb" ]; then INSTALLER="dpkg --force-confdef --force-confold --install" +elif [ "$FILE" = "txz" ]; then + INSTALLER="pkg install" fi FILE=$(basename ${URL}) -echo "Downloading: ${URL} to /tmp/${FILE}" +echo "${P} Downloading: ${URL}" +echo "${P} To Location: /tmp/${FILE}" $CMD ${URL} > /tmp/${FILE} # Install it. if [ "$(id -u)" = "0" ]; then - echo "===================================" - echo "Downloaded. Installing the package!" - echo "Running: ${INSTALLER} /tmp/${FILE}" + echo "${P} Downloaded. Installing the package!" + echo "${P} Executing: ${INSTALLER} /tmp/${FILE}" $INSTALLER /tmp/${FILE} + echo "<-------------------------------------------------->" else - echo "================================" - echo "Downloaded. Install the package:" - echo "sudo $INSTALLER /tmp/${FILE}" + echo "${P} Downloaded. Install the package like this:" + echo " sudo $INSTALLER /tmp/${FILE}" fi