Deal with config file and logging path ownership.

This commit is contained in:
David Newhall II 2019-05-30 21:20:35 -07:00
parent 41d2d201ac
commit b68c4e03ea
4 changed files with 21 additions and 4 deletions

View File

@ -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

15
scripts/after-install-osx.sh Executable file
View File

@ -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

View File

@ -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

View File

@ -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