mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-08-18 18:46:10 +02:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 34a9032152 |
+107
-1
@@ -81,7 +81,113 @@ function update_script() {
|
||||
ln -sfn "$ROMM_BASE"/resources /opt/romm/frontend/dist/assets/romm/resources
|
||||
ln -sfn "$ROMM_BASE"/assets /opt/romm/frontend/dist/assets/romm/assets
|
||||
if [[ -f /etc/angie/http.d/romm.conf ]]; then
|
||||
sed -i "s|alias .*/library/;|alias ${ROMM_BASE}/library/;|" /etc/angie/http.d/romm.conf
|
||||
if ! grep -q "js_content decode.decodeBase64" /etc/angie/http.d/romm.conf; then
|
||||
msg_info "Adding missing /decode and /cache locations to Angie config"
|
||||
dpkg -l angie-module-njs &>/dev/null || $STD apt-get install -y angie-module-njs
|
||||
grep -q "ngx_http_js_module.so" /etc/angie/angie.conf || sed -i '1i load_module modules/ngx_http_js_module.so;' /etc/angie/angie.conf
|
||||
mkdir -p /etc/angie/js "${ROMM_BASE}/cache"
|
||||
cat <<'JSEOF' >/etc/angie/js/decode.js
|
||||
// Decode a Base64 encoded string received as a query parameter named 'value',
|
||||
// and return the decoded value in the response body.
|
||||
function decodeBase64(r) {
|
||||
var encodedValue = r.args.value;
|
||||
|
||||
if (!encodedValue) {
|
||||
r.return(400, "Missing 'value' query parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Use Buffer to return raw bytes — atob() returns a JS string which r.return()
|
||||
// would re-encode as UTF-8, corrupting any non-ASCII bytes (e.g. in filenames
|
||||
// like "Pokémon") and causing CRC mismatches in the mod_zip manifest.
|
||||
r.return(200, Buffer.from(encodedValue, 'base64'));
|
||||
} catch (e) {
|
||||
r.return(400, "Invalid Base64 encoding");
|
||||
}
|
||||
}
|
||||
|
||||
export default { decodeBase64 };
|
||||
JSEOF
|
||||
cat <<EOF >/etc/angie/http.d/romm.conf
|
||||
js_import /etc/angie/js/decode.js;
|
||||
|
||||
upstream romm_backend {
|
||||
server 127.0.0.1:5000;
|
||||
}
|
||||
|
||||
map \$http_upgrade \$connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /opt/romm/frontend/dist;
|
||||
client_max_body_size 0;
|
||||
|
||||
location / {
|
||||
try_files \$uri \$uri/ /index.html;
|
||||
}
|
||||
|
||||
location /assets {
|
||||
alias /opt/romm/frontend/dist/assets;
|
||||
try_files \$uri \$uri/ =404;
|
||||
expires 1y;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
location ~ ^/rom/.*/ejs\$ {
|
||||
add_header Cross-Origin-Embedder-Policy "require-corp";
|
||||
add_header Cross-Origin-Opener-Policy "same-origin";
|
||||
try_files \$uri /index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://romm_backend;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Real-IP \$remote_addr;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scheme;
|
||||
}
|
||||
|
||||
location ~ ^/(ws|netplay) {
|
||||
proxy_pass http://romm_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade \$http_upgrade;
|
||||
proxy_set_header Connection \$connection_upgrade;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_read_timeout 86400;
|
||||
}
|
||||
|
||||
location = /openapi.json {
|
||||
proxy_pass http://romm_backend;
|
||||
}
|
||||
|
||||
location /library/ {
|
||||
internal;
|
||||
alias ${ROMM_BASE}/library/;
|
||||
}
|
||||
|
||||
location /cache/ {
|
||||
internal;
|
||||
alias ${ROMM_BASE}/cache/;
|
||||
}
|
||||
|
||||
location /decode {
|
||||
internal;
|
||||
js_content decode.decodeBase64;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
msg_ok "Added /decode and /cache locations"
|
||||
else
|
||||
sed -i -e "s|alias .*/library/;|alias ${ROMM_BASE}/library/;|" \
|
||||
-e "s|alias .*/cache/;|alias ${ROMM_BASE}/cache/;|" /etc/angie/http.d/romm.conf
|
||||
fi
|
||||
systemctl reload angie
|
||||
elif [[ -f /etc/nginx/sites-available/romm ]]; then
|
||||
sed -i "s|alias .*/library/;|alias ${ROMM_BASE}/library/;|" /etc/nginx/sites-available/romm
|
||||
|
||||
+47
-6
@@ -42,16 +42,40 @@ $STD apt install -y \
|
||||
tzdata
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
msg_info "Installing Angie with mod_zip module"
|
||||
msg_info "Installing Angie with mod_zip and njs modules"
|
||||
setup_deb822_repo \
|
||||
"angie" \
|
||||
"https://angie.software/keys/angie-signing.gpg" \
|
||||
"https://download.angie.software/angie/debian/$(get_os_info version_id)" \
|
||||
"$(get_os_info codename)" \
|
||||
"main"
|
||||
$STD apt-get install -y angie angie-module-zip
|
||||
sed -i '1i load_module modules/ngx_http_zip_module.so;' /etc/angie/angie.conf
|
||||
msg_ok "Installed Angie with mod_zip module"
|
||||
$STD apt-get install -y angie angie-module-zip angie-module-njs
|
||||
sed -i '1i load_module modules/ngx_http_zip_module.so;\nload_module modules/ngx_http_js_module.so;' /etc/angie/angie.conf
|
||||
mkdir -p /etc/angie/js
|
||||
cat <<'EOF' >/etc/angie/js/decode.js
|
||||
// Decode a Base64 encoded string received as a query parameter named 'value',
|
||||
// and return the decoded value in the response body.
|
||||
function decodeBase64(r) {
|
||||
var encodedValue = r.args.value;
|
||||
|
||||
if (!encodedValue) {
|
||||
r.return(400, "Missing 'value' query parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Use Buffer to return raw bytes — atob() returns a JS string which r.return()
|
||||
// would re-encode as UTF-8, corrupting any non-ASCII bytes (e.g. in filenames
|
||||
// like "Pokémon") and causing CRC mismatches in the mod_zip manifest.
|
||||
r.return(200, Buffer.from(encodedValue, 'base64'));
|
||||
} catch (e) {
|
||||
r.return(400, "Invalid Base64 encoding");
|
||||
}
|
||||
}
|
||||
|
||||
export default { decodeBase64 };
|
||||
EOF
|
||||
msg_ok "Installed Angie with mod_zip and njs modules"
|
||||
PYTHON_VERSION="3.13" setup_uv
|
||||
NODE_VERSION="24" setup_nodejs
|
||||
setup_mariadb
|
||||
@@ -63,7 +87,8 @@ mkdir -p /opt/romm \
|
||||
/var/lib/romm/resources \
|
||||
/var/lib/romm/assets/{saves,states,screenshots} \
|
||||
/var/lib/romm/library/roms \
|
||||
/var/lib/romm/library/bios
|
||||
/var/lib/romm/library/bios \
|
||||
/var/lib/romm/cache
|
||||
msg_ok "Created directories"
|
||||
|
||||
msg_info "Creating configuration file"
|
||||
@@ -217,6 +242,8 @@ fetch_and_deploy_gh_release "EmulatorJS" "EmulatorJS/EmulatorJS" "prebuild" "v4.
|
||||
|
||||
msg_info "Configuring Angie"
|
||||
cat <<'EOF' >/etc/angie/http.d/romm.conf
|
||||
js_import /etc/angie/js/decode.js;
|
||||
|
||||
upstream romm_backend {
|
||||
server 127.0.0.1:5000;
|
||||
}
|
||||
@@ -283,10 +310,24 @@ server {
|
||||
internal;
|
||||
alias /var/lib/romm/library/;
|
||||
}
|
||||
|
||||
# Internally redirect cached zip file requests (Range-resumable downloads)
|
||||
location /cache/ {
|
||||
internal;
|
||||
alias /var/lib/romm/cache/;
|
||||
}
|
||||
|
||||
# Internal decoding endpoint, used by mod_zip to decode base64-encoded
|
||||
# multi-file manifest entries (e.g. the generated .m3u for multi-disc games)
|
||||
location /decode {
|
||||
internal;
|
||||
js_content decode.decodeBase64;
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
sed -i "s|alias /var/lib/romm/library/;|alias ${ROMM_BASE}/library/;|" /etc/angie/http.d/romm.conf
|
||||
sed -i -e "s|alias /var/lib/romm/library/;|alias ${ROMM_BASE}/library/;|" \
|
||||
-e "s|alias /var/lib/romm/cache/;|alias ${ROMM_BASE}/cache/;|" /etc/angie/http.d/romm.conf
|
||||
rm -f /etc/angie/http.d/default.conf
|
||||
systemctl restart angie
|
||||
systemctl enable -q --now angie
|
||||
|
||||
Reference in New Issue
Block a user