diff --git a/integrations/inputunifi/.github_deploy_key.enc b/integrations/inputunifi/.github_deploy_key.enc deleted file mode 100644 index 7cd01940..00000000 Binary files a/integrations/inputunifi/.github_deploy_key.enc and /dev/null differ diff --git a/integrations/inputunifi/.travis.yml b/integrations/inputunifi/.travis.yml index 6e1df712..f009af4e 100644 --- a/integrations/inputunifi/.travis.yml +++ b/integrations/inputunifi/.travis.yml @@ -10,11 +10,6 @@ go: - 1.12.x before_install: - mkdir -p $GOPATH/bin - # This deploy key is not used atm. -- openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in .github_deploy_key.enc -out github_deploy_key -d -- chmod 600 github_deploy_key -- eval $(ssh-agent -s) -- ssh-add github_deploy_key # 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 - chmod +x $GOPATH/bin/dep @@ -25,6 +20,18 @@ install: - rvm $brew_ruby do gem install --no-document fpm script: - rvm $brew_ruby do make release +# get deploy key for golift/homebrew-repo. +after_success: + - | + declare -r SSH_FILE="$(mktemp -u $HOME/.ssh/XXXXX)" + echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config + openssl aes-256-cbc -K $encrypted_9f3147001275_key -iv $encrypted_9f3147001275_iv -in ".travis/github_deploy_key.enc" -out "$SSH_FILE" -d + chmod 600 "$SSH_FILE" \ + && printf "%s\n" \ + "Host github.com" \ + " IdentityFile $SSH_FILE" \ + " StrictHostKeyChecking no" \ + " LogLevel ERROR" >> ~/.ssh/config deploy: - provider: releases api_key: @@ -37,8 +44,11 @@ deploy: repo: davidnewhall/unifi-poller tags: true - provider: script - script: scripts/formula-deploy.sh ${TRAVIS_TAG} + script: scripts/formula-deploy.sh on: - repo: davidnewhall/unifi-poller tags: true -secure: "0yBdTabuF8LM8nQ8hSF1wjigQawal9N/v2NlR62oioMvzqWOy0zKo8R+mcfHK+pCByx0Ki/VWslms/WBKQnQvolGKY32UOg2cJvoVMoOemcwaezLK0kGZt8+O83ZQLr0CsiuzLQxJoqjiYf8ca6N2tjDFIowLPzSNPQR32mAP8cTe5fkxKyFAXgmA41BkzWMTx/V9R6udcX+Oofi8tpIZv1fyqSMNVlItHLxLFeP7F/r6OSM/Y87abAOt1U/ugPDufCL1MpmjRNhkL+NnHajSI30RsHFMv0c96hV3Va2g1VXrEVTB3F/0HhwBd9vwWwmiAGDMP/Nh7WfkQjHgHYCWVlbYgEdZj3rxeP9p14WEki3VavW2tZENjXoHpJswcT3UhB2m49p+pyV9NbzxZKeJDa2oniYBA9RfCrIURUIDI9Mk7vb+SVdcwx8JioiOebo568eRNHFI66KmQFrCGs+ZSuGFMk2ftaqhHSSctaD14EXzIurmWernw8xwmJAyiyBx6bKUIF969lBPlLVVCbl86ekNjm5xPxCaUM+Evugzo6nGsGckEUor85Ej54Q8qcxO/3m12F6gbHaEUUVK1splk+3dvDrSTZ6zJ+opxKkFph1MLjqQOIwqGU6DMMKy0JxMusjRg8n135LQQ/V05+Mzci4AF+kctidKfE42JDt5vA=" + repo: davidnewhall/unifi-poller +env: + global: + - GH_USER_NAME=unifi-auto-releaser + - GH_USER_EMAIL=unifi@auto.releaser diff --git a/integrations/inputunifi/.travis/github_deploy_key.enc b/integrations/inputunifi/.travis/github_deploy_key.enc new file mode 100644 index 00000000..bf0a7bf7 Binary files /dev/null and b/integrations/inputunifi/.travis/github_deploy_key.enc differ diff --git a/integrations/inputunifi/Makefile b/integrations/inputunifi/Makefile index eb7f723f..613e92e0 100644 --- a/integrations/inputunifi/Makefile +++ b/integrations/inputunifi/Makefile @@ -179,13 +179,14 @@ install: man readme $(BINARY) @echo - Otherwise, build and install a package: make rpm -or- make deb @echo See the Package Install wiki for more info: $(URL)/wiki/Package-Install @[ "$$(uname)" = "Darwin" ] || (echo "Unable to continue, not a Mac." && false) - @[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local" && false) + @[ "$(PREFIX)" != "" ] || (echo "Unable to continue, PREFIX not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) + @[ "$(ETC)" != "" ] || (echo "Unable to continue, ETC not set. Use: make install PREFIX=/usr/local ETC=/usr/local/etc" && false) # Copying the binary, config file, unit file, and man page into the env. - /usr/bin/install -m 0755 -d $(PREFIX)/bin $(PREFIX)/share/man/man1 $(PREFIX)/etc/$(BINARY) $(PREFIX)/share/doc/$(BINARY)/examples + /usr/bin/install -m 0755 -d $(PREFIX)/bin $(PREFIX)/share/man/man1 $(ETC)/$(BINARY) $(PREFIX)/share/doc/$(BINARY)/examples /usr/bin/install -m 0755 -cp $(BINARY) $(PREFIX)/bin/$(BINARY) /usr/bin/install -m 0644 -cp $(BINARY).1.gz $(PREFIX)/share/man/man1 - /usr/bin/install -m 0644 -cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/ - [ -f $(PREFIX)/etc/$(BINARY)/up.conf ] || /usr/bin/install -m 0644 -cp examples/up.conf.example $(PREFIX)/etc/$(BINARY)/up.conf + /usr/bin/install -m 0644 -cp examples/up.conf.example $(ETC)/$(BINARY)/ + [ -f $(ETC)/$(BINARY)/up.conf ] || /usr/bin/install -m 0644 -cp examples/up.conf.example $(ETC)/$(BINARY)/up.conf /usr/bin/install -m 0644 -cp *.html examples/{*dash.json,up.conf.example} $(PREFIX)/share/doc/$(BINARY)/ # These go to their own folder so the img src in the html pages continue to work. /usr/bin/install -m 0644 -cp examples/*.png $(PREFIX)/share/doc/$(BINARY)/examples diff --git a/integrations/inputunifi/scripts/formula-deploy.sh b/integrations/inputunifi/scripts/formula-deploy.sh index d6d51dc3..8313843c 100755 --- a/integrations/inputunifi/scripts/formula-deploy.sh +++ b/integrations/inputunifi/scripts/formula-deploy.sh @@ -5,11 +5,10 @@ make unifi-poller.rb VERSION=$(grep -E '^\s*version\s*"' unifi-poller.rb | cut -d\" -f 2) -git config user.name "unifi-poller-bot" -git config user.email "unifi@poller.bot" - rm -rf homebrew-repo -git clone https://$GITHUB_API_KEY@github.com/golift/homebrew-repo.git +git config --global user.email "unifi@auto.releaser" +git config --global user.name "unifi-auto-releaser" +git clone git@github.com:golift/homebrew-repo.git cp unifi-poller.rb homebrew-repo/Formula pushd homebrew-repo diff --git a/integrations/inputunifi/templates/unifi-poller.rb.tmpl b/integrations/inputunifi/templates/unifi-poller.rb.tmpl index c086d8c8..acfb8a67 100644 --- a/integrations/inputunifi/templates/unifi-poller.rb.tmpl +++ b/integrations/inputunifi/templates/unifi-poller.rb.tmpl @@ -21,10 +21,42 @@ class UnifiPoller < Formula bin_path.install Dir["*"] cd bin_path do system "dep", "ensure" - system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}" + system "make", "install", "VERSION=#{version}", "PREFIX=#{prefix}", "ETC=#{etc}" end end + plist_options :startup => true + + def plist; <<-EOS.undent + + + + + Label + #{plist_name} + ProgramArguments + + #{bin}/unifi-poller + -c + #{etc}/unifi-poller/up.conf + + RunAtLoad + + KeepAlive + + StandardErrorPath + #{var}/log/unifi-poller/log + StandardOutPath + #{var}/log/unifi-poller/log + UserName + nobody + GroupName + nobody + + + EOS + end + test do assert_match "unifi-poller v#{version}", shell_output("#{bin}/unifi-poller -v 2>&1", 2) end