mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-28 05:10:40 +00:00
c768da0cb1
Word/Excel/PowerPoint to PDF conversion uses LibreOffice WASM which requires SharedArrayBuffer. SharedArrayBuffer only works when the server sends Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp headers. The previous http-server setup did not send these headers, causing WASM initialization to time out for office-format conversions. Fix: replace http-server with nginx and configure COOP/COEP headers in the nginx site config, matching the upstream Docker image's nginx.conf. Also adds a one-time migration path in update_script for existing installs running the old http-server service.
77 lines
1.9 KiB
Bash
77 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
# Copyright (c) 2021-2026 community-scripts ORG
|
|
# Author: vhsdream
|
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
|
# Source: https://github.com/alam00000/bentopdf
|
|
|
|
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
|
|
color
|
|
verb_ip6
|
|
catch_errors
|
|
setting_up_container
|
|
network_check
|
|
update_os
|
|
|
|
NODE_VERSION="24" setup_nodejs
|
|
fetch_and_deploy_gh_release "bentopdf" "alam00000/bentopdf" "tarball" "latest" "/opt/bentopdf"
|
|
|
|
msg_info "Setup BentoPDF"
|
|
cd /opt/bentopdf
|
|
$STD npm ci --no-audit --no-fund
|
|
ensure_dependencies nginx
|
|
cp ./.env.example ./.env.production
|
|
export NODE_OPTIONS="--max-old-space-size=3072"
|
|
export SIMPLE_MODE=true
|
|
export VITE_USE_CDN=true
|
|
$STD npm run build:all
|
|
msg_ok "Setup BentoPDF"
|
|
|
|
msg_info "Creating Service"
|
|
cat <<'EOF' >/etc/nginx/sites-available/bentopdf
|
|
server {
|
|
listen 8080;
|
|
server_name _;
|
|
root /opt/bentopdf/dist;
|
|
index index.html;
|
|
|
|
# Required for LibreOffice WASM (Word/Excel/PowerPoint to PDF via SharedArrayBuffer)
|
|
add_header Cross-Origin-Opener-Policy "same-origin" always;
|
|
add_header Cross-Origin-Embedder-Policy "require-corp" always;
|
|
add_header Cross-Origin-Resource-Policy "cross-origin" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
|
|
gzip_static on;
|
|
|
|
location / {
|
|
try_files $uri $uri/ $uri.html =404;
|
|
}
|
|
|
|
error_page 404 /404.html;
|
|
}
|
|
EOF
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
ln -sf /etc/nginx/sites-available/bentopdf /etc/nginx/sites-enabled/bentopdf
|
|
cat <<'EOF' >/etc/systemd/system/bentopdf.service
|
|
[Unit]
|
|
Description=BentoPDF Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
ExecStart=/usr/sbin/nginx -g "daemon off;"
|
|
ExecReload=/bin/kill -HUP $MAINPID
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
EOF
|
|
|
|
systemctl enable -q --now bentopdf
|
|
msg_ok "Created & started service"
|
|
|
|
motd_ssh
|
|
customize
|
|
cleanup_lxc
|