diff --git a/Makefile b/Makefile index 0b560e33..1c5e78be 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: clean test man build clean: for p in $(PACKAGES); do rm -f `echo $${p}|cut -d/ -f3`{,.1,.1.gz}; done - rm -rf build unifi-poller_*.deb unifi-poller-*.rpm unifi-poller-*.pkg + rm -rf package_build unifi-poller_*.deb unifi-poller-*.rpm unifi-poller-*.pkg build: for p in $(PACKAGES); do go build -ldflags "-w -s" $${p}; done diff --git a/scripts/after-install-osx.sh b/scripts/after-install-osx.sh new file mode 100755 index 00000000..28248634 --- /dev/null +++ b/scripts/after-install-osx.sh @@ -0,0 +1,15 @@ +#!/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 + +# 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/build_linux_packages.sh b/scripts/build_linux_packages.sh index 18147867..b579609c 100755 --- a/scripts/build_linux_packages.sh +++ b/scripts/build_linux_packages.sh @@ -42,4 +42,4 @@ fpm -s dir -t ${OUTPUT} \ --version ${VERSION} \ --after-install scripts/after-install.sh \ --before-remove scripts/before-remove.sh \ - -C package_build + --chdir package_build diff --git a/scripts/build_osx_package.sh b/scripts/build_osx_package.sh index adcbb562..a0af56f9 100755 --- a/scripts/build_osx_package.sh +++ b/scripts/build_osx_package.sh @@ -21,11 +21,12 @@ BINFIX=/usr/local # Make a build environment. rm -rf package_build mkdir -p package_build${BINFIX}/bin package_build${PREFIX}/etc/${BINARY} package_build${BINFIX}/share/man/man1 +mkdir -p package_build${PREFIX}/var/log # Copy the binary, config file and man page into the env. cp ${BINARY} package_build${BINFIX}/bin cp *.1.gz package_build${BINFIX}/share/man/man1 -cp examples/up.conf.example package_build${PREFIX}/etc/${BINARY}/up.conf +cp examples/up.conf.example package_build${PREFIX}/etc/${BINARY}/ # Copy in launch agent. mkdir -p package_build/Library/LaunchAgents @@ -35,5 +36,6 @@ cp init/launchd/com.github.davidnewhall.unifi-poller.plist package_build/Library fpm -s dir -t osxpkg \ --name ${BINARY} \ --version ${VERSION} \ + --after-install scripts/after-install-osx.sh \ --osxpkg-identifier-prefix com.github.davidnewhall \ - -C package_build + --chdir package_build