testsAndMisc/linux_configuration/scripts/single_use/features/systemd/dufs.service
Krzysztof kuhy Rudnicki 20bc1aeb02 linux_configuration: self-hosted dufs cloud storage + KeePass WebDAV auto-sync
Add setup_dufs_cloud.sh: a self-sustaining installer that stands up dufs
(single Rust binary; web UI + built-in WebDAV) on 127.0.0.1:5000 behind the
existing Caddy + DuckDNS exposure stack at a new subdomain, so files are
reachable from mobile network over HTTPS. An event-driven systemd path unit
mirrors ~/Keepass/Passwords.kdbx into the served folder on every change, so
KeePassDX syncs the vault natively over WebDAV.

Paranoid secret handling for the gitignored .dufs_cloud.conf (plaintext web
password): ignored at repo-root + linux_configuration + **/ globs; a new
check-no-dufs-conf pre-commit hook blocks it even against `git add -f`; the
installer refuses to write it unless git check-ignore confirms it is ignored;
the password is hashed via `openssl passwd -6 -stdin` (never in argv); and a
cloud-root guard forbids serving home/.ssh/.config/.gnupg/the repo/root.

Verified: dufs auth (401/200) + WebDAV (207) against the real v0.46.0 binary,
idempotent Caddy/DuckDNS/unit-render logic, and a live phone-on-cellular test.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0126QvdMrv2WNeUVShFiLTc3
2026-07-12 03:40:54 +02:00

23 lines
745 B
Desktop File

[Unit]
# dufs self-hosted cloud file server (web UI + WebDAV), bound to loopback and
# fronted by the existing Caddy reverse proxy for public HTTPS.
# Placeholders (__USER__ / __HOME__) are substituted by setup_dufs_cloud.sh at
# install time; this file is the source of truth, not the installed copy.
Description=dufs self-hosted cloud file server
Documentation=https://github.com/sigoden/dufs
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=__USER__
ExecStart=/usr/local/bin/dufs --config __HOME__/.config/dufs/dufs.yaml
Restart=on-failure
RestartSec=3
# Minimal hardening (dufs needs $HOME/.config and the served dir under /home).
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target