From c9fc09d43cd5a8a70c48ef5be9a81b5462a0a1bd Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Sun, 22 Nov 2026 10:30:00 +0100 Subject: [PATCH] Mathesar (#18914) * Add mathesar (ct) * rm --------- Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: CanbiZ (MickLesk) <47820557+MickLesk@users.noreply.github.com> --- ct/mathesar.sh | 67 +++++++++++++++++++++++++++++++++ install/mathesar-install.sh | 74 +++++++++++++++++++++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 ct/mathesar.sh create mode 100644 install/mathesar-install.sh diff --git a/ct/mathesar.sh b/ct/mathesar.sh new file mode 100644 index 000000000..7d6d37a33 --- /dev/null +++ b/ct/mathesar.sh @@ -0,0 +1,67 @@ +#!/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/mathesar-foundation/mathesar + +APP="Mathesar" +var_tags="${var_tags:-database;postgresql;spreadsheet}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +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/mathesar ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "mathesar" "mathesar-foundation/mathesar"; then + msg_info "Stopping Mathesar" + systemctl stop mathesar + msg_ok "Stopped Mathesar" + + PYTHON_VERSION="3.12" setup_uv + CLEAN_INSTALL=1 CLEAN_INSTALL_KEEP="sso.yml file_storage.yml login_page.yml" fetch_and_deploy_gh_release "mathesar" "mathesar-foundation/mathesar" "prebuild" "latest" "/opt/mathesar" "mathesar.tar.gz" + + msg_info "Updating Mathesar" + cd /opt/mathesar + $STD uv venv --python 3.12 /opt/mathesar/.venv + $STD uv pip install --python /opt/mathesar/.venv/bin/python -r requirements.txt + set -a + source /opt/mathesar_data/.env + set +a + $STD /opt/mathesar/.venv/bin/python -m mathesar.install + msg_ok "Updated Mathesar" + + msg_info "Starting Mathesar" + systemctl start mathesar + msg_ok "Started Mathesar" + 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}:8000${CL}" diff --git a/install/mathesar-install.sh b/install/mathesar-install.sh new file mode 100644 index 000000000..4d77e52c9 --- /dev/null +++ b/install/mathesar-install.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# 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/mathesar-foundation/mathesar + +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 libcairo2 +msg_ok "Installed Dependencies" + +PG_VERSION="17" setup_postgresql +PG_DB_NAME="mathesar_django" PG_DB_USER="mathesar" PG_DB_SCHEMA_PERMS="true" setup_postgresql_db +PYTHON_VERSION="3.12" setup_uv +fetch_and_deploy_gh_release "mathesar" "mathesar-foundation/mathesar" "prebuild" "latest" "/opt/mathesar" "mathesar.tar.gz" + +msg_info "Installing Mathesar" +cd /opt/mathesar +$STD uv venv --python 3.12 /opt/mathesar/.venv +$STD uv pip install --python /opt/mathesar/.venv/bin/python -r requirements.txt +msg_ok "Installed Mathesar" + +msg_info "Configuring Mathesar" +mkdir -p /opt/mathesar_data/media +cat </opt/mathesar_data/.env +SECRET_KEY=$(random_password 50) +ALLOWED_HOSTS=* +WEB_CONCURRENCY=3 +MEDIA_ROOT=/opt/mathesar_data/media/ +POSTGRES_HOST=127.0.0.1 +POSTGRES_PORT=5432 +POSTGRES_DB=mathesar_django +POSTGRES_USER=mathesar +POSTGRES_PASSWORD=${PG_DB_PASS} +EOF +chmod 600 /opt/mathesar_data/.env +set -a +source /opt/mathesar_data/.env +set +a +$STD /opt/mathesar/.venv/bin/python -m mathesar.install +msg_ok "Configured Mathesar" + +msg_info "Creating Service" +cat </etc/systemd/system/mathesar.service +[Unit] +Description=Mathesar +After=network.target postgresql.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/mathesar +EnvironmentFile=/opt/mathesar_data/.env +ExecStart=/opt/mathesar/.venv/bin/gunicorn config.wsgi -b 0.0.0.0:8000 --timeout 180 +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now mathesar +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc