Compare commits

..

2 Commits

Author SHA1 Message Date
Tobias
ed453052a9 Update log message for stopping Metabase service 2025-11-16 15:53:26 +01:00
push-app-to-main[bot]
63f993c51e 'Add new script' 2025-11-16 09:54:04 +00:00
6 changed files with 202 additions and 55 deletions

6
ct/headers/metabase Normal file
View File

@@ -0,0 +1,6 @@
__ ___ __ __
/ |/ /__ / /_____ _/ /_ ____ _________
/ /|_/ / _ \/ __/ __ `/ __ \/ __ `/ ___/ _ \
/ / / / __/ /_/ /_/ / /_/ / /_/ (__ ) __/
/_/ /_/\___/\__/\__,_/_.___/\__,_/____/\___/

View File

@@ -28,42 +28,26 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
if check_for_gh_release "healthchecks" "healthchecks/healthchecks"; then if check_for_gh_release "healthchecks" "healthchecks/healthchecks"; then
msg_info "Stopping Services" msg_info "Stopping Services"
systemctl stop healthchecks systemctl stop healthchecks
msg_ok "Stopped Services" msg_ok "Stopped Services"
msg_info "Backing up existing installation" PYTHON_VERSION="3.13" setup_uv
BACKUP="/opt/healthchecks-backup-$(date +%F-%H%M)"
cp -a /opt/healthchecks "$BACKUP"
msg_ok "Backup created at $BACKUP"
fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks" fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks"
msg_info "Updating healthchecks"
cd /opt/healthchecks cd /opt/healthchecks
if [[ -d venv ]]; then mkdir -p /opt/healthchecks/static-collected/
rm -rf venv $STD uv pip install wheel gunicorn -r requirements.txt --system
fi $STD uv run -- python manage.py makemigrations
msg_info "Recreating Python venv" $STD uv run -- python manage.py migrate --noinput
$STD python3 -m venv venv $STD uv run -- python manage.py collectstatic --noinput
$STD source venv/bin/activate $STD uv run -- python manage.py compress
$STD pip install --upgrade pip wheel msg_ok "Updated healthchecks"
msg_ok "Created venv"
msg_info "Installing requirements"
$STD pip install gunicorn -r requirements.txt
msg_ok "Installed requirements"
msg_info "Running Django migrations"
$STD python manage.py migrate --noinput
$STD python manage.py collectstatic --noinput
$STD python manage.py compress
msg_ok "Completed Django migrations and static build"
msg_info "Starting Services" msg_info "Starting Services"
systemctl start healthchecks systemctl start healthchecks
systemctl reload caddy systemctl restart caddy
msg_ok "Started Services" msg_ok "Started Services"
msg_ok "Updated successfully!" msg_ok "Updated successfully!"
fi fi

65
ct/metabase.sh Normal file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.metabase.com/
APP="Metabase"
var_tags="${var_tags:-analytics}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-6}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
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/metabase ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "metabase" "metabase/metabase"; then
msg_info "Stopping Service"
systemctl stop metabase
msg_info "Stopped Service"
msg_info "Creating backup"
mv /opt/metabase/.env /opt
msg_ok "Created backup"
msg_info "Updating Metabase"
RELEASE=$(get_latest_github_release "metabase/metabase")
curl -fsSL "https://downloads.metabase.com/v${RELEASE}.x/metabase.jar" -o /opt/metabase/metabase.jar
echo $RELEASE >~/.metabase
msg_ok "Updated Metabase"
msg_info "Restoring backup"
mv /opt/.env /opt/metabase
msg_ok "Restored backup"
msg_info "Starting Service"
systemctl start metabase
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 "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

View File

@@ -0,0 +1,35 @@
{
"name": "Metabase",
"slug": "metabase",
"categories": [
9
],
"date_created": "2025-09-04",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 3000,
"documentation": "https://www.metabase.com/docs/latest/",
"config_path": "/opt/metabase/.env",
"website": "https://www.metabase.com/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/metabase.webp",
"description": "Metabase is an open-source business intelligence platform. You can use Metabase to ask questions about your data, or embed Metabase in your app to let your customers explore their data on their own.",
"install_methods": [
{
"type": "default",
"script": "ct/metabase.sh",
"resources": {
"cpu": 2,
"ram": 2048,
"hdd": 6,
"os": "Debian",
"version": "13"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": []
}

View File

@@ -1,4 +1,5 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG # Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (Canbiz) # Author: MickLesk (Canbiz)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@@ -15,44 +16,43 @@ update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt install -y \ $STD apt install -y \
gcc \ gcc \
python3 \
python3-dev \
python3-venv \
libpq-dev \ libpq-dev \
libcurl4-openssl-dev \ libcurl4-openssl-dev \
libssl-dev \ libssl-dev \
caddy caddy
mkdir -p ~/.config/pip
cat > ~/.config/pip/pip.conf << EOF
[global]
break-system-packages = true
EOF
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PYTHON_VERSION="3.13" setup_uv
PG_VERSION=16 setup_postgresql PG_VERSION=16 setup_postgresql
PG_DB_NAME="healthchecks_db" PG_DB_USER="hc_user" PG_DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13) setup_postgresql_db
msg_info "Setup Keys (Admin / Secret)" msg_info "Setup Database"
DB_NAME=healthchecks_db
DB_USER=hc_user
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-13)
SECRET_KEY="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)" SECRET_KEY="$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32)"
ADMIN_EMAIL="admin@helper-scripts.local" ADMIN_EMAIL="admin@helper-scripts.local"
ADMIN_PASSWORD="$DB_PASS" ADMIN_PASSWORD="$DB_PASS"
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC'"
{ {
echo "healthchecks-Credentials"
echo "healthchecks Database User: $DB_USER"
echo "healthchecks Database Password: $DB_PASS"
echo "healthchecks Database Name: $DB_NAME"
echo "healthchecks Admin Email: $ADMIN_EMAIL" echo "healthchecks Admin Email: $ADMIN_EMAIL"
echo "healthchecks Admin Password: $ADMIN_PASSWORD" echo "healthchecks Admin Password: $ADMIN_PASSWORD"
} >>~/healthchecks.creds } >>~/healthchecks.creds
msg_ok "Set up Keys" msg_ok "Set up Database"
fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks" fetch_and_deploy_gh_release "healthchecks" "healthchecks/healthchecks"
msg_info "Installing Healthchecks (venv)" msg_info "Setup healthchecks"
cd /opt/healthchecks cd /opt/healthchecks
python3 -m venv venv mkdir -p /opt/healthchecks/static-collected/
source venv/bin/activate $STD uv pip install wheel gunicorn -r requirements.txt --system
$STD pip install --upgrade pip wheel
$STD pip install gunicorn -r requirements.txt
msg_ok "Installed Python packages"
LOCAL_IP=$(hostname -I | awk '{print $1}') LOCAL_IP=$(hostname -I | awk '{print $1}')
cat <<EOF >/opt/healthchecks/hc/local_settings.py cat <<EOF >/opt/healthchecks/hc/local_settings.py
@@ -83,19 +83,18 @@ DATABASES = {
} }
EOF EOF
msg_info "Running Django setup" $STD uv run -- python manage.py makemigrations
$STD python manage.py makemigrations $STD uv run -- python manage.py migrate --noinput
$STD python manage.py migrate --noinput $STD uv run -- python manage.py collectstatic --noinput
$STD python manage.py collectstatic --noinput $STD uv run -- python manage.py compress
$STD python manage.py compress
python <<EOF cat <<EOF | $STD uv run -- python manage.py shell
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
User = get_user_model() User = get_user_model()
if not User.objects.filter(email="${ADMIN_EMAIL}").exists(): if not User.objects.filter(email="${ADMIN_EMAIL}").exists():
User.objects.create_superuser("${ADMIN_EMAIL}", "${ADMIN_EMAIL}", "${ADMIN_PASSWORD}") User.objects.create_superuser("${ADMIN_EMAIL}", "${ADMIN_EMAIL}", "${ADMIN_PASSWORD}")
EOF EOF
msg_ok "Configured Django" msg_ok "Installed healthchecks"
msg_info "Configuring Caddy" msg_info "Configuring Caddy"
cat <<EOF >/etc/caddy/Caddyfile cat <<EOF >/etc/caddy/Caddyfile
@@ -109,7 +108,7 @@ ${LOCAL_IP} {
EOF EOF
msg_ok "Configured Caddy" msg_ok "Configured Caddy"
msg_info "Creating systemd service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/healthchecks.service cat <<EOF >/etc/systemd/system/healthchecks.service
[Unit] [Unit]
Description=Healthchecks Service Description=Healthchecks Service
@@ -117,13 +116,12 @@ After=network.target postgresql.service
[Service] [Service]
WorkingDirectory=/opt/healthchecks/ WorkingDirectory=/opt/healthchecks/
ExecStart=/opt/healthchecks/venv/bin/gunicorn hc.wsgi:application --bind 127.0.0.1:8000 ExecStart=/usr/local/bin/uv run -- gunicorn hc.wsgi:application --bind 127.0.0.1:8000
Restart=always Restart=always
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
EOF EOF
systemctl enable -q --now healthchecks caddy systemctl enable -q --now healthchecks caddy
systemctl reload caddy systemctl reload caddy
msg_ok "Created Service" msg_ok "Created Service"

View File

@@ -0,0 +1,59 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: Slaviša Arežina (tremor021)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://www.metabase.com/
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
JAVA_VERSION="21" setup_java
PG_VERSION="17" setup_postgresql
PG_DB_NAME="metabase_db" PG_DB_USER="metabase" setup_postgresql_db
msg_info "Setting up Metabase"
mkdir -p /opt/metabase
RELEASE=$(get_latest_github_release "metabase/metabase")
curl -fsSL "https://downloads.metabase.com/v${RELEASE}.x/metabase.jar" -o /opt/metabase/metabase.jar
cd /opt/metabase
cat <<EOF >/opt/metabase/.env
MB_DB_TYPE=postgres
MB_DB_DBNAME=$PG_DB_NAME
MB_DB_PORT=5432
MB_DB_USER=$PG_DB_USER
MB_DB_PASS=$PG_DB_PASS
MB_DB_HOST=localhost
EOF
echo $RELEASE >~/.metabase
msg_ok "Setup Metabase"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/metabase.service
[Unit]
Description=Metabase Service
After=network.target
[Service]
EnvironmentFile=/opt/metabase/.env
WorkingDirectory=/opt/metabase
ExecStart=/usr/bin/java --add-opens java.base/java.nio=ALL-UNNAMED -jar metabase.jar
Restart=always
SuccessExitStatus=143
TimeoutStopSec=120
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now metabase
msg_ok "Created Service"
motd_ssh
customize
cleanup_lxc