Compare commits

..

1 Commits

Author SHA1 Message Date
MickLesk 34a9032152 romm: add missing /decode and /cache Angie locations for multi-file downloads 2026-08-18 11:17:25 +02:00
5 changed files with 302 additions and 7 deletions
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2026 community-scripts ORG
# Author: bvdberg01
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://sabre.io/baikal/ | Github: https://github.com/sabre-io/Baikal
APP="Baikal"
var_tags="${var_tags:-Dav}"
var_cpu="${var_cpu:-1}"
var_ram="${var_ram:-512}"
var_disk="${var_disk:-4}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_arm64="${var_arm64:-yes}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/baikal ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "baikal" "sabre-io/Baikal"; then
msg_info "Stopping Service"
systemctl stop apache2
msg_ok "Stopped Service"
create_backup /opt/baikal/config/baikal.yaml \
/opt/baikal/Specific/
PHP_APACHE="YES" PHP_VERSION="8.3" setup_php
setup_composer
fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal" "tarball"
restore_backup
chown -R www-data:www-data /opt/baikal/
chmod -R 755 /opt/baikal/
msg_info "Configuring Baikal"
cd /opt/baikal
$STD composer install
msg_ok "Configured Baikal"
msg_info "Starting Service"
systemctl start apache2
msg_ok "Started Service"
msg_ok "Updated successfully!"
fi
exit
}
start
build_container
description
msg_ok "Completed successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW}Access it using the following URL:${CL}"
echo -e "${GATEWAY}${BGN}http://${IP}${CL}"
+6
View File
@@ -0,0 +1,6 @@
____ _ __ __
/ __ )____ _(_) /______ _/ /
/ __ / __ `/ / //_/ __ `/ /
/ /_/ / /_/ / / ,< / /_/ / /
/_____/\__,_/_/_/|_|\__,_/_/
+107 -1
View File
@@ -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
+75
View File
@@ -0,0 +1,75 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2026 community-scripts ORG
# Author: bvdberg01
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://sabre.io/baikal/ | Github: https://github.com/sabre-io/Baikal
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y git
msg_ok "Installed Dependencies"
PG_VERSION="16" setup_postgresql
PHP_APACHE="YES" PHP_VERSION="8.3" setup_php
setup_composer
fetch_and_deploy_gh_release "baikal" "sabre-io/Baikal" "tarball"
PG_DB_NAME="baikal_db" PG_DB_USER="baikal_user" PG_DB_PASS="$(openssl rand -base64 12)" setup_postgresql_db
msg_info "Configuring Baikal"
cd /opt/baikal
$STD composer install
cat <<EOF >/opt/baikal/config/baikal.yaml
database:
backend: pgsql
pgsql_host: localhost
pgsql_dbname: $PG_DB_NAME
pgsql_username: $PG_DB_USER
pgsql_password: $PG_DB_PASS
EOF
chown -R www-data:www-data /opt/baikal/
chmod -R 755 /opt/baikal/
msg_ok "Installed Baikal"
msg_info "Creating Service"
cat <<EOF >/etc/apache2/sites-available/baikal.conf
<VirtualHost *:80>
ServerName baikal
DocumentRoot /opt/baikal/html
RewriteEngine on
RewriteRule /.well-known/carddav /dav.php [R=308,L]
RewriteRule /.well-known/caldav /dav.php [R=308,L]
RewriteCond %{REQUEST_URI} ^/dav.php$ [NC]
RewriteRule ^(.*)$ /dav.php/ [R=301,L]
<Directory /opt/baikal/html>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<IfModule mod_expires.c>
ExpiresActive Off
</IfModule>
ErrorLog /var/log/apache2/baikal_error.log
CustomLog /var/log/apache2/baikal_access.log combined
</VirtualHost>
EOF
$STD a2ensite baikal
$STD a2enmod rewrite
$STD a2dissite 000-default.conf
$STD systemctl reload apache2
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc
+47 -6
View File
@@ -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