diff options
author | Miquel Lionel <lionel@les-miquelots.net> | 2021-06-24 13:53:58 +0100 |
---|---|---|
committer | Miquel Lionel <lionelmiquel@sfr.fr> | 2021-07-02 01:21:59 +0100 |
commit | de854ac0a8fe72a1b0d0137c351b39de25e0adfe (patch) | |
tree | ae1386ade7ebb65e2b269347b09c8ced87fb614f /Makefile | |
parent | 420155e750c4b95dd4327d7adb4310a64eafb364 (diff) | |
download | gpigeon-de854ac0a8fe72a1b0d0137c351b39de25e0adfe.tar.gz gpigeon-de854ac0a8fe72a1b0d0137c351b39de25e0adfe.zip |
Implemented very basic multi-user support
- the `gpigeonctl' script is used to initialize the database, add an user and delete it,
clear cookies. More info in the readme about it.
- tweaked gpigeon-template.cgi and link-template-tmpl.cgi to
support multiusers
- tweaked the Makefile
- tweaked the config.def.mk and added WWWUSER and WWWDIR
variables
- made some ajustements in the styles.css file for
responsivity.
- added some headers for security in nginx-example.conf
- added gpigeonctl.def which serves as a "blueprint" for gpigeonctl
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 92 |
1 files changed, 57 insertions, 35 deletions
@@ -1,28 +1,37 @@ .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 '$(BINPREFIX)'; then \ + printf "\n$(RED)No \u0024BINPREFIX variable defined in config.mk.\n";\ + printf "Look into config.def.mk for the defaults and fix that in your config.mk.$(STOP)\n";\ + exit 1;\ + else \ + printf "\n\u0024BINPREFIX var is set to $(BOLD)$(BINPREFIX)$(STOP)";\ + fi @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";\ + printf "Look into config.def.mk for the defaults and fix that in your config.mk.$(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}";\ + printf "\n${RED}No web directory defined in config.mk. Check your config.def.mk for the defaults and fix that in your config.mk.${STOP}";\ exit 1; \ else \ - printf "\nThe WWW directory is $(BOLD)$(WWWPREFIX)$(STOP)";\ + printf "\nThe WWW directory is $(BOLD)$(WWWDIR)$(STOP)";\ + fi + @if test -z '$(DB_PATH)'; then\ + printf "\n${RED}No database path defined in config.mk. Check your config.def.mk for the defaults and fix that in your config.mk$(STOP)";\ + exit 1; \ + else \ + printf "\nThe path to the SQLite database is $(BOLD)$(DB_PATH)$(STOP)";\ + sed -e 's|db_path_goes_here|$(DB_PATH)|g' gpigeon-template.cgi > gpigeon.cgi;\ fi @if test -n '$(_GPG_HOMEDIR)'; then \ @@ -32,28 +41,31 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi $(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; \ + printf "\nLink template is at ${BOLD}$(LINK_TEMPLATE_PATH)${STOP}\n"; \ + sed -e 's|link_template_path_goes_here|$(LINK_TEMPLATE_PATH)|g' -i 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"; \ + 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;\ + 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; \ + sed -e 's|sender_addr_goes_here|$(MAILSENDER)|g' -i link-tmpl.cgi; \ else \ printf "\t${RED}No mail sender adress configured in your config.mk. Fix this.${STOP}\n" ; \ $(MAKE) clean ; \ @@ -61,7 +73,7 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi 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; \ + sed -e 's|sender_pw_goes_here|$(MAILSENDER_PW)|g' -i 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 ; \ @@ -69,7 +81,7 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi 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; \ + sed -e 's|smtp_domain_goes_here|$(SMTP_DOMAIN)|g' -i link-tmpl.cgi; \ else\ printf "\t${RED}No SMTP server was configured in your config.mk. Fix this.${STOP}\n";\ $(MAKE) clean ; \ @@ -77,46 +89,56 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi 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; \ + sed -e 's|smtp_port_goes_here|$(SMTP_PORT)|g' -i 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; + + @sed -e 's|has_mailserver_goes_here|$(HAS_MAILSERVER)|g' -i link-tmpl.cgi; + @sed -e 's|gpg_homedir_goes_here|$(_GPG_HOMEDIR)|g' -i link-tmpl.cgi; @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" - + +gpigeonctl: gpigeonctl.def.pl + @sed -e 's|gpgdir_goes_here|$(_GPG_HOMEDIR)|g' gpigeonctl.def.pl > gpigeonctl; + @sed -e 's|cookies_dir_goes_here|$(COOKIES_DIR)|g' -i gpigeonctl ; + @sed -e 's|db_path_goes_here|$(DB_PATH)|g' -i gpigeonctl; + @sed -e 's|web_user_goes_here|$(WWWUSER)|g' -i gpigeonctl; + @sed -e 's|web_dir_goes_here|$(WWWDIR)|g' -i gpigeonctl; + chmod +x gpigeonctl; + install: - $(MAKE) gpigeon; + $(MAKE) gpigeon gpigeonctl; + @if test -n "$(WWWDOMAIN)"; then\ + $(MAKE) nginxconf;\ + printf "\nInstalling $(WWWDOMAIN).conf into $(NGINXCONFDIR)\n";\ + install -Dm644 $(WWWDOMAIN).conf -t $(DESTDIR)$(NGINXCONFDIR);\ + fi 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 + mkdir -p $(DESTDIR)$(WWWDIR)/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 + install -Dm644 index.html favicon.ico styles.css -t $(DESTDIR)$(WWWDIR)/ + install -Dm755 gpigeonctl -t $(DESTDIR)$(BINPREFIX) + @printf "Done. Now execute `gpigeonctl init' to initialize the database.\n" 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) + rm -f $(DESTDIR)$(BINPREFIX)/gpigeonctl + rm -rf $(DESTDIR)$(PREFIX)/gpigeon + rm -rf $(DESTDIR)$(WWWDIR) clean: - rm -f genpass.txt gpg.txt link-tmpl.cgi gpigeon.cgi $(WWWDOMAIN).conf the.db + rm -f genpass.txt gpg.txt link-tmpl.cgi gpigeon.cgi $(WWWDOMAIN).conf the.db gpigeonctl .PHONY: clean install uninstall |