aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2021-06-18 22:13:54 +0100
committerMiquel Lionel <lionelmiquel@sfr.fr>2021-06-23 13:48:56 +0100
commit420155e750c4b95dd4327d7adb4310a64eafb364 (patch)
tree3c7ea05d24b73e1467489530b4f7c9be50e0af7c /Makefile
parent416fb73fbccf28ff256de352cd9b14803423852d (diff)
downloadgpigeon-420155e750c4b95dd4327d7adb4310a64eafb364.tar.gz
gpigeon-420155e750c4b95dd4327d7adb4310a64eafb364.zip
add some update from the master.
- Added the README.md form master branch. - Added new script gpigeonctl: will allow to initialize the database and manage it (add or delete and user, purge cookies). - Added the Makefile and the config.dek.mk from master branch with some changes - Added nginx config from master branch - Rename gpigeon.css -> styles.css - gpigeon-template.cgi: the -w flag on the shebang is useless because we already have "use warnings". Also, the man page discourage its use. - Fixed link-tmpl-template.cgi: the self-deletion now occurs as intended, and not only when in HAS_MAILSERVER=0 mode. also fixed the indenting around these parts because it was a clusterfuck
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile122
1 files changed, 122 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..9781a3a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,122 @@
+.POSIX:
+
+# you should comment this line @if non-GNU make
+# and execute genpass.pl manually and edit config.mk
+# with the resulting argon2id hash.
+BOLD=\033[01m
+RED=\033[31m
+STOP=\033[0m
+#RANDOM_ARGON2 := $(shell perl genpass.pl > genpass.txt && tail -1 genpass.txt)
+include config.mk
+
+gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
+ @if test -z '$(PREFIX)'; then \
+ printf "\n$(RED)No \u0024PREFIX variable defined in config.mk.\n";\
+ printf "Look into config.def.mk for the defaults and fix that.$(STOP)\n";\
+ exit 1;\
+ else \
+ printf "\n\u0024PREFIX var is set to $(BOLD)$(PREFIX)$(STOP)";\
+ fi
+
+ @if test -z '$(WWWPREFIX)'; then\
+ printf "\n${RED}No web directory defined in config.mk. Check your config.def.mk for the defaults and fix that.${STOP}";\
+ exit 1; \
+ else \
+ printf "\nThe WWW directory is $(BOLD)$(WWWPREFIX)$(STOP)";\
+ fi
+
+ @if test -n '$(_GPG_HOMEDIR)'; then \
+ printf "\nThe home directory for GPG will be ${BOLD}$(_GPG_HOMEDIR)${STOP}" ;\
+ else \
+ printf "\n${RED}The GPG home directory for gpigeon wasn't set in config.mk . Fix that.${STOP}" ;\
+ $(MAKE) clean ;\
+ exit 1;\
+ fi
+ @if test -n '$(LINK_TEMPLATE_PATH)'; then \
+ printf "\nLink template is at ${BOLD}$(LINK_TEMPLATE_PATH)${STOP}"; \
+ sed -e 's|link_template_path_goes_here|$(LINK_TEMPLATE_PATH)|g' gpigeon-template.cgi > gpigeon.cgi; \
+ else \
+ printf "\n${RED}The path for the link template wasn't set in your config.mk. Fix that.${STOP}" ;\
+ exit 1;\
+ fi
+ @if test -n '$(MSG_FORM_CHAR_LIMIT)'; then \
+ printf "Message form will have a message limit of ${BOLD}$(MSG_FORM_CHAR_LIMIT) characters${STOP}\n"; \
+ sed -e "s|msg_char_limit_goes_here|$(MSG_FORM_CHAR_LIMIT)|g" link-tmpl-template.cgi > link-tmpl.cgi;\
+ else \
+ printf "${RED}No character limits were defined in your config.mk. Fix that.${STOP}\n" ;\
+ $(MAKE) clean ;\
+ exit 1;\
+ fi
+ @if [ '${HAS_MAILSERVER}' == '1' ]; then \
+ printf "Local mail server setup. ${BOLD}Mail::Sendmail module will be used to send the mails${STOP}.\n"; \
+ else \
+ printf "External mail server setup. ${BOLD}Net::SMTPS module will be used to send the mails${STOP}.\n"; \
+ if test -n '$(MAILSENDER)'; then \
+ printf "\tEncrypted mails will be sent from ${BOLD}$(MAILSENDER)${STOP}\n"; \
+ sed -e 's|sender_addr_goes_here|$(MAILSENDER)|g' link-tmpl-template.cgi > link-tmpl.cgi; \
+ else \
+ printf "\t${RED}No mail sender adress configured in your config.mk. Fix this.${STOP}\n" ; \
+ $(MAKE) clean ; \
+ exit 1; \
+ fi; \
+ if test -n '$(MAILSENDER_PW)'; then \
+ printf "\tPassword for ${BOLD}${MAILSENDER}${STOP} is %s.\n" '${MAILSENDER_PW}'; \
+ sed -e 's|sender_pw_goes_here|$(MAILSENDER_PW)|g' link-tmpl-template.cgi > link-tmpl.cgi; \
+ else\
+ printf "\t${RED}Password for the sender address wasn't set in your config.mk. Fix this${STOP}.\n";\
+ $(MAKE) clean ; \
+ exit 1; \
+ fi; \
+ if test -n '$(SMTP_DOMAIN)'; then \
+ printf "\tSMTP server: ${BOLD}$(SMTP_DOMAIN)${STOP}\n"; \
+ sed -e 's|smtp_domain_goes_here|$(SMTP_DOMAIN)|g' link-tmpl-template.cgi > link-tmpl.cgi; \
+ else\
+ printf "\t${RED}No SMTP server was configured in your config.mk. Fix this.${STOP}\n";\
+ $(MAKE) clean ; \
+ exit 1; \
+ fi; \
+ if test -n '$(SMTP_PORT)'; then \
+ printf "\tSMTP port: ${BOLD}$(SMTP_PORT)${STOP}\n"; \
+ sed -e 's|smtp_port_goes_here|$(SMTP_PORT)|g' link-tmpl-template.cgi > link-tmpl.cgi; \
+ else \
+ printf "\t${RED}No SMTP port configured in your config.mk. Fix this${STOP}.\n"; \
+ $(MAKE) clean ; \
+ exit 1; \
+ fi; \
+ fi
+ @sed -e 's|has_mailserver_goes_here|$(HAS_MAILSERVER)|g' link-tmpl-template.cgi > link-tmpl.cgi;
+ @sed -e 's|gpg_homedir_goes_here|$(_GPG_HOMEDIR)|g' link-tmpl-template.cgi > link-tmpl.cgi;
+ @sed -e 's|gpg_homedir_goes_here|$(_GPG_HOMEDIR)|g' gpigeon-template.cgi > gpigeonctl;
+ @if test -n '$(WWWDOMAIN)' && test -n '$(WWWPREFIX)'; then\
+ $(MAKE) nginxconf;\
+ printf "Done generating $(WWWDOMAIN).conf for nginx.";\
+ fi
+ @printf "\nDone preparing files. You can now type\n\t$$ sudo make install\nin your terminal.\n"
+
+install:
+ $(MAKE) gpigeon;
+ mkdir -p $(DESTDIR)$(COOKIES_DIR);
+ mkdir -m700 -p $(DESTDIR)$(_GPG_HOMEDIR)
+ gpg --homedir "$(DESTDIR)$(_GPG_HOMEDIR)" --import gpg.txt; \
+ mkdir -p $(DESTDIR)$(WWWPREFIX)/cgi-bin/l
+ install -Dm700 gpigeon.cgi $(DESTDIR)$(GPIGEON_PATH)
+ install -Dm600 link-tmpl.cgi $(DESTDIR)$(LINK_TEMPLATE_PATH)
+ install -Dm644 index.html favicon.ico styles.css -t $(DESTDIR)$(WWWPREFIX)/
+ install -Dm755 merci/* -t $(DESTDIR)$(PREFIX)/merci/
+ @if test -e '$(WWWDOMAIN).conf'; then\
+ printf "\nInstalling $(WWWDOMAIN).conf into $(NGINXCONFDIR)\n";\
+ install -Dm644 $(WWWDOMAIN).conf -t $(DESTDIR)$(NGINXCONFDIR);\
+ fi
+
+nginxconf: nginx-example.conf
+ @sed -e 's|wwwpath_goes_here|$(WWWPREFIX)|g;s|domain_goes_here|$(WWWDOMAIN)|g' nginx-example.conf > $(WWWDOMAIN).conf ;\
+
+
+uninstall:
+ rm -rf $(DESTDIR)$(PREFIX)
+ rm -rf $(DESTDIR)$(WWWPREFIX)
+
+clean:
+ rm -f genpass.txt gpg.txt link-tmpl.cgi gpigeon.cgi $(WWWDOMAIN).conf the.db
+
+.PHONY: clean install uninstall