Files
ProxmoxVE/ct/dawarich.sh
T
Riccardo Baral 08e2f99522 fix(dawarich): serve .mjs MapLibre modules as JavaScript (#18304)
Since Dawarich 1.15.1 the importmap pins maplibre-gl to
/maplibre/<version>/maplibre-gl.mjs in public/. Debian's nginx
mime.types has no mjs entry, so the vhost served it as
application/octet-stream and browsers refused to load the module:
blank map, map controllers fail.

Add a .mjs location (text/javascript, as Rails serves it upstream) to
the install heredoc, and insert it into existing vhosts from
update_script() before the release check, applied via nginx_enable_site.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 13:53:13 +01:00

112 lines
3.8 KiB
Bash

#!/usr/bin/env bash
_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func"
source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func")
# Copyright (c) 2021-2026 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/Freika/dawarich
APP="Dawarich"
var_tags="${var_tags:-location;tracking;gps}"
var_cpu="${var_cpu:-4}"
var_ram="${var_ram:-4096}"
var_disk="${var_disk:-15}"
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/dawarich ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
ensure_dependencies libgeos++-dev libxml2-dev libxslt-dev libjemalloc-dev
if [[ -f /etc/nginx/sites-available/dawarich.conf ]] && ! grep -q '\.mjs\$' /etc/nginx/sites-available/dawarich.conf; then
msg_info "Fixing MapLibre delivery in Nginx"
sed -i '/location ~ \^\/(assets|packs)\/ {/i\ location ~ \\.mjs$ {\n types { }\n default_type text/javascript;\n try_files $uri @rails;\n }\n' /etc/nginx/sites-available/dawarich.conf
nginx_enable_site dawarich.conf
msg_ok "Fixed MapLibre delivery in Nginx"
fi
if check_for_gh_release "dawarich" "Freika/dawarich"; then
msg_info "Stopping Services"
systemctl stop dawarich-web dawarich-worker
msg_ok "Stopped Services"
create_backup /opt/dawarich/app/storage \
/opt/dawarich/app/config/master.key \
/opt/dawarich/app/config/credentials.yml.enc
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "dawarich" "Freika/dawarich" "tarball" "latest" "/opt/dawarich/app"
RUBY_VERSION=$(cat /opt/dawarich/app/.ruby-version 2>/dev/null || echo "3.4.6")
RUBY_VERSION=${RUBY_VERSION} RUBY_INSTALL_RAILS="false" HOME=/root setup_ruby
msg_info "Running Migrations"
cd /opt/dawarich/app
source /root/.profile
export PATH="/root/.rbenv/shims:/root/.rbenv/bin:${PATH}"
eval "$(/root/.rbenv/bin/rbenv init - bash)"
if ! grep -q "OTP_ENCRYPTION_PRIMARY_KEY" /opt/dawarich/.env; then
echo "OTP_ENCRYPTION_PRIMARY_KEY=$(openssl rand -hex 64)" >>/opt/dawarich/.env
fi
if ! grep -q "OTP_ENCRYPTION_DETERMINISTIC_KEY" /opt/dawarich/.env; then
echo "OTP_ENCRYPTION_DETERMINISTIC_KEY=$(openssl rand -hex 64)" >>/opt/dawarich/.env
fi
if ! grep -q "OTP_ENCRYPTION_KEY_DERIVATION_SALT" /opt/dawarich/.env; then
echo "OTP_ENCRYPTION_KEY_DERIVATION_SALT=$(openssl rand -hex 64)" >>/opt/dawarich/.env
fi
set -a && source /opt/dawarich/.env && set +a
$STD bundle config set --local deployment 'true'
$STD bundle config set --local without 'development test'
$STD bundle install
if [[ -f /opt/dawarich/package.json ]]; then
cd /opt/dawarich
$STD npm install
cd /opt/dawarich/app
elif [[ -f /opt/dawarich/app/package.json ]]; then
$STD npm install
fi
$STD bundle exec rails db:migrate
$STD bundle exec rake assets:precompile
$STD bundle exec rake data:migrate
msg_ok "Ran Migrations"
restore_backup
msg_info "Starting Services"
systemctl start dawarich-web dawarich-worker
msg_ok "Started Services"
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}:3000${CL}"