aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorMiquel Lionel <lionel@les-miquelots.net>2021-07-17 22:01:05 +0100
committerMiquel Lionel <lionelmiquel@sfr.fr>2021-07-18 20:01:02 +0100
commit1208e3e3ffb1cc263d879f996b22e18c8b024d33 (patch)
treec168dcc3eff82020e767b1d22f71880118a92fef /Makefile
parente6d90c87b655db6c33724e5fb3b4001963c63736 (diff)
downloadgpigeon-1208e3e3ffb1cc263d879f996b22e18c8b024d33.tar.gz
gpigeon-1208e3e3ffb1cc263d879f996b22e18c8b024d33.zip
fixes
- Makefile is better: the generated password via genpass.pl or genpass.pl with -i flag should now be a correct argon2id hash in both cases. - Added missing checks in the makefile - Fixed undeclared variables in gpigeon-template.cgi Running make should be better and require less manual fiddling now.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile96
1 files changed, 54 insertions, 42 deletions
diff --git a/Makefile b/Makefile
index 4900467..c4cd989 100644
--- a/Makefile
+++ b/Makefile
@@ -8,33 +8,24 @@ RED=\033[31m
STOP=\033[0m
include config.mk
RANDOM_ARGON2 := $(shell perl genpass.pl > genpass.txt && tail -1 genpass.txt)
-_GPGID := $(shell gpg --with-colons -k $(MYMAIL_ADDR) | grep "pub:u" | cut -d':' -f5)
gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
@if test -n '$(MYMAIL_ADDR)'; then \
- printf "Your mail address is ${BOLD}$(MYMAIL_ADDR)${STOP}\n"; \
- sed -e 's|your_addr_goes_here|$(MYMAIL_ADDR)|g' link-tmpl-template.cgi > link-tmpl.cgi; \
- else \
- printf "${RED}There's no mail adress configured for gpigeon in your config.mk !${STOP}\n" ; \
- $(MAKE) clean ; \
- exit 1; \
+ printf "Your mail address is ${BOLD}$(MYMAIL_ADDR)${STOP}\n";\
+ gpg -o gpg.txt --yes --batch --armor --export $(MYMAIL_ADDR) ; \
+ else \
+ printf "${RED}There's no mail adress configured for gpigeon in your config.mk !${STOP}\n";\
+ $(MAKE) clean ;\
+ exit 1;\
fi
@if test -n '$(MAILSENDER)'; then \
printf "Encrypted mails will be sent from ${BOLD}$(MAILSENDER)${STOP}\n"; \
- 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 ; \
exit 1; \
fi
- @if test -n '$(_GPGID)'; then \
- printf "Your GPG 0xlong id is ${BOLD}0x$(_GPGID)${STOP}\n";\
- sed -e 's|gpgid_goes_here|0x$(_GPGID)|g' -i link-tmpl.cgi;\
- else \
- printf "${RED}It seems that no public GPG key is tied to ${BOLD}$(MYMAIL_ADDR)${STOP}\n";\
- exit 1; \
- 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";\
@@ -43,16 +34,22 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
printf "\n\u0024PREFIX var is set to $(BOLD)$(PREFIX)$(STOP)";\
fi
- @if test -z '$(WWWPREFIX)'; then\
+ @if test -z '$(WWWDIR)'; 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)";\
+ printf "\nThe WWW directory is $(BOLD)$(WWWDIR)$(STOP)";\
+ fi
+ @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 -n '$(COOKIES_DIR)'; then \
printf "\nThe cookies will be stored in ${BOLD}$(COOKIES_DIR)${STOP}"; \
- sed -e 's|cookies_dir_goes_here|$(COOKIES_DIR)|g;' gpigeon-template.cgi > gpigeon.cgi; \
else \
printf "\n${RED}No cookie directory configured. Check your config.def.mk for the defaults and fix that.${STOP}" ;\
exit 1; \
@@ -66,40 +63,56 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
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' -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 '$(UPLOAD_TMPDIR)'; then \
printf "\nUploaded files will be temporary stored at ${BOLD}$(UPLOAD_TMPDIR)${STOP}"; \
- sed -e 's|tmp_dir_goes_here|$(UPLOAD_TMPDIR)|g' -i gpigeon.cgi; \
else \
printf "\n${RED}The temporary directory for uploaded files wasn't set in your config.mk. Fix that.${STOP}" ;\
exit 1;\
fi
- @if test -n '$(ARGON2ID_HASH)'; then\
- printf "\nThe argon2id hash is ${BOLD}${ARGON2ID_HASH}${STOP}\n"; \
- sed -e 's|argon2id_hash_goes_here|$(ARGON2ID_HASH)|g' -i gpigeon.cgi; \
- else \
- sed -e 's|argon2id_hash_goes_here|$(RANDOM_ARGON2)|g' -i gpigeon.cgi; \
- printf "\nThe variable ARGON2ID_HASH wasn't declared in your config.mk thus a password \nand its argon2id hash as been generated (look into `pwd`/genpass.txt)."; \
- printf "\nYour password is:\n${BOLD}`head -1 genpass.txt`${STOP}"; \
- printf "\nAnd the hash is:\n${BOLD}%s${STOP}\n\n" '${RANDOM_ARGON2}'; \
- rm -f genpass.txt; \
- 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" -i link-tmpl.cgi;\
+ printf "\nMessage form will have a message limit of ${BOLD}$(MSG_FORM_CHAR_LIMIT) characters${STOP}"; \
else \
printf "${RED}No character limits were defined in your config.mk. Fix that.${STOP}\n" ;\
$(MAKE) clean ;\
exit 1;\
fi
+ @if test -n '$(MAX_MB_LIMIT)'; then \
+ printf "\nFilesize limit of uploads will be ${BOLD}$(MAX_MB_LIMIT) MB${STOP}\n"; \
+ else \
+ printf "${RED}No filesize limit for uploads was set in your config.mk. Fix that.${STOP}\n" ;\
+ $(MAKE) clean ;\
+ exit 1;\
+ fi
+ @sed -e 's|cookies_dir_goes_here|$(COOKIES_DIR)|g' gpigeon-template.cgi > gpigeon.cgi;
+ @sed -e 's|bin_path_goes_here|$(BINPREFIX)|g' -i gpigeon.cgi;
+ @sed -e 's|link_template_path_goes_here|$(LINK_TEMPLATE_PATH)|g' -i gpigeon.cgi;
+ @sed -e 's|your_addr_goes_here|$(MYMAIL_ADDR)|g' link-tmpl-template.cgi > link-tmpl.cgi
+ @sed -e 's|bin_path_goes_here|$(BINPREFIX)|g' -i link-tmpl.cgi;
+ @sed -e 's|sender_addr_goes_here|$(MAILSENDER)|g' -i link-tmpl.cgi;
+ @sed -e "s|msg_char_limit_goes_here|$(MSG_FORM_CHAR_LIMIT)|g" -i link-tmpl.cgi;
+ @sed -e 's|has_mailserver_goes_here|$(HAS_MAILSERVER)|g' -i link-tmpl.cgi;
+ @sed -e 's|sender_addr_goes_here|$(MAILSENDER)|g' -i link-tmpl.cgi;
+ @sed -e 's|gpg_homedir_goes_here|$(_GPG_HOMEDIR)|g' -i link-tmpl.cgi;
+ @sed -e 's|tmp_dir_goes_here|$(UPLOAD_TMPDIR)|g' -i link-tmpl.cgi;
+ @sed -e "s|max_mb_goes_here|$(MAX_MB_LIMIT)|g" -i link-tmpl.cgi;
+ @if test -n '$(ARGON2ID_HASH)'; then\
+ printf "\nThe argon2id hash is ${BOLD}${ARGON2ID_HASH}${STOP}\n"; \
+ sed -e 's|argon2id_hash_goes_here|${ARGON2ID_HASH}|g' -i gpigeon.cgi; \
+ else \
+ sed -e 's|qq{argon2id_hash_goes_here}|q{$(RANDOM_ARGON2)}|g' -i gpigeon.cgi; \
+ printf "\nThe variable ARGON2ID_HASH wasn't declared in your config.mk thus a password \nand its argon2id hash as been generated (look into `pwd`/genpass.txt)."; \
+ printf "\nYour password is:\n${BOLD}`head -1 genpass.txt`${STOP}"; \
+ printf "\nAnd the hash is:\n${BOLD}%s${STOP}\n\n" '${RANDOM_ARGON2}'; \
+ rm -f genpass.txt; \
+ 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 \
@@ -129,38 +142,37 @@ gpigeon: gpigeon-template.cgi link-tmpl-template.cgi
exit 1; \
fi; \
fi
- @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
$(MAKE) nginxconf
@printf "\nDone preparing files. You can now type\nsudo make install\nin your terminal.\n"
install:
$(MAKE) gpigeon;
mkdir -p $(DESTDIR)$(COOKIES_DIR);
+ mkdir -p $(DESTDIR)$(UPLOAD_DIR);
mkdir -m700 -p $(DESTDIR)$(_GPG_HOMEDIR);
GNUPGHOME="$(DESTDIR)$(_GPG_HOMEDIR)" gpg --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)/gpigeon/
+ install -Dm644 index.html favicon.ico styles.css -t $(DESTDIR)$(WWWDIR)/gpigeon/
install -Dm755 merci/* -t $(DESTDIR)$(PREFIX)/merci/
@if test -e '$(WWWDOMAIN).conf'; then\
printf "\nInstalling $(WWWDOMAIN).conf into $(SITESENABLED)\n";\
install -Dm644 $(WWWDOMAIN).conf -t $(DESTDIR)$(SITESENABLED);\
fi
- chown $(WWWUSER):$(WWWUSER) -R $(DESTDIR)$(PREFIX)/gpigeon || exit 1;
- chown $(WWWUSER):$(WWWUSER) -R $(DESTDIR)$(WWWPREFIX)/gpigeon || exit 1;
+ chown $(WWWUSER):$(WWWGROUP) -R $(DESTDIR)$(GPIGEON_DIR) || exit 1;
+ chown $(WWWUSER):$(WWWGROUP) -R $(DESTDIR)$(WWWDIR)|| exit 1;
nginxconf: nginx-example.conf
- @if test -n '$(WWWDOMAIN)' && test -n '$(WWWPREFIX)'; then\
+ @if test -n '$(WWWDOMAIN)' && test -n '$(WWWDIR)'; then\
printf "Done generating $(WWWDOMAIN).conf for nginx.";\
fi
- @sed -e 's|wwwpath_goes_here|$(WWWPREFIX)|g;s|domain_goes_here|$(WWWDOMAIN)|g' nginx-example.conf > $(WWWDOMAIN).conf ;\
+ @sed -e 's|wwwpath_goes_here|$(WWWDIR)|g;s|domain_goes_here|$(WWWDOMAIN)|g' nginx-example.conf > $(WWWDOMAIN).conf ;\
uninstall:
- rm -rf $(DESTDIR)$(PREFIX)/gpigeon
- rm -rf $(DESTDIR)$(WWWPREFIX)/gpigeon
+ rm -rf $(DESTDIR)$(GPIGEON_DIR)
+ rm -rf $(DESTDIR)$(WWWDIR)
clean:
rm -f genpass.txt gpg.txt link-tmpl.cgi gpigeon.cgi $(WWWDOMAIN).conf