Skip to content

Commit f2575c9

Browse files
leopu00claude
andcommitted
fix(install): write host.env (JHT_HOST_TYPE) on the manual install path too
run_host_setup_vps() returned early unless a --pairing-token was present (desktop-provisioned path), so `curl install.sh | bash` (the manual/tech VPS path) never ran host-setup.sh → ~/.jht/host.env was never written → the wrapper exported JHT_HOST_TYPE=unknown → pid1 booted in mode=local → it SKIPPED the entire cloud block (push daemon + pair-on-boot + the "Sync now" handler). Net effect: cloud sync silently dead on every manually-installed VPS (Sync-now inert, data only via manual push). Generalised to run_host_setup(): runs on both paths. With --pairing-token it forces --host-type=vps (no TTY to confirm); on the manual path it runs host-setup with no flag → detect_vps() auto-detects and, with no TTY, writes the detected JHT_HOST_TYPE without a prompt. Applied to both the served copy (web/public) and scripts/. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 981d12c commit f2575c9

2 files changed

Lines changed: 54 additions & 28 deletions

File tree

scripts/install.sh

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -843,27 +843,40 @@ save_pairing_token() {
843843
ok "Pairing token salvato in $token_file (mode 0644)"
844844
}
845845

846-
run_host_setup_vps() {
847-
# Quando install.sh arriva con --pairing-token, la macchina è una VPS
848-
# provisionata dal desktop launcher: nessun utente al terminale, host-setup
849-
# va lanciato non-interattivo per scrivere ~/.jht/host.env con
850-
# JHT_HOST_TYPE=vps. Senza questo file il container parte in mode=local
851-
# (default backwards-compat del compose) e pid1 salta il pair-on-boot.
852-
[ -z "$PAIRING_TOKEN" ] && return 0
846+
run_host_setup() {
847+
# host-setup.sh scrive ~/.jht/host.env con JHT_HOST_TYPE (+ JHT_LANG + swap).
848+
# SENZA questo file il container parte in mode=local (default backwards-compat
849+
# del compose) e pid1 SALTA tutto il blocco cloud — daemon push + pair-on-boot
850+
# + gestore "Sync now" — quindi il cloud sync è silenziosamente morto. Va
851+
# eseguito su ENTRAMBI i path d'installazione:
852+
# • desktop-provisioned (--pairing-token presente): forza --host-type=vps —
853+
# nessun utente al terminale per confermare l'auto-detection.
854+
# • manuale `curl install.sh | bash`: NESSUN flag → host-setup auto-rileva
855+
# (detect_vps) e, senza TTY, scrive il tipo rilevato senza prompt.
856+
# Regressione fixata 2026-07-09: questo path faceva `return 0` subito →
857+
# host.env mai scritto → container in mode=local → daemon cloud mai avviato.
853858
local hostsetup="$RUNTIME_DIR/host-setup.sh"
854859
if [ ! -x "$hostsetup" ]; then
855-
warn "host-setup.sh non disponibile in $hostsetup — skip preflight VPS"
860+
warn "host-setup.sh non disponibile in $hostsetup — skip preflight"
856861
return 0
857862
fi
858863
if [ "$DRY_RUN" -eq 1 ]; then
859-
info "dry-run: eseguirei $hostsetup --host-type=vps"
864+
info "dry-run: eseguirei $hostsetup${PAIRING_TOKEN:+ --host-type=vps}"
860865
return 0
861866
fi
862-
info "Eseguo host-setup.sh in modalità VPS (scrive host.env + swap)..."
863-
if "$hostsetup" --host-type=vps </dev/null; then
864-
ok "host-setup VPS completato"
867+
info "Eseguo host-setup.sh (scrive ~/.jht/host.env + preflight swap)..."
868+
if [ -n "$PAIRING_TOKEN" ]; then
869+
if "$hostsetup" --host-type=vps </dev/null; then
870+
ok "host-setup completato (vps forzato)"
871+
else
872+
warn "host-setup uscito con errore — proseguo (pair manuale potrebbe servire)"
873+
fi
865874
else
866-
warn "host-setup VPS uscito con errore — proseguo (pair manuale potrebbe servire)"
875+
if "$hostsetup" </dev/null; then
876+
ok "host-setup completato (tipo host auto-rilevato)"
877+
else
878+
warn "host-setup uscito con errore — proseguo"
879+
fi
867880
fi
868881
# Allinea ownership di ~/.jht e ~/Documents/Job Hunter Team al UID del
869882
# container `jht` (1001, vedi Dockerfile `useradd jht`). Senza questo,
@@ -953,7 +966,7 @@ main() {
953966
main_native
954967
fi
955968
save_pairing_token
956-
run_host_setup_vps
969+
run_host_setup
957970
final_message
958971
maybe_onboard
959972
}

web/public/install.sh

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -843,27 +843,40 @@ save_pairing_token() {
843843
ok "Pairing token saved to $token_file (mode 0644)"
844844
}
845845

846-
run_host_setup_vps() {
847-
# When install.sh arrives with --pairing-token, the machine is a VPS
848-
# provisioned by the desktop launcher: no user at the terminal, host-setup
849-
# must be run non-interactively to write ~/.jht/host.env with
850-
# JHT_HOST_TYPE=vps. Without this file the container starts in mode=local
851-
# (backwards-compat default of the compose) and pid1 skips pair-on-boot.
852-
[ -z "$PAIRING_TOKEN" ] && return 0
846+
run_host_setup() {
847+
# host-setup.sh writes ~/.jht/host.env with JHT_HOST_TYPE (+ JHT_LANG + swap).
848+
# WITHOUT this file the container boots in mode=local (compose backwards-compat
849+
# default) and pid1 SKIPS the entire cloud block — push daemon + pair-on-boot +
850+
# the "Sync now" handler — so cloud sync is silently dead. Must run on BOTH
851+
# install paths:
852+
# • desktop-provisioned (--pairing-token present): force --host-type=vps —
853+
# no user at the terminal to confirm the auto-detection.
854+
# • manual `curl install.sh | bash`: NO flag → host-setup auto-detects
855+
# (detect_vps) and, with no TTY, writes the detected type without a prompt.
856+
# Regression fixed 2026-07-09: this path used to `return 0` early → host.env
857+
# never written → container in mode=local → cloud daemon never started.
853858
local hostsetup="$RUNTIME_DIR/host-setup.sh"
854859
if [ ! -x "$hostsetup" ]; then
855-
warn "host-setup.sh not available at $hostsetup — skipping VPS preflight"
860+
warn "host-setup.sh not available at $hostsetup — skipping preflight"
856861
return 0
857862
fi
858863
if [ "$DRY_RUN" -eq 1 ]; then
859-
info "dry-run: would run $hostsetup --host-type=vps"
864+
info "dry-run: would run $hostsetup${PAIRING_TOKEN:+ --host-type=vps}"
860865
return 0
861866
fi
862-
info "Running host-setup.sh in VPS mode (writes host.env + swap)..."
863-
if "$hostsetup" --host-type=vps </dev/null; then
864-
ok "VPS host-setup completed"
867+
info "Running host-setup.sh (writes ~/.jht/host.env + swap preflight)..."
868+
if [ -n "$PAIRING_TOKEN" ]; then
869+
if "$hostsetup" --host-type=vps </dev/null; then
870+
ok "host-setup completed (forced vps)"
871+
else
872+
warn "host-setup exited with an error — continuing (a manual pair may be needed)"
873+
fi
865874
else
866-
warn "VPS host-setup exited with an error — continuing (a manual pair may be needed)"
875+
if "$hostsetup" </dev/null; then
876+
ok "host-setup completed (auto-detected host type)"
877+
else
878+
warn "host-setup exited with an error — continuing"
879+
fi
867880
fi
868881
# Align the ownership of ~/.jht and ~/Documents/Job Hunter Team with the
869882
# `jht` container UID (1001, see Dockerfile `useradd jht`). Without this,
@@ -953,7 +966,7 @@ main() {
953966
main_native
954967
fi
955968
save_pairing_token
956-
run_host_setup_vps
969+
run_host_setup
957970
final_message
958971
maybe_onboard
959972
}

0 commit comments

Comments
 (0)