.PHONY: install uninstall
createemail: email.c
	gcc -o createemail email.c -lcrypt -ljansson

install: createemail
	cp createemail /usr/local/bin/createemail
	chmod 4755 /usr/local/bin/createemail
	chown root:root /usr/local/bin/createemail
	dotnet publish -o out --self-contained -c Release -p:PublishReadyToRun=true -p:PublishSingleFile=true -r linux-x64
	mkdir /opt/RegisterEmail
	cp out/RegisterEmail /opt/RegisterEmail/RegisterEmail
	cp -r www /opt/RegisterEmail/www
	cp createemail.service /etc/systemd/system/createemail.service
	systemctl enable createemail.service
	systemctl start createemail.service
uninstall:
	systemctl stop createemail.service
	systemctl disable createemail.service
	rm /etc/systemd/system/createemail.service
	rm -r /opt/RegisterEmail
	rm /usr/local/bin/createemail