summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile38
1 files changed, 38 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..42cdea6
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,38 @@
+SHELL := /bin/sh
+
+APP_DIR := /opt/blind-uploader
+SYSTEMD_UNIT := /etc/systemd/system/blind-uploader.service
+NGINX_CONFIG := /etc/nginx/conf.d/blind-uploader.conf
+DOMAIN ?= upload.example.com
+
+.PHONY: help check prerequisites install
+
+help:
+ @echo "Targets:"
+ @echo " make check Run the automated tests"
+ @echo " sudo make install DOMAIN=... Install and start the application"
+
+check:
+ python3 -m unittest discover -s tests -v
+
+prerequisites:
+ @test "$$(id -u)" -eq 0 || { echo "Run installation as root: sudo make install DOMAIN=upload.example.com" >&2; exit 1; }
+ @for command in python3 install systemctl nginx sed; do \
+ command -v "$$command" >/dev/null 2>&1 || { echo "Required command not found: $$command" >&2; exit 1; }; \
+ done
+
+install: prerequisites
+ install -d -m 0755 $(APP_DIR) $(APP_DIR)/static
+ install -m 0755 server.py $(APP_DIR)/server.py
+ install -m 0644 README.md $(APP_DIR)/README.md
+ install -m 0644 static/index.html static/styles.css static/app.js $(APP_DIR)/static/
+ install -m 0644 deploy/blind-uploader.service $(SYSTEMD_UNIT)
+ install -d -m 0755 $$(dirname $(NGINX_CONFIG))
+ sed 's/upload\.example\.com/$(DOMAIN)/g' deploy/nginx-blind-uploader.conf > $(NGINX_CONFIG)
+ chmod 0644 $(NGINX_CONFIG)
+ nginx -t
+ systemctl daemon-reload
+ systemctl enable --now blind-uploader.service
+ systemctl reload nginx
+ @echo "Private Drop installed for http://$(DOMAIN)"
+ @echo "Uploads will be stored privately under /var/lib/blind-uploader/uploads"