From dfd40000122f1a54abca9939e725943982ed7595 Mon Sep 17 00:00:00 2001 From: David Newhall II Date: Fri, 7 Jun 2019 13:54:26 -0700 Subject: [PATCH] Combined after install scripts. --- .gitignore | 4 ++-- Makefile | 2 +- examples/README.md | 2 +- scripts/after-install-osx.sh | 19 ------------------- scripts/after-install.sh | 28 ++++++++++++++++++++++++---- 5 files changed, 28 insertions(+), 27 deletions(-) delete mode 100755 scripts/after-install-osx.sh diff --git a/.gitignore b/.gitignore index bda3cba7..61d1785f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,10 @@ /unifi-poller*.deb /unifi-poller*.rpm /unifi-poller*.pkg +/unifi-poller.macos +/unifi-poller.linux /vendor .DS_Store *~ /package_build_* /release -/unifi-poller.macos -/unifi-poller.linux diff --git a/Makefile b/Makefile index 9747381a..0652c6af 100644 --- a/Makefile +++ b/Makefile @@ -82,7 +82,7 @@ $(BINARY)-$(VERSION).pkg: check_fpm package_build_osx --name $(BINARY) \ --version $(VERSION) \ --iteration $(ITERATION) \ - --after-install scripts/after-install-osx.sh \ + --after-install scripts/after-install.sh \ --osxpkg-identifier-prefix com.github.davidnewhall \ --license MIT \ --url $(URL) \ diff --git a/examples/README.md b/examples/README.md index 90fa3dd3..d9799785 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,6 +1,6 @@ # Grafana Dashboards & Examples -This folder contains 3 grafana dashboards to get you started with the new data pool. +This folder contains 4 grafana dashboards to get you started with the new data pool. Import these into Grafana to quickly visualize data from your devices. Created with Grafana 6.2. diff --git a/scripts/after-install-osx.sh b/scripts/after-install-osx.sh deleted file mode 100755 index bc2ad33c..00000000 --- a/scripts/after-install-osx.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# This file is used by osxpkg packages. FPM use. - -# Copy the config file into place if it does not exist. -if [ ! -f /usr/local/etc/unifi-poller/up.conf ] && [ -f /usr/local/etc/unifi-poller/up.conf.example ]; then - cp /usr/local/etc/unifi-poller/up.conf.example /usr/local/etc/unifi-poller/up.conf -fi - -# Allow admins to change the configuration and write logs. -chgrp -R admin /usr/local/etc/unifi-poller -chmod -R g+wr /usr/local/etc/unifi-poller - -# Make sure admins can write logs. -chgrp admin /usr/local/var/log -chmod g=rwx /usr/local/var/log - -# This starts it as root. no no no .... not sure how to fix that. -# launchctl load /Library/LaunchAgents/com.github.davidnewhall.unifi-poller.plist diff --git a/scripts/after-install.sh b/scripts/after-install.sh index 2fb3cd87..8842906b 100755 --- a/scripts/after-install.sh +++ b/scripts/after-install.sh @@ -1,7 +1,27 @@ #!/bin/bash -# This file is used by rpm and deb packages. FPM use. +# This file is used by deb, rpm and osx packages. +# FPM adds this as the after-install script. -systemctl daemon-reload -systemctl enable unifi-poller -systemctl restart unifi-poller +if [ "$(uname -s)" = "Darwin" ]; then + # Copy the config file into place if it does not exist. + if [ ! -f /usr/local/etc/unifi-poller/up.conf ] && [ -f /usr/local/etc/unifi-poller/up.conf.example ]; then + cp /usr/local/etc/unifi-poller/up.conf.example /usr/local/etc/unifi-poller/up.conf + fi + + # Allow admins to change the configuration and write logs. + chgrp -R admin /usr/local/etc/unifi-poller + chmod -R g+wr /usr/local/etc/unifi-poller + + # Make sure admins can write logs. + chgrp admin /usr/local/var/log + chmod g=rwx /usr/local/var/log + + # This starts it as root. no no no .... not sure how to fix that. + # launchctl load /Library/LaunchAgents/com.github.davidnewhall.unifi-poller.plist + +elif [ -x "/bin/systemctl" ]; then + /bin/systemctl daemon-reload + /bin/systemctl enable unifi-poller + /bin/systemctl restart unifi-poller +fi