#!/usr/bin/bash

cd "$(dirname "$0")"

if [ -f caddy ]; then
	rm caddy
fi

xcaddy build \
	--with github.com/greenpau/caddy-auth-portal \
	--with github.com/greenpau/caddy-auth-jwt \
	--with github.com/greenpau/caddy-trace

if [ -f caddy ]; then
	if [ -f /usr/bin/caddy ]; then
		rm /usr/bin/caddy
	fi
	sudo cp caddy /usr/bin/caddy
else
	echo "ERROR xcaddy did not produce an executable"
fi
