aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorJason McCormick <jason@mfamily.org>2026-11-05 18:20:34 -0500
committerJason McCormick <jason@mfamily.org>2026-11-05 18:20:34 -0500
commit75719aa37f7317f3a8feeb516f1444edb4274410 (patch)
tree36e7e0454ad0044ebc72a253935790afc389843c /Makefile
parent67383e6863fcff8b49e680b5b861b3154f8cb518 (diff)
feat: TOML config and upload notification watcher
Replace allowed-uris.txt with config.toml: [GLOBAL] holds SMTP settings (send_as, smtp_server, smtp_port, tls, starttls) and every other stanza is an upload URI with a recipient and optional view_url_prefix. Add watcher.py, run every 5 minutes by a systemd timer, which emails each drop's recipient once per run when new images appeared in the last slot. The email links each image under view_url_prefix and includes its .txt submission details. Fix the service unit and Makefile to use CONFIG_FILE, install the watcher and its units, and validate the config before restarting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile22
1 files changed, 17 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 436587b..dd8db60 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,10 @@ SHELL := /bin/sh
APP_DIR := /opt/blind-uploader
SYSTEMD_UNIT := /etc/systemd/system/blind-uploader.service
-TARGETS_FILE := /etc/blind-uploader/allowed-uris
+WATCHER_UNIT := /etc/systemd/system/blind-uploader-watcher.service
+WATCHER_TIMER := /etc/systemd/system/blind-uploader-watcher.timer
+CONFIG_FILE := /etc/blind-uploader/config.toml
+LEGACY_TARGETS_FILE := /etc/blind-uploader/allowed-uris
UPLOAD_STATE_DIR := /var/lib/blind-uploader/uploads
DOMAIN ?= upload.example.com
NGINX_CONFIG := /etc/nginx/sites-available/$(DOMAIN)
@@ -27,14 +30,21 @@ prerequisites:
install: prerequisites
install -d -o root -g root -m 0755 $(APP_DIR) $(APP_DIR)/static
install -o root -g root -m 0755 server.py $(APP_DIR)/server.py
+ install -o root -g root -m 0755 watcher.py $(APP_DIR)/watcher.py
install -o root -g root -m 0644 README.md $(APP_DIR)/README.md
install -o root -g root -m 0644 static/index.html static/styles.css static/app.js $(APP_DIR)/static/
- install -d -o root -g www-data -m 0750 $$(dirname $(TARGETS_FILE))
- @test -e $(TARGETS_FILE) || install -o root -g www-data -m 0640 allowed-uris.txt $(TARGETS_FILE)
- chown root:www-data $(TARGETS_FILE)
- chmod 0640 $(TARGETS_FILE)
+ install -d -o root -g www-data -m 0750 $$(dirname $(CONFIG_FILE))
+ @test -e $(CONFIG_FILE) || install -o root -g www-data -m 0640 config.toml $(CONFIG_FILE)
+ chown root:www-data $(CONFIG_FILE)
+ chmod 0640 $(CONFIG_FILE)
+ @if test -e $(LEGACY_TARGETS_FILE); then \
+ echo "WARNING: $(LEGACY_TARGETS_FILE) is no longer used; move its URIs into $(CONFIG_FILE) as stanzas." >&2; \
+ fi
+ python3 -B -c 'import sys; sys.path.insert(0, "$(APP_DIR)"); from server import load_config; from pathlib import Path; load_config(Path("$(CONFIG_FILE)"))'
install -d -o www-data -g www-data -m 0700 /var/lib/blind-uploader $(UPLOAD_STATE_DIR)
install -o root -g root -m 0644 deploy/blind-uploader.service $(SYSTEMD_UNIT)
+ install -o root -g root -m 0644 deploy/blind-uploader-watcher.service $(WATCHER_UNIT)
+ install -o root -g root -m 0644 deploy/blind-uploader-watcher.timer $(WATCHER_TIMER)
@if test ! -e $(NGINX_CONFIG); then \
sed 's/upload\.example\.com/$(DOMAIN)/g' deploy/nginx-blind-uploader.conf > $(NGINX_CONFIG); \
chown root:root $(NGINX_CONFIG); \
@@ -44,6 +54,8 @@ install: prerequisites
systemctl daemon-reload
systemctl enable blind-uploader.service
systemctl restart blind-uploader.service
+ systemctl enable --now blind-uploader-watcher.timer
systemctl reload nginx
@echo "Private Drop installed for http://$(DOMAIN)"
@echo "Uploads will be stored privately under /var/lib/blind-uploader/uploads"
+ @echo "Edit $(CONFIG_FILE) for SMTP settings and upload URIs, then: systemctl restart blind-uploader.service"