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"