From 891be92dc9530202cc900f7018b8392dc3ce6713 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 22 Oct 2026 13:50:33 +0200 Subject: [PATCH] Refactor: Cryptpad (#18065) * CryptPad: configure 2026.10.0 through infra.js 2026.10.0 moved the origins, host and ports from config.js to infra.js and no longer derives the sandbox origin, so updated instances pointed the sandbox at the browser's own localhost and hung at 'loading drive' (#18063). Update builds infra.js once from config.js, install writes it directly (the config.js seds matched nothing anymore). install-onlyoffice.sh is now install-office.sh; update runs it only where office was installed. * CryptPad: repair instances already on 2026.10.0 Instances updated before this fix have no infra.js but already the new version, so the migration would wait for the next release. Update runs again for them, and a config.js from the 2026.10.0 example (no origin at all) gets the container address like a fresh install. --- ct/cryptpad.sh | 30 +++++++++++++++++++++++++++--- install/cryptpad-install.sh | 10 +++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ct/cryptpad.sh b/ct/cryptpad.sh index 54ac048e3..d2b0f6b1f 100644 --- a/ct/cryptpad.sh +++ b/ct/cryptpad.sh @@ -30,12 +30,14 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + # Updates to 2026.10.0 finished without infra.js; run them again so it gets written + [[ -f /opt/cryptpad/config/infra.example.js && ! -f /opt/cryptpad/config/infra.js ]] && rm -f ~/.cryptpad if check_for_gh_release "cryptpad" "cryptpad/cryptpad"; then msg_info "Stopping Service" systemctl stop cryptpad msg_ok "Stopped Service" - create_backup /opt/cryptpad/config/config.js /opt/cryptpad/www/common/onlyoffice/dist + create_backup /opt/cryptpad/config/config.js /opt/cryptpad/config/infra.js /opt/cryptpad/www/common/onlyoffice/dist CLEAN_INSTALL=1 CLEAN_INSTALL_KEEP="blob block customize data datastore onlyoffice-conf" fetch_and_deploy_gh_release "cryptpad" "cryptpad/cryptpad" "tarball" @@ -45,8 +47,30 @@ function update_script() { cd /opt/cryptpad $STD npm ci --allow-git=all $STD npm run install:components - if [ -f "/opt/cryptpad/install-onlyoffice.sh" ]; then - $STD bash /opt/cryptpad/install-onlyoffice.sh --accept-license + if [[ -d /opt/cryptpad/www/common/onlyoffice/dist ]]; then + $STD bash /opt/cryptpad/install-office.sh --accept-license + fi + if [[ ! -f /opt/cryptpad/config/infra.js ]]; then + # 2026.10.0 reads the network settings from infra.js and no longer derives the sandbox origin + LOCAL_IP="$LOCAL_IP" node - <<'EOF' +const c = require("/opt/cryptpad/config/config.js"); +const i = require("/opt/cryptpad/config/infra.example.js"); +const port = c.httpPort || i.public.httpPort; +const safePort = c.httpSafePort || port + 1; +const origin = (c.httpUnsafeOrigin || `http://${process.env.LOCAL_IP}:${port}`).replace(/\/+$/, ""); +const sandbox = new URL(origin); +sandbox.port = safePort; +Object.assign(i.public, { + origin, + sandboxOrigin: (c.httpSafeOrigin || sandbox.origin).replace(/\/+$/, ""), + httpHost: c.httpAddress || (c.httpUnsafeOrigin ? i.public.httpHost : "0.0.0.0"), + httpPort: port, + httpSafePort: safePort, + externalWebsocketURL: c.externalWebsocketURL, + fileHost: c.fileHost, +}); +require("fs").writeFileSync("/opt/cryptpad/config/infra.js", "module.exports = " + JSON.stringify(i, null, 4) + ";\n"); +EOF fi $STD npm run build msg_ok "Updated CryptaPad" diff --git a/install/cryptpad-install.sh b/install/cryptpad-install.sh index d74b9e875..323602f90 100644 --- a/install/cryptpad-install.sh +++ b/install/cryptpad-install.sh @@ -28,11 +28,15 @@ cd /opt/cryptpad $STD npm ci --allow-git=all $STD npm run install:components if [[ "${onlyoffice,,}" =~ ^(y|yes)$ ]]; then - $STD bash -c "./install-onlyoffice.sh --accept-license" + $STD bash -c "./install-office.sh --accept-license" fi cp config/config.example.js config/config.js -sed -i "51s/localhost/${LOCAL_IP}/g" /opt/cryptpad/config/config.js -sed -i "80s#//httpAddress: 'localhost'#httpAddress: '0.0.0.0'#g" /opt/cryptpad/config/config.js +cp config/infra.example.js config/infra.js +sed -i \ + -e "s|origin: \"http://localhost:3000\"|origin: \"http://${LOCAL_IP}:3000\"|" \ + -e "s|sandboxOrigin: \"http://localhost:3001\"|sandboxOrigin: \"http://${LOCAL_IP}:3001\"|" \ + -e "s|httpHost: \"localhost\"|httpHost: \"0.0.0.0\"|" \ + config/infra.js $STD npm run build msg_ok "Setup CryptPad"