Allow remote NAS deployment target

Prompts used since the previous commit:
- Ik wil dit testen op mijn NAS, die lokaal hier in huis draait. Dus niet op vps.australius.nl. Kan dat ook?

Special observations:
- deploy_vps.sh now accepts REMOTE_HOST and REMOTE_USER, with VPS_HOST/VPS_USER kept as aliases.
- The current service install path still assumes a Linux/systemd target with sudo; Synology/QNAP-style NAS deployment may need scheduler or container adaptation.
- verplaats_log.json remains modified from the user's run and was intentionally not staged.
This commit is contained in:
2026-07-04 20:02:43 +02:00
parent 5c0e345fd8
commit 5932e8927e
2 changed files with 25 additions and 17 deletions
+13 -5
View File
@@ -1,8 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
VPS_HOST="${VPS_HOST:-vps.austalius.nl}"
VPS_USER="${VPS_USER:?Set VPS_USER to the non-root sudo SSH user}"
REMOTE_HOST="${REMOTE_HOST:-${VPS_HOST:-}}"
REMOTE_USER="${REMOTE_USER:-${VPS_USER:-}}"
if [ -z "$REMOTE_HOST" ]; then
echo "Set REMOTE_HOST to the SSH host or IP address, for example a local NAS hostname." >&2
exit 2
fi
if [ -z "$REMOTE_USER" ]; then
echo "Set REMOTE_USER to the non-root sudo SSH user." >&2
exit 2
fi
APP_USER="${APP_USER:-mailcat}"
APP_DIR="${APP_DIR:-/opt/mailcat}"
SERVICE_NAME="${SERVICE_NAME:-mailcat-sort-backup}"
@@ -30,9 +38,9 @@ tar \
-C "$ROOT_DIR" \
-czf "$ARCHIVE" .
scp "$ARCHIVE" "$VPS_USER@$VPS_HOST:/tmp/mailcat-deploy.tar.gz"
scp "$ARCHIVE" "$REMOTE_USER@$REMOTE_HOST:/tmp/mailcat-deploy.tar.gz"
ssh "$VPS_USER@$VPS_HOST" \
ssh "$REMOTE_USER@$REMOTE_HOST" \
"APP_USER='$APP_USER' APP_DIR='$APP_DIR' SERVICE_NAME='$SERVICE_NAME' ACCOUNT='$ACCOUNT' bash -s" <<'REMOTE'
set -euo pipefail
@@ -46,7 +54,7 @@ sudo chown -R "$APP_USER:$APP_USER" "$APP_DIR" /var/lib/mailcat /var/log/mailcat
sudo chmod 750 "$APP_DIR"
if [ ! -f "$APP_DIR/config.json" ]; then
echo "Missing $APP_DIR/config.json on VPS. Create it with mode 600 before starting the service." >&2
echo "Missing $APP_DIR/config.json on remote host. Create it with mode 600 before starting the service." >&2
fi
sudo chmod 600 "$APP_DIR/config.json" 2>/dev/null || true
sudo chown "$APP_USER:$APP_USER" "$APP_DIR/config.json" 2>/dev/null || true