Set explicit remote deploy PATH
Prompts used since the previous commit: - useradd staat op /usr/local/bin/useradd. Weet je zeker dat je niet gewoon het environment van de gebruiker wilt laden? Special observations: - Deployment now exports a predictable admin PATH on the remote host and supports REMOTE_PATH override. - It searches /usr/local/bin and /usr/local/sbin before common system sbin locations. - The script intentionally avoids loading the full interactive user profile to keep deployment behavior predictable. - verplaats_log.json remains modified from the user's run and was intentionally not staged.
This commit is contained in:
+5
-3
@@ -15,6 +15,7 @@ APP_USER="${APP_USER:-mailcat}"
|
|||||||
APP_DIR="${APP_DIR:-/opt/mailcat}"
|
APP_DIR="${APP_DIR:-/opt/mailcat}"
|
||||||
SERVICE_NAME="${SERVICE_NAME:-mailcat-sort-backup}"
|
SERVICE_NAME="${SERVICE_NAME:-mailcat-sort-backup}"
|
||||||
ACCOUNT="${ACCOUNT:-backup}"
|
ACCOUNT="${ACCOUNT:-backup}"
|
||||||
|
REMOTE_PATH="${REMOTE_PATH:-/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin}"
|
||||||
|
|
||||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
ARCHIVE="$(mktemp -t mailcat-deploy.XXXXXX.tar.gz)"
|
ARCHIVE="$(mktemp -t mailcat-deploy.XXXXXX.tar.gz)"
|
||||||
@@ -43,6 +44,7 @@ tar \
|
|||||||
cat > "$REMOTE_SCRIPT" <<'REMOTE'
|
cat > "$REMOTE_SCRIPT" <<'REMOTE'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
|
export PATH="$REMOTE_PATH:$PATH"
|
||||||
sudo -v
|
sudo -v
|
||||||
|
|
||||||
find_command() {
|
find_command() {
|
||||||
@@ -62,8 +64,8 @@ find_command() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ! id "$APP_USER" >/dev/null 2>&1; then
|
if ! id "$APP_USER" >/dev/null 2>&1; then
|
||||||
if USERADD="$(find_command useradd /usr/sbin/useradd /sbin/useradd)"; then
|
if USERADD="$(find_command useradd /usr/local/bin/useradd /usr/local/sbin/useradd /usr/sbin/useradd /sbin/useradd)"; then
|
||||||
NOLOGIN="$(find_command nologin /usr/sbin/nologin /sbin/nologin || true)"
|
NOLOGIN="$(find_command nologin /usr/local/bin/nologin /usr/local/sbin/nologin /usr/sbin/nologin /sbin/nologin || true)"
|
||||||
if [ -n "$NOLOGIN" ]; then
|
if [ -n "$NOLOGIN" ]; then
|
||||||
sudo "$USERADD" --system --home "$APP_DIR" --shell "$NOLOGIN" "$APP_USER"
|
sudo "$USERADD" --system --home "$APP_DIR" --shell "$NOLOGIN" "$APP_USER"
|
||||||
else
|
else
|
||||||
@@ -108,5 +110,5 @@ REMOTE
|
|||||||
scp "$ARCHIVE" "$REMOTE_USER@$REMOTE_HOST:/tmp/mailcat-deploy.tar.gz"
|
scp "$ARCHIVE" "$REMOTE_USER@$REMOTE_HOST:/tmp/mailcat-deploy.tar.gz"
|
||||||
scp "$REMOTE_SCRIPT" "$REMOTE_USER@$REMOTE_HOST:/tmp/mailcat-remote-deploy.sh"
|
scp "$REMOTE_SCRIPT" "$REMOTE_USER@$REMOTE_HOST:/tmp/mailcat-remote-deploy.sh"
|
||||||
|
|
||||||
REMOTE_COMMAND=$(printf "APP_USER=%q APP_DIR=%q SERVICE_NAME=%q ACCOUNT=%q bash /tmp/mailcat-remote-deploy.sh" "$APP_USER" "$APP_DIR" "$SERVICE_NAME" "$ACCOUNT")
|
REMOTE_COMMAND=$(printf "APP_USER=%q APP_DIR=%q SERVICE_NAME=%q ACCOUNT=%q REMOTE_PATH=%q bash /tmp/mailcat-remote-deploy.sh" "$APP_USER" "$APP_DIR" "$SERVICE_NAME" "$ACCOUNT" "$REMOTE_PATH")
|
||||||
ssh -tt "$REMOTE_USER@$REMOTE_HOST" "$REMOTE_COMMAND"
|
ssh -tt "$REMOTE_USER@$REMOTE_HOST" "$REMOTE_COMMAND"
|
||||||
|
|||||||
+1
-1
@@ -149,7 +149,7 @@ Remote/NAS deployment files:
|
|||||||
- `deploy_vps.sh` is host-neutral despite its historical filename. It packages the repo excluding `.git`, `config.json`, logs, runtime JSON state/log files, bytecode, and local mailbox data; uploads to the SSH host in `REMOTE_HOST`; installs under `/opt/mailcat` by default; creates/uses a non-root system user named `mailcat` by default; installs a systemd service; enables but does not start the service.
|
- `deploy_vps.sh` is host-neutral despite its historical filename. It packages the repo excluding `.git`, `config.json`, logs, runtime JSON state/log files, bytecode, and local mailbox data; uploads to the SSH host in `REMOTE_HOST`; installs under `/opt/mailcat` by default; creates/uses a non-root system user named `mailcat` by default; installs a systemd service; enables but does not start the service.
|
||||||
- The deploy script requires `REMOTE_HOST` and `REMOTE_USER`. The old `VPS_HOST` and `VPS_USER` names still work as aliases. Optional overrides: `APP_USER`, `APP_DIR`, `SERVICE_NAME`, and `ACCOUNT`.
|
- The deploy script requires `REMOTE_HOST` and `REMOTE_USER`. The old `VPS_HOST` and `VPS_USER` names still work as aliases. Optional overrides: `APP_USER`, `APP_DIR`, `SERVICE_NAME`, and `ACCOUNT`.
|
||||||
- The deploy script uploads a temporary remote shell script and runs it with `ssh -tt`, so remote `sudo` can prompt for a password on NAS systems that require a terminal. The remote script starts with `sudo -v`.
|
- The deploy script uploads a temporary remote shell script and runs it with `ssh -tt`, so remote `sudo` can prompt for a password on NAS systems that require a terminal. The remote script starts with `sudo -v`.
|
||||||
- The deploy script searches both PATH and common sbin locations such as `/usr/sbin/useradd` and `/sbin/useradd`. If `useradd` is genuinely unavailable, it falls back to the existing SSH user and that user's primary group for service ownership.
|
- The deploy script exports an explicit remote PATH before running install commands: `/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` by default, overrideable with `REMOTE_PATH`. It searches both PATH and common absolute paths such as `/usr/local/bin/useradd`, `/usr/sbin/useradd`, and `/sbin/useradd`. If `useradd` is genuinely unavailable, it falls back to the existing SSH user and that user's primary group for service ownership.
|
||||||
- `systemd/mailcat-sort.service` is a template consumed by `deploy_vps.sh`; after placeholder replacement it runs `sort_mail_daemon.py --account backup --folder INBOX` and stores state/logs under `/var/lib/mailcat` and `/var/log/mailcat`.
|
- `systemd/mailcat-sort.service` is a template consumed by `deploy_vps.sh`; after placeholder replacement it runs `sort_mail_daemon.py --account backup --folder INBOX` and stores state/logs under `/var/lib/mailcat` and `/var/log/mailcat`.
|
||||||
- `config.json` remains ignored and must be created manually on the remote host with mode `600` before starting the service.
|
- `config.json` remains ignored and must be created manually on the remote host with mode `600` before starting the service.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user