
# This file is part of snetaid.
#
#

noinst_DATA = snetaid.sysvinit snetaid.runit snetaid.conf netaid-server.json

EXTRA_DIST = snetaid.sysvinit.in snetaid.runit.in snetaid.conf netaid-server.json

CLEANFILES = snetaid.sysvinit snetaid.runit

snetaid.sysvinit: snetaid.sysvinit.in
	sed -e 's,@CONFDIR\@,$(snetaidconfdir),g' \
		-e 's,@SBINDIR\@,$(sbindir),g' $< > $@

snetaid.runit: snetaid.runit.in
	sed -e 's,@CONFDIR\@,$(snetaidconfdir),g' \
		-e 's,@SBINDIR\@,$(sbindir),g' $< > $@

install-data-local: snetaid.sysvinit snetaid.runit
if HAVE_SYSVINIT
	$(INSTALL) -b -D -m744 snetaid.sysvinit ${DESTDIR}${sysvdir}/snetaid
endif
if HAVE_RUNIT
	$(MKDIR_P) ${DESTDIR}/etc/sv/snetaid
	$(LN_S) ${DESTDIR}/${supervisedir} ${DESTDIR}/etc/sv/snetaid/supervise
	$(MKDIR_P) ${DESTDIR}/etc/runit/runsvdir/default
	$(LN_S) ${DESTDIR}/etc/sv/snetaid ${DESTDIR}/etc/runit/runsvdir/default/snetaid
	$(INSTALL) -b -D -m744 snetaid.runit ${DESTDIR}/etc/sv/snetaid/run
endif
	$(INSTALL) -b -D -m644 $(srcdir)/snetaid.conf ${DESTDIR}${snetaidconfdir}/snetaid.conf
	$(INSTALL) -b -D -m644 $(srcdir)/netaid-server.json ${DESTDIR}${aclsdir}/netaid-server.json

uninstall-local:
if HAVE_SYSVINIT
	rm -f ${DESTDIR}${sysvdir}/snetaid || true
endif
if HAVE_RUNIT
	rm -rf ${DESTDIR}/etc/sv/snetaid || true
	rm ${DESTDIR}/etc/runit/runsvdir/default/snetaid || true
endif
	rm -f ${DESTDIR}${snetaidconfdir}/snetaid.conf || true
	rm -f ${DESTDIR}${aclsdir}/netaid-server.json || true
