#!/usr/bin/make -f

export DEB_VERSION=$(shell dpkg-parsechangelog | egrep '^Version:' | cut -f 2 -d ' ')
export BUILD_VERSION=v${DEB_VERSION}-debian-pragmatic
export GO111MODULE=on


%:
	dh $@

override_dh_systemd_start:
	echo "Not running dh_systemd_start"
override_dh_auto_clean:
override_dh_auto_test:
override_dh_auto_build:
override_dh_auto_install:
	make
	
	mkdir -p debian/crowdsec-firewall-bouncer-iptables/usr/sbin
	mkdir -p debian/crowdsec-firewall-bouncer-nftables/usr/sbin

	cp crowdsec-firewall-bouncer  debian/crowdsec-firewall-bouncer-iptables/usr/sbin
	cp crowdsec-firewall-bouncer  debian/crowdsec-firewall-bouncer-nftables/usr/sbin

	mkdir -p debian/crowdsec-firewall-bouncer-iptables/etc/crowdsec/bouncers/
	mkdir -p debian/crowdsec-firewall-bouncer-nftables/etc/crowdsec/bouncers/
	cp config/crowdsec-firewall-bouncer.yaml debian/crowdsec-firewall-bouncer-iptables/etc/crowdsec/bouncers/
	cp config/crowdsec-firewall-bouncer.yaml debian/crowdsec-firewall-bouncer-nftables/etc/crowdsec/bouncers/

	mkdir -p debian/crowdsec-firewall-bouncer-iptables/etc/systemd/system/
	mkdir -p debian/crowdsec-firewall-bouncer-nftables/etc/systemd/system/

	BIN=/usr/sbin/crowdsec-firewall-bouncer CFG=/etc/crowdsec/bouncers/ envsubst < config/crowdsec-firewall-bouncer.service >  debian/crowdsec-firewall-bouncer-iptables/etc/systemd/system/crowdsec-firewall-bouncer.service
	BIN=/usr/sbin/crowdsec-firewall-bouncer CFG=/etc/crowdsec/bouncers/ envsubst < config/crowdsec-firewall-bouncer.service >  debian/crowdsec-firewall-bouncer-nftables/etc/systemd/system/crowdsec-firewall-bouncer.service

