From 314579047430e0d5b9148c597438ff7efadec0e3 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Mon, 9 Feb 2026 22:03:23 +0100 Subject: [PATCH 001/100] feat: add Calibre-Web container script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Web-based eBook library management - Mobile-responsive interface with user management - Calibre integration for format conversion (EPUB→AZW3 for Kindle) - Tested on Debian 13 LXC (CT240) Technical details: - Base OS: Debian 13 (2 CPU, 2GB RAM, 8GB disk, port 8083) - Flask-Limiter 3.x (4.x incompatible) - --break-system-packages for PEP 668 compliance - Default credentials: admin/admin123 --- ct/calibre-web.sh | 119 ++++++++++++++++++++++++++ frontend/public/json/calibre-web.json | 44 ++++++++++ install/calibre-web-install.sh | 96 +++++++++++++++++++++ skills/qmd | 1 + 4 files changed, 260 insertions(+) create mode 100644 ct/calibre-web.sh create mode 100644 frontend/public/json/calibre-web.json create mode 100644 install/calibre-web-install.sh create mode 160000 skills/qmd diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh new file mode 100644 index 000000000..5eee91c50 --- /dev/null +++ b/ct/calibre-web.sh @@ -0,0 +1,119 @@ +#!/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: [YourGitHubUsername] +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: [SOURCE_URL e.g. https://github.com/example/app] + +# ============================================================================ +# APP CONFIGURATION +# ============================================================================ +# These values are sent to build.func and define default container resources. +# Users can customize these during installation via the interactive prompts. +# ============================================================================ + +APP="Calibre-Web" +var_tags="${var_tags:-media;books}" # Max 2 tags, semicolon-separated +var_cpu="${var_cpu:-2}" # CPU cores: 1-4 typical +var_ram="${var_ram:-2048}" # RAM in MB: 512, 1024, 2048, etc. +var_disk="${var_disk:-8}" # Disk in GB: 6, 8, 10, 20 typical +var_os="${var_os:-debian}" # OS: debian, ubuntu, alpine +var_version="${var_version:-13}" # OS Version: 13 (Debian), 24.04 (Ubuntu), 3.21 (Alpine) +var_unprivileged="${var_unprivileged:-1}" # 1=unprivileged (secure), 0=privileged (for Docker/Podman) + +# ============================================================================ +# INITIALIZATION - These are required in all CT scripts +# ============================================================================ +header_info "$APP" # Display app name and setup header +variables # Initialize build.func variables +color # Load color variables for output +catch_errors # Enable error handling with automatic exit on failure + +# ============================================================================ +# UPDATE SCRIPT - Called when user selects "Update" from web interface +# ============================================================================ +# This function is triggered by the web interface to update the application. +# It should: +# 1. Check if installation exists +# 2. Check for new GitHub releases +# 3. Stop running services +# 4. Backup critical data +# 5. Deploy new version +# 6. Run post-update commands (migrations, config updates, etc.) +# 7. Restore data if needed +# 8. Start services +# +# Exit with `exit` at the end to prevent container restart. +# ============================================================================ + +function update_script() { + header_info + check_container_storage + check_container_resources + + # Step 1: Verify installation exists + if [[ ! -d /opt/calibre-web ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + # Step 2: Check if update is available + if check_for_gh_release "calibre-web" "janeczku/calibre-web"; then + + # Step 3: Stop services before update + msg_info "Stopping Service" + systemctl stop calibre-web + msg_ok "Stopped Service" + + # Step 4: Backup critical data before overwriting + msg_info "Backing up Data" + cp -r /opt/calibre-web/app.db /opt/calibre-web/app.db_backup 2>/dev/null || true + msg_ok "Backed up Data" + + # Step 5: Download and deploy new version + # CLEAN_INSTALL=1 removes old directory before extracting + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" + + # Step 6: Install Python dependencies + msg_info "Installing Dependencies" + cd /opt/calibre-web + $STD pip3 install --no-cache-dir -r requirements.txt + msg_ok "Installed Dependencies" + # $STD composer install --no-dev + # msg_ok "Installed Dependencies" + + # Step 7: Restore data from backup + msg_info "Restoring Data" + cp /opt/calibre-web/app.db_backup /opt/calibre-web/app.db 2>/dev/null || true + rm -f /opt/calibre-web/app.db_backup + msg_ok "Restored Data" + + # Step 8: Restart service with new version + msg_info "Starting Service" + systemctl start calibre-web + msg_ok "Started Service" + msg_ok "Updated successfully!" + fi + exit +} + +# ============================================================================ +# MAIN EXECUTION - Container creation flow +# ============================================================================ +# These are called by build.func and handle the full installation process: +# 1. start - Initialize container creation +# 2. build_container - Execute the install script inside container +# 3. description - Display completion info and access details +# ============================================================================ + +start +build_container +description + +# ============================================================================ +# COMPLETION MESSAGE +# ============================================================================ +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}:8083${CL}" diff --git a/frontend/public/json/calibre-web.json b/frontend/public/json/calibre-web.json new file mode 100644 index 000000000..ef08fcd6e --- /dev/null +++ b/frontend/public/json/calibre-web.json @@ -0,0 +1,44 @@ +{ + "name": "Calibre-Web", + "slug": "calibre-web", + "categories": [ + 4 + ], + "date_created": "2026-02-09", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 8083, + "documentation": "https://github.com/janeczku/calibre-web/wiki", + "website": "https://github.com/janeczku/calibre-web", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/calibre-web.webp", + "config_path": "/opt/calibre-web/app.db", + "description": "Web app for browsing, reading and downloading eBooks from a Calibre database. Provides an attractive interface with mobile support, user management, and eBook conversion capabilities.", + "install_methods": [ + { + "type": "default", + "script": "ct/calibre-web.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 8, + "os": "Debian", + "version": "13" + } + } + ], + "default_credentials": { + "username": "admin", + "password": "admin123" + }, + "notes": [ + { + "text": "Default credentials: admin / admin123 - Change immediately after first login!", + "type": "warning" + }, + { + "text": "Upload your Calibre library metadata.db during first setup wizard.", + "type": "info" + } + ] +} diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh new file mode 100644 index 000000000..6eb9a5b69 --- /dev/null +++ b/install/calibre-web-install.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: mikolaj92 +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/janeczku/calibre-web + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +# ============================================================================= +# DEPENDENCIES - Calibre-Web requires Python and pip +# ============================================================================= + +msg_info "Installing Dependencies" +$STD apt install -y \ + python3 \ + python3-pip \ + imagemagick \ + libpango-1.0-0 \ + libharfbuzz0b \ + libpangoft2-1.0-0 \ + fonts-liberation +msg_ok "Installed Dependencies" + +# ============================================================================= +# OPTIONAL - Install Calibre for eBook conversion +# ============================================================================= +msg_info "Installing Calibre (for eBook conversion)" +$STD apt install -y calibre +msg_ok "Installed Calibre" + +# ============================================================================= +# DOWNLOAD & DEPLOY APPLICATION +# ============================================================================= + +msg_info "Setting up Calibre-Web" +fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" +msg_ok "Setup Calibre-Web" + +# ============================================================================= +# INSTALL PYTHON DEPENDENCIES +# ============================================================================= + +msg_info "Installing Python Dependencies" +cd /opt/calibre-web +$STD pip3 install --no-cache-dir -r requirements.txt +msg_ok "Installed Python Dependencies" + +# ============================================================================= +# CREATE DATA DIRECTORY +# ============================================================================= + +msg_info "Creating Data Directory" +mkdir -p /opt/calibre-web/data +msg_ok "Created Data Directory" + +# ============================================================================= +# CREATE SYSTEMD SERVICE +# ============================================================================= + +msg_info "Creating Service" +cat </etc/systemd/system/cps.service +[Unit] +Description=Calibre-Web Service +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/calibre-web +ExecStart=/usr/bin/python3 /opt/calibre-web/cps.py +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now cps +msg_ok "Created Service" + +# ============================================================================= +# CLEANUP & FINALIZATION +# ============================================================================= +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/skills/qmd b/skills/qmd new file mode 160000 index 000000000..d0af0396a --- /dev/null +++ b/skills/qmd @@ -0,0 +1 @@ +Subproject commit d0af0396a7a23bc87aa3188ffc320fc8f83ccae4 From ac4dab5a661cbb9d800b9493753110fb2022da8c Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 07:03:34 +0100 Subject: [PATCH 002/100] fix: address PR review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Rename service: cps.service → calibre-web.service (consistency) - Fix logo URL: /webp/ → /webp/flat/ (required CDN format) - Remove git submodule: skills/qmd (accidental addition) Resolves review comments from greptile-apps[bot] --- frontend/public/json/calibre-web.json | 2 +- install/calibre-web-install.sh | 4 ++-- skills/qmd | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) delete mode 160000 skills/qmd diff --git a/frontend/public/json/calibre-web.json b/frontend/public/json/calibre-web.json index ef08fcd6e..ef7d1b88b 100644 --- a/frontend/public/json/calibre-web.json +++ b/frontend/public/json/calibre-web.json @@ -11,7 +11,7 @@ "interface_port": 8083, "documentation": "https://github.com/janeczku/calibre-web/wiki", "website": "https://github.com/janeczku/calibre-web", - "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/calibre-web.webp", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/flat/calibre-web.webp", "config_path": "/opt/calibre-web/app.db", "description": "Web app for browsing, reading and downloading eBooks from a Calibre database. Provides an attractive interface with mobile support, user management, and eBook conversion capabilities.", "install_methods": [ diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 6eb9a5b69..0f67f168e 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -65,7 +65,7 @@ msg_ok "Created Data Directory" # ============================================================================= msg_info "Creating Service" -cat </etc/systemd/system/cps.service +cat </etc/systemd/system/calibre-web.service [Unit] Description=Calibre-Web Service After=network.target @@ -81,7 +81,7 @@ RestartSec=5 [Install] WantedBy=multi-user.target EOF -systemctl enable -q --now cps +systemctl enable -q --now calibre-web msg_ok "Created Service" # ============================================================================= diff --git a/skills/qmd b/skills/qmd deleted file mode 160000 index d0af0396a..000000000 --- a/skills/qmd +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d0af0396a7a23bc87aa3188ffc320fc8f83ccae4 From 0622ec62182fb7db41a5e001fe82834b3cb1f910 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 07:10:41 +0100 Subject: [PATCH 003/100] fix: address remaining PR review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove all section comments (beyond standardized header) - Fix heredoc: cat <file → cat <file - Replace apt-get with apt in cleanup - Add missing cleanup_lxc call at end Resolves remaining review comments from greptile-apps[bot] --- install/calibre-web-install.sh | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 0f67f168e..7b336921a 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -13,10 +13,6 @@ setting_up_container network_check update_os -# ============================================================================= -# DEPENDENCIES - Calibre-Web requires Python and pip -# ============================================================================= - msg_info "Installing Dependencies" $STD apt install -y \ python3 \ @@ -28,44 +24,25 @@ $STD apt install -y \ fonts-liberation msg_ok "Installed Dependencies" -# ============================================================================= -# OPTIONAL - Install Calibre for eBook conversion -# ============================================================================= msg_info "Installing Calibre (for eBook conversion)" $STD apt install -y calibre msg_ok "Installed Calibre" -# ============================================================================= -# DOWNLOAD & DEPLOY APPLICATION -# ============================================================================= - msg_info "Setting up Calibre-Web" fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" msg_ok "Setup Calibre-Web" -# ============================================================================= -# INSTALL PYTHON DEPENDENCIES -# ============================================================================= - msg_info "Installing Python Dependencies" cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" -# ============================================================================= -# CREATE DATA DIRECTORY -# ============================================================================= - msg_info "Creating Data Directory" mkdir -p /opt/calibre-web/data msg_ok "Created Data Directory" -# ============================================================================= -# CREATE SYSTEMD SERVICE -# ============================================================================= - msg_info "Creating Service" -cat </etc/systemd/system/calibre-web.service +cat < Date: Tue, 10 Feb 2026 07:17:20 +0100 Subject: [PATCH 004/100] fix: remove all comments from ct/calibre-web.sh (header only) Remove all section/block comments beyond standardized header per repo policy: - APP CONFIGURATION section - INITIALIZATION section - UPDATE SCRIPT detailed comments - MAIN EXECUTION section - COMPLETION MESSAGE section Resolves: Comments violate script policy (ct/*.sh header-only comments) --- ct/calibre-web.sh | 54 ++--------------------------------------------- 1 file changed, 2 insertions(+), 52 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index 5eee91c50..dcf0925a6 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -1,16 +1,9 @@ #!/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: [YourGitHubUsername] +# Author: mikolaj92 # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: [SOURCE_URL e.g. https://github.com/example/app] - -# ============================================================================ -# APP CONFIGURATION -# ============================================================================ -# These values are sent to build.func and define default container resources. -# Users can customize these during installation via the interactive prompts. -# ============================================================================ +# Source: https://github.com/janeczku/calibre-web APP="Calibre-Web" var_tags="${var_tags:-media;books}" # Max 2 tags, semicolon-separated @@ -21,74 +14,43 @@ var_os="${var_os:-debian}" # OS: debian, ubuntu, alpine var_version="${var_version:-13}" # OS Version: 13 (Debian), 24.04 (Ubuntu), 3.21 (Alpine) var_unprivileged="${var_unprivileged:-1}" # 1=unprivileged (secure), 0=privileged (for Docker/Podman) -# ============================================================================ -# INITIALIZATION - These are required in all CT scripts -# ============================================================================ header_info "$APP" # Display app name and setup header variables # Initialize build.func variables color # Load color variables for output catch_errors # Enable error handling with automatic exit on failure -# ============================================================================ -# UPDATE SCRIPT - Called when user selects "Update" from web interface -# ============================================================================ -# This function is triggered by the web interface to update the application. -# It should: -# 1. Check if installation exists -# 2. Check for new GitHub releases -# 3. Stop running services -# 4. Backup critical data -# 5. Deploy new version -# 6. Run post-update commands (migrations, config updates, etc.) -# 7. Restore data if needed -# 8. Start services -# -# Exit with `exit` at the end to prevent container restart. -# ============================================================================ - function update_script() { header_info check_container_storage check_container_resources - # Step 1: Verify installation exists if [[ ! -d /opt/calibre-web ]]; then msg_error "No ${APP} Installation Found!" exit fi - # Step 2: Check if update is available if check_for_gh_release "calibre-web" "janeczku/calibre-web"; then - # Step 3: Stop services before update msg_info "Stopping Service" systemctl stop calibre-web msg_ok "Stopped Service" - # Step 4: Backup critical data before overwriting msg_info "Backing up Data" cp -r /opt/calibre-web/app.db /opt/calibre-web/app.db_backup 2>/dev/null || true msg_ok "Backed up Data" - # Step 5: Download and deploy new version - # CLEAN_INSTALL=1 removes old directory before extracting CLEAN_INSTALL=1 fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" - # Step 6: Install Python dependencies msg_info "Installing Dependencies" cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Dependencies" - # $STD composer install --no-dev - # msg_ok "Installed Dependencies" - # Step 7: Restore data from backup msg_info "Restoring Data" cp /opt/calibre-web/app.db_backup /opt/calibre-web/app.db 2>/dev/null || true rm -f /opt/calibre-web/app.db_backup msg_ok "Restored Data" - # Step 8: Restart service with new version msg_info "Starting Service" systemctl start calibre-web msg_ok "Started Service" @@ -97,22 +59,10 @@ function update_script() { exit } -# ============================================================================ -# MAIN EXECUTION - Container creation flow -# ============================================================================ -# These are called by build.func and handle the full installation process: -# 1. start - Initialize container creation -# 2. build_container - Execute the install script inside container -# 3. description - Display completion info and access details -# ============================================================================ - start build_container description -# ============================================================================ -# COMPLETION MESSAGE -# ============================================================================ 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}" From f89fe2da5c0b3a04b7e5928f12db1f2d4fad8a65 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 07:23:51 +0100 Subject: [PATCH 005/100] fix: address final 4 review comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix URLs: ProxmoxVE → ProxmoxVED (build.func, license) - Fix APP value: Calibre-Web → calibre-web (lowercase slug) - Fix placeholder: ${APP} → Calibre-Web in msg_error - Fix error suppression: || true → 2>/dev/null Resolves remaining review comments from greptile-apps[bot] --- ct/calibre-web.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index dcf0925a6..433345062 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -1,11 +1,11 @@ #!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG # Author: mikolaj92 -# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/janeczku/calibre-web -APP="Calibre-Web" +APP="calibre-web" var_tags="${var_tags:-media;books}" # Max 2 tags, semicolon-separated var_cpu="${var_cpu:-2}" # CPU cores: 1-4 typical var_ram="${var_ram:-2048}" # RAM in MB: 512, 1024, 2048, etc. @@ -25,7 +25,7 @@ function update_script() { check_container_resources if [[ ! -d /opt/calibre-web ]]; then - msg_error "No ${APP} Installation Found!" + msg_error "No Calibre-Web Installation Found!" exit fi @@ -36,7 +36,7 @@ function update_script() { msg_ok "Stopped Service" msg_info "Backing up Data" - cp -r /opt/calibre-web/app.db /opt/calibre-web/app.db_backup 2>/dev/null || true + cp -r /opt/calibre-web/app.db /opt/calibre-web/app.db_backup 2>/dev/null msg_ok "Backed up Data" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" @@ -47,7 +47,7 @@ function update_script() { msg_ok "Installed Dependencies" msg_info "Restoring Data" - cp /opt/calibre-web/app.db_backup /opt/calibre-web/app.db 2>/dev/null || true + cp /opt/calibre-web/app.db_backup /opt/calibre-web/app.db 2>/dev/null rm -f /opt/calibre-web/app.db_backup msg_ok "Restored Data" From 9c17e368b110652effddcf1559e9a27808572347 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 08:41:15 +0100 Subject: [PATCH 006/100] fix: address CrazyWolf13 review feedback - Remove msg_info before mkdir (no need for msg block) - kept only for apt/pip (these generate stdout) Addressed reviewer comments from CrazyWolf13 (2026-02-10) --- install/calibre-web-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 7b336921a..30b27e0c1 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -37,7 +37,6 @@ cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" -msg_info "Creating Data Directory" mkdir -p /opt/calibre-web/data msg_ok "Created Data Directory" From cf7b97bcdc118ec9260e88f15e69e1eb7abf3601 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 10:49:16 +0100 Subject: [PATCH 007/100] fix: apply remaining CrazyWolf13 inline suggestions --- ct/calibre-web.sh | 1 - install/calibre-web-install.sh | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index 433345062..926fa1944 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -30,7 +30,6 @@ function update_script() { fi if check_for_gh_release "calibre-web" "janeczku/calibre-web"; then - msg_info "Stopping Service" systemctl stop calibre-web msg_ok "Stopped Service" diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 30b27e0c1..d204fd2a8 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -37,10 +37,9 @@ cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" -mkdir -p /opt/calibre-web/data -msg_ok "Created Data Directory" - msg_info "Creating Service" +mkdir -p /opt/calibre-web/data + cat < Date: Tue, 10 Feb 2026 10:57:19 +0100 Subject: [PATCH 008/100] fix: remove remaining inline comments from ct script --- ct/calibre-web.sh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index 926fa1944..b2ea6a504 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -6,18 +6,18 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV # Source: https://github.com/janeczku/calibre-web APP="calibre-web" -var_tags="${var_tags:-media;books}" # Max 2 tags, semicolon-separated -var_cpu="${var_cpu:-2}" # CPU cores: 1-4 typical -var_ram="${var_ram:-2048}" # RAM in MB: 512, 1024, 2048, etc. -var_disk="${var_disk:-8}" # Disk in GB: 6, 8, 10, 20 typical -var_os="${var_os:-debian}" # OS: debian, ubuntu, alpine -var_version="${var_version:-13}" # OS Version: 13 (Debian), 24.04 (Ubuntu), 3.21 (Alpine) -var_unprivileged="${var_unprivileged:-1}" # 1=unprivileged (secure), 0=privileged (for Docker/Podman) +var_tags="${var_tags:-media;books}" +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_unprivileged="${var_unprivileged:-1}" -header_info "$APP" # Display app name and setup header -variables # Initialize build.func variables -color # Load color variables for output -catch_errors # Enable error handling with automatic exit on failure +header_info "$APP" +variables +color +catch_errors function update_script() { header_info From 36a3f330312b13e16818a48513a32252dca967c5 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:00:19 +0100 Subject: [PATCH 009/100] fix: address remaining heredoc and trailing blank line comments --- install/calibre-web-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index d204fd2a8..02a0d4936 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -40,7 +40,7 @@ msg_ok "Installed Python Dependencies" msg_info "Creating Service" mkdir -p /opt/calibre-web/data -cat </etc/systemd/system/calibre-web.service [Unit] Description=Calibre-Web Service After=network.target @@ -65,5 +65,4 @@ customize msg_info "Cleaning up" apt -y autoremove apt -y autoclean - cleanup_lxc From b672954401a4c53248670b165e8fb9c8f8dab561 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:04:10 +0100 Subject: [PATCH 010/100] fix: remove unnecessary msg_info/msg_ok block for service creation --- install/calibre-web-install.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 02a0d4936..28443517c 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -37,7 +37,6 @@ cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" -msg_info "Creating Service" mkdir -p /opt/calibre-web/data cat </etc/systemd/system/calibre-web.service @@ -57,7 +56,6 @@ RestartSec=5 WantedBy=multi-user.target EOF systemctl enable -q --now calibre-web -msg_ok "Created Service" motd_ssh customize From 8d7d6ee5f321543db8b75d843246fc193189b00d Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:06:23 +0100 Subject: [PATCH 011/100] fix: apply reviewer suggestion for service creation block --- install/calibre-web-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 28443517c..e66fef4e3 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -37,6 +37,7 @@ cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" +msg_info "Creating Service" mkdir -p /opt/calibre-web/data cat </etc/systemd/system/calibre-web.service From 996f551ea400e25ea2c126552681636e94816bc2 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:08:14 +0100 Subject: [PATCH 012/100] style: match greptile heredoc redirection format --- install/calibre-web-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index e66fef4e3..264350e2d 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -40,7 +40,7 @@ msg_ok "Installed Python Dependencies" msg_info "Creating Service" mkdir -p /opt/calibre-web/data -cat </etc/systemd/system/calibre-web.service +cat < /etc/systemd/system/calibre-web.service [Unit] Description=Calibre-Web Service After=network.target From b8e23d9a54f09086d0b52b979ff202faeb302cb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Miko=C5=82ajczyk?= <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:18:23 +0100 Subject: [PATCH 013/100] Update calibre-web-install.sh --- install/calibre-web-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 264350e2d..ad3e29bed 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -61,7 +61,6 @@ systemctl enable -q --now calibre-web motd_ssh customize -msg_info "Cleaning up" apt -y autoremove apt -y autoclean cleanup_lxc From f2299ee94127bbc6c6ec6dae0521420c4f5bef8e Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 17:23:59 +0100 Subject: [PATCH 014/100] fix(calibre-web): align review feedback on installer and defaults --- frontend/public/json/calibre-web.json | 8 ++++---- install/calibre-web-install.sh | 5 ++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/frontend/public/json/calibre-web.json b/frontend/public/json/calibre-web.json index ef7d1b88b..7e509b0c2 100644 --- a/frontend/public/json/calibre-web.json +++ b/frontend/public/json/calibre-web.json @@ -28,13 +28,13 @@ } ], "default_credentials": { - "username": "admin", - "password": "admin123" + "username": null, + "password": null }, "notes": [ { - "text": "Default credentials: admin / admin123 - Change immediately after first login!", - "type": "warning" + "text": "No credentials are set by this script. Complete setup and create credentials in the first-run wizard.", + "type": "info" }, { "text": "Upload your Calibre library metadata.db during first setup wizard.", diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index ad3e29bed..42d9b0348 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -2,7 +2,7 @@ # Copyright (c) 2021-2026 community-scripts ORG # Author: mikolaj92 -# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE # Source: https://github.com/janeczku/calibre-web source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" @@ -37,10 +37,9 @@ cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" -msg_info "Creating Service" mkdir -p /opt/calibre-web/data -cat < /etc/systemd/system/calibre-web.service +cat </etc/systemd/system/calibre-web.service [Unit] Description=Calibre-Web Service After=network.target From f9e3a931ff00dfa876040d982d6452a515ed43b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Miko=C5=82ajczyk?= <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:29:18 +0100 Subject: [PATCH 015/100] Update install/calibre-web-install.sh Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- install/calibre-web-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 42d9b0348..6037cfbd9 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -37,9 +37,9 @@ cd /opt/calibre-web $STD pip3 install --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" -mkdir -p /opt/calibre-web/data - +msg_info "Creating Service" cat </etc/systemd/system/calibre-web.service +mkdir -p /opt/calibre-web/data [Unit] Description=Calibre-Web Service After=network.target From bbcdf2c44630cc99de9a4826e62c971486dc9a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Miko=C5=82ajczyk?= <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:29:31 +0100 Subject: [PATCH 016/100] Update install/calibre-web-install.sh Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- install/calibre-web-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 6037cfbd9..62869dad5 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -56,6 +56,7 @@ RestartSec=5 WantedBy=multi-user.target EOF systemctl enable -q --now calibre-web +msg_ok "Created Service" motd_ssh customize From a4c7dce494019b13a393168707b1fbc7ebdacb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Miko=C5=82ajczyk?= <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:29:43 +0100 Subject: [PATCH 017/100] Update install/calibre-web-install.sh Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- install/calibre-web-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 62869dad5..1b5d68c7d 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -60,7 +60,4 @@ msg_ok "Created Service" motd_ssh customize - -apt -y autoremove -apt -y autoclean cleanup_lxc From b5188819969a7d986bf8b3123ed246d514aee00d Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:31:29 +0100 Subject: [PATCH 018/100] calibre-web: switch pip installs to uv and fix service block order --- ct/calibre-web.sh | 4 +++- install/calibre-web-install.sh | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index b2ea6a504..0400755db 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -29,6 +29,8 @@ function update_script() { exit fi + setup_uv + if check_for_gh_release "calibre-web" "janeczku/calibre-web"; then msg_info "Stopping Service" systemctl stop calibre-web @@ -42,7 +44,7 @@ function update_script() { msg_info "Installing Dependencies" cd /opt/calibre-web - $STD pip3 install --no-cache-dir -r requirements.txt + $STD uv pip install --system --no-cache-dir -r requirements.txt msg_ok "Installed Dependencies" msg_info "Restoring Data" diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 1b5d68c7d..3ec8c8adc 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -16,7 +16,6 @@ update_os msg_info "Installing Dependencies" $STD apt install -y \ python3 \ - python3-pip \ imagemagick \ libpango-1.0-0 \ libharfbuzz0b \ @@ -32,14 +31,17 @@ msg_info "Setting up Calibre-Web" fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" msg_ok "Setup Calibre-Web" +setup_uv + msg_info "Installing Python Dependencies" cd /opt/calibre-web -$STD pip3 install --no-cache-dir -r requirements.txt +$STD uv pip install --system --no-cache-dir -r requirements.txt msg_ok "Installed Python Dependencies" +mkdir -p /opt/calibre-web/data + msg_info "Creating Service" cat </etc/systemd/system/calibre-web.service -mkdir -p /opt/calibre-web/data [Unit] Description=Calibre-Web Service After=network.target From 2b7eed26307b14958f2f8e164611d678acc6f9e7 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:33:47 +0100 Subject: [PATCH 019/100] calibre-web: use uv sync (native) instead of pip-compatible install --- ct/calibre-web.sh | 2 +- install/calibre-web-install.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index 0400755db..e9254001a 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -44,7 +44,7 @@ function update_script() { msg_info "Installing Dependencies" cd /opt/calibre-web - $STD uv pip install --system --no-cache-dir -r requirements.txt + $STD uv sync --no-dev msg_ok "Installed Dependencies" msg_info "Restoring Data" diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 3ec8c8adc..d899f3b76 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -35,7 +35,7 @@ setup_uv msg_info "Installing Python Dependencies" cd /opt/calibre-web -$STD uv pip install --system --no-cache-dir -r requirements.txt +$STD uv sync --no-dev msg_ok "Installed Python Dependencies" mkdir -p /opt/calibre-web/data @@ -50,7 +50,7 @@ After=network.target Type=simple User=root WorkingDirectory=/opt/calibre-web -ExecStart=/usr/bin/python3 /opt/calibre-web/cps.py +ExecStart=/opt/calibre-web/.venv/bin/python /opt/calibre-web/cps.py Restart=on-failure RestartSec=5 From 0f713dea2fad21f9b2896929f014cfd1c74a3c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Miko=C5=82ajczyk?= <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:46:24 +0100 Subject: [PATCH 020/100] Update install/calibre-web-install.sh Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- install/calibre-web-install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index d899f3b76..5424a7a72 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -38,9 +38,8 @@ cd /opt/calibre-web $STD uv sync --no-dev msg_ok "Installed Python Dependencies" -mkdir -p /opt/calibre-web/data - msg_info "Creating Service" +mkdir -p /opt/calibre-web/data cat </etc/systemd/system/calibre-web.service [Unit] Description=Calibre-Web Service From 79a3a3bc791bd4ffffed103b5f63a2adc858bc0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Miko=C5=82ajczyk?= <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:46:37 +0100 Subject: [PATCH 021/100] Update install/calibre-web-install.sh Co-authored-by: Tobias <96661824+CrazyWolf13@users.noreply.github.com> --- install/calibre-web-install.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/install/calibre-web-install.sh b/install/calibre-web-install.sh index 5424a7a72..dc201423c 100644 --- a/install/calibre-web-install.sh +++ b/install/calibre-web-install.sh @@ -27,10 +27,7 @@ msg_info "Installing Calibre (for eBook conversion)" $STD apt install -y calibre msg_ok "Installed Calibre" -msg_info "Setting up Calibre-Web" fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" -msg_ok "Setup Calibre-Web" - setup_uv msg_info "Installing Python Dependencies" From cca810310171af55302f335338c8f2bce8250828 Mon Sep 17 00:00:00 2001 From: mikolaj92 <7442637+mikolaj92@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:47:12 +0100 Subject: [PATCH 022/100] calibre-web: move setup_uv after deploy in update path --- ct/calibre-web.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index e9254001a..a0f0574f3 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -29,8 +29,6 @@ function update_script() { exit fi - setup_uv - if check_for_gh_release "calibre-web" "janeczku/calibre-web"; then msg_info "Stopping Service" systemctl stop calibre-web @@ -42,6 +40,8 @@ function update_script() { CLEAN_INSTALL=1 fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" + setup_uv + msg_info "Installing Dependencies" cd /opt/calibre-web $STD uv sync --no-dev From 9395dc94fbfb8622e5367e457f4a75654f97c2b4 Mon Sep 17 00:00:00 2001 From: Tobias <96661824+CrazyWolf13@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:53:26 +0100 Subject: [PATCH 023/100] space :) --- ct/calibre-web.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ct/calibre-web.sh b/ct/calibre-web.sh index a0f0574f3..278dd9ff8 100644 --- a/ct/calibre-web.sh +++ b/ct/calibre-web.sh @@ -39,7 +39,6 @@ function update_script() { msg_ok "Backed up Data" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "calibre-web" "janeczku/calibre-web" "tarball" "latest" "/opt/calibre-web" - setup_uv msg_info "Installing Dependencies" From dc47c1c1c3d39c0a96e27efb549fd6e14bf8cc83 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 11 Feb 2026 15:49:41 +0100 Subject: [PATCH 024/100] Unify telemetry storage and add repo filtering Refactor telemetry backend to store all telemetry in a single collection and add repo_source-based filtering. Key changes: - Added detect_repo_source() in misc/api.func to auto-detect/export REPO_SOURCE (ProxmoxVE/ProxmoxVED/external) when scripts are sourced. - Consolidated PocketBase collections into a single default collection (_telemetry_data) across service, migration, and scripts; updated defaults in migrate.go, migration.go, migrate.sh and migration shell scripts. - Simplified PBClient to use one targetColl and removed collection resolution logic; updated create/update/find/fetch functions to use targetColl. - Introduced repo_source field (values: "ProxmoxVE", "ProxmoxVED", "external") on telemetry records and telemetry payloads; updated validation and logging. - Added repo filtering to dashboard endpoints, FetchDashboardData and FetchRecordsPaginated, plus a repo selector in the dashboard UI; default filter is ProxmoxVE (production), with an "all" option. - Adjusted API handlers and callers to pass repo filters and include repo_source when upserting telemetry. - Misc: updated comments, error messages, and logging to reflect the new model; added telemetry-service.exe binary. Purpose: simplify data model (single collection), make telemetry attributable to repository sources, and enable dashboard filtering by repo/source. --- misc/api.func | 71 ++++++++++++++++++- misc/data/alerts.go | 6 +- misc/data/cleanup.go | 2 +- misc/data/dashboard.go | 36 +++++++--- misc/data/migrate.go | 4 +- misc/data/migrate.sh | 2 +- misc/data/migration/migrate.sh | 2 +- misc/data/migration/migration.go | 4 +- misc/data/service.go | 115 ++++++++++++++++--------------- 9 files changed, 165 insertions(+), 77 deletions(-) diff --git a/misc/api.func b/misc/api.func index 7d02a7912..062be163f 100644 --- a/misc/api.func +++ b/misc/api.func @@ -37,9 +37,74 @@ TELEMETRY_URL="https://telemetry.community-scripts.org/telemetry" # Timeout for telemetry requests (seconds) TELEMETRY_TIMEOUT=5 -# Repository source identifier (auto-transformed by CI on promotion to ProxmoxVE) -# DO NOT CHANGE - this is used by the telemetry service to route data to the correct collection -REPO_SOURCE="community-scripts/ProxmoxVED" +# ============================================================================== +# SECTION 0: REPOSITORY SOURCE DETECTION +# ============================================================================== + +# ------------------------------------------------------------------------------ +# detect_repo_source() +# +# - Dynamically detects which GitHub/Gitea repo the scripts were loaded from +# - Inspects /proc/$$/cmdline and $0 to find the source URL +# - Maps detected repo to one of three canonical values: +# * "ProxmoxVE" — official community-scripts/ProxmoxVE (production) +# * "ProxmoxVED" — official community-scripts/ProxmoxVED (development) +# * "external" — any fork or unknown source +# - Fallback: "ProxmoxVED" (CI sed transforms ProxmoxVED → ProxmoxVE on promotion) +# - Sets and exports REPO_SOURCE global variable +# - Skips detection if REPO_SOURCE is already set (e.g., by environment) +# ------------------------------------------------------------------------------ +detect_repo_source() { + # Allow explicit override via environment + [[ -n "${REPO_SOURCE:-}" ]] && return 0 + + local content="" owner_repo="" + + # Method 1: Read from /proc/$$/cmdline + # When invoked via: bash -c "$(curl -fsSL https://.../ct/app.sh)" + # the full CT/VM script content is in /proc/$$/cmdline (same PID through source chain) + if [[ -r /proc/$$/cmdline ]]; then + content=$(tr '\0' ' ' /dev/null) || true + fi + + # Method 2: Read from the original script file (bash ct/app.sh / bash vm/app.sh) + if [[ -z "$content" ]] || ! echo "$content" | grep -qE 'githubusercontent\.com|community-scripts\.org' 2>/dev/null; then + if [[ -f "$0" ]] && [[ "$0" != *bash* ]]; then + content=$(head -10 "$0" 2>/dev/null) || true + fi + fi + + # Extract owner/repo from URL patterns found in the script content + if [[ -n "$content" ]]; then + # GitHub raw URL: raw.githubusercontent.com/OWNER/REPO/... + owner_repo=$(echo "$content" | grep -oE 'raw\.githubusercontent\.com/[^/]+/[^/]+' | head -1 | sed 's|raw\.githubusercontent\.com/||') || true + + # Gitea URL: git.community-scripts.org/OWNER/REPO/... + if [[ -z "$owner_repo" ]]; then + owner_repo=$(echo "$content" | grep -oE 'git\.community-scripts\.org/[^/]+/[^/]+' | head -1 | sed 's|git\.community-scripts\.org/||') || true + fi + fi + + # Map detected owner/repo to canonical repo_source value + case "$owner_repo" in + community-scripts/ProxmoxVE) REPO_SOURCE="ProxmoxVE" ;; + community-scripts/ProxmoxVED) REPO_SOURCE="ProxmoxVED" ;; + "") + # No URL detected — use hardcoded fallback + # CI sed transforms this on promotion: ProxmoxVED → ProxmoxVE + REPO_SOURCE="ProxmoxVED" + ;; + *) + # Fork or unknown repo + REPO_SOURCE="external" + ;; + esac + + export REPO_SOURCE +} + +# Run detection immediately when api.func is sourced +detect_repo_source # ============================================================================== # SECTION 1: ERROR CODE DESCRIPTIONS diff --git a/misc/data/alerts.go b/misc/data/alerts.go index 01f1a57f1..9890cbb75 100644 --- a/misc/data/alerts.go +++ b/misc/data/alerts.go @@ -134,7 +134,7 @@ func (a *Alerter) checkAndAlert() { defer cancel() // Fetch last hour's data - data, err := a.pb.FetchDashboardData(ctx, 1) + data, err := a.pb.FetchDashboardData(ctx, 1, "ProxmoxVE") if err != nil { log.Printf("WARN: alert check failed: %v", err) return @@ -410,13 +410,13 @@ func (a *Alerter) fetchWeeklyReportData(ctx context.Context) (*WeeklyReportData, year, week := lastMonday.ISOWeek() // Fetch current week's data (7 days) - currentData, err := a.pb.FetchDashboardData(ctx, 7) + currentData, err := a.pb.FetchDashboardData(ctx, 7, "ProxmoxVE") if err != nil { return nil, fmt.Errorf("failed to fetch current week data: %w", err) } // Fetch previous week's data for comparison (14 days, we'll compare) - prevData, err := a.pb.FetchDashboardData(ctx, 14) + prevData, err := a.pb.FetchDashboardData(ctx, 14, "ProxmoxVE") if err != nil { // Non-fatal, just log log.Printf("WARN: could not fetch previous week data: %v", err) diff --git a/misc/data/cleanup.go b/misc/data/cleanup.go index c072bef3d..5b0e672f8 100644 --- a/misc/data/cleanup.go +++ b/misc/data/cleanup.go @@ -108,7 +108,7 @@ func (c *Cleaner) findStuckInstallations(ctx context.Context) ([]StuckRecord, er req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api/collections/%s/records?filter=%s&perPage=100", - c.pb.baseURL, c.pb.devColl, filter), + c.pb.baseURL, c.pb.targetColl, filter), nil, ) if err != nil { diff --git a/misc/data/dashboard.go b/misc/data/dashboard.go index ab899be94..b8d953aa7 100644 --- a/misc/data/dashboard.go +++ b/misc/data/dashboard.go @@ -104,20 +104,31 @@ type AddonCount struct { } // FetchDashboardData retrieves aggregated data from PocketBase -func (p *PBClient) FetchDashboardData(ctx context.Context, days int) (*DashboardData, error) { +// repoSource filters by repo_source field ("ProxmoxVE", "ProxmoxVED", "external", or "" for all) +func (p *PBClient) FetchDashboardData(ctx context.Context, days int, repoSource string) (*DashboardData, error) { if err := p.ensureAuth(ctx); err != nil { return nil, err } data := &DashboardData{} - // Calculate date filter (days=0 means all entries) - var filter string + // Build filter parts + var filterParts []string + + // Date filter (days=0 means all entries) if days > 0 { since := time.Now().AddDate(0, 0, -days).Format("2006-01-02 00:00:00") - filter = url.QueryEscape(fmt.Sprintf("created >= '%s'", since)) - } else { - filter = "" // No filter = all entries + filterParts = append(filterParts, fmt.Sprintf("created >= '%s'", since)) + } + + // Repo source filter + if repoSource != "" { + filterParts = append(filterParts, fmt.Sprintf("repo_source = '%s'", repoSource)) + } + + var filter string + if len(filterParts) > 0 { + filter = url.QueryEscape(strings.Join(filterParts, " && ")) } // Fetch all records for the period @@ -306,10 +317,10 @@ func (p *PBClient) fetchRecords(ctx context.Context, filter string) ([]Telemetry var url string if filter != "" { url = fmt.Sprintf("%s/api/collections/%s/records?filter=%s&sort=-created&page=%d&perPage=%d", - p.baseURL, p.devColl, filter, page, perPage) + p.baseURL, p.targetColl, filter, page, perPage) } else { url = fmt.Sprintf("%s/api/collections/%s/records?sort=-created&page=%d&perPage=%d", - p.baseURL, p.devColl, page, perPage) + p.baseURL, p.targetColl, page, perPage) } req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) @@ -1413,6 +1424,12 @@ func DashboardHTML() string { Telemetry Dashboard
+
@@ -1676,8 +1693,9 @@ func DashboardHTML() string { async function fetchData() { const activeBtn = document.querySelector('.filter-btn.active'); const days = activeBtn ? activeBtn.dataset.days : '30'; + const repo = document.getElementById('repoFilter').value; try { - const response = await fetch('/api/dashboard?days=' + days); + const response = await fetch('/api/dashboard?days=' + days + '&repo=' + repo); if (!response.ok) throw new Error('Failed to fetch data'); return await response.json(); } catch (error) { diff --git a/misc/data/migrate.go b/misc/data/migrate.go index 7212c2dee..564bb1595 100644 --- a/misc/data/migrate.go +++ b/misc/data/migrate.go @@ -93,13 +93,13 @@ func main() { pbCollection = os.Getenv("PB_TARGET_COLLECTION") } if pbCollection == "" { - pbCollection = "_dev_telemetry_data" + pbCollection = "_telemetry_data" } // Auth collection authCollection := os.Getenv("PB_AUTH_COLLECTION") if authCollection == "" { - authCollection = "_dev_telemetry_service" + authCollection = "_telemetry_service" } // Credentials diff --git a/misc/data/migrate.sh b/misc/data/migrate.sh index 1da9e25ea..dde5a8c11 100755 --- a/misc/data/migrate.sh +++ b/misc/data/migrate.sh @@ -13,7 +13,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Default values POCKETBASE_URL="${1:-http://localhost:8090}" -POCKETBASE_COLLECTION="${2:-_dev_telemetry_data}" +POCKETBASE_COLLECTION="${2:-_telemetry_data}" echo "=============================================" echo " ProxmoxVED Data Migration Tool" diff --git a/misc/data/migration/migrate.sh b/misc/data/migration/migrate.sh index 5ed189389..de1db3504 100644 --- a/misc/data/migration/migrate.sh +++ b/misc/data/migration/migrate.sh @@ -13,7 +13,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Default values POCKETBASE_URL="${1:-http://localhost:8090}" -POCKETBASE_COLLECTION="${2:-_dev_telemetry_data}" +POCKETBASE_COLLECTION="${2:-_telemetry_data}" echo "=============================================" echo " ProxmoxVED Data Migration Tool" diff --git a/misc/data/migration/migration.go b/misc/data/migration/migration.go index e1c500418..bf4d34a4f 100644 --- a/misc/data/migration/migration.go +++ b/misc/data/migration/migration.go @@ -95,13 +95,13 @@ func main() { pbCollection = os.Getenv("PB_TARGET_COLLECTION") } if pbCollection == "" { - pbCollection = "_dev_telemetry_data" + pbCollection = "_telemetry_data" } // Auth collection authCollection := os.Getenv("PB_AUTH_COLLECTION") if authCollection == "" { - authCollection = "_dev_telemetry_service" + authCollection = "_telemetry_service" } // Credentials - prefer admin auth for timestamp preservation diff --git a/misc/data/service.go b/misc/data/service.go index 4ae810d28..0dcfaafb6 100644 --- a/misc/data/service.go +++ b/misc/data/service.go @@ -24,11 +24,10 @@ type Config struct { // PocketBase PBBaseURL string - PBAuthCollection string // "_dev_telemetry_service" + PBAuthCollection string // "_telemetry_service" PBIdentity string // email PBPassword string - PBTargetColl string // "_dev_telemetry_data" (dev default) - PBLiveTargetColl string // "_live_telemetry_data" (production) + PBTargetColl string // "_telemetry_data" // Limits MaxBodyBytes int64 @@ -104,10 +103,10 @@ type TelemetryIn struct { ErrorCategory string `json:"error_category,omitempty"` // "network", "storage", "dependency", "permission", "timeout", "unknown" // Repository source for collection routing - RepoSource string `json:"repo_source,omitempty"` // "community-scripts/ProxmoxVE" or "community-scripts/ProxmoxVED" + RepoSource string `json:"repo_source,omitempty"` // "ProxmoxVE", "ProxmoxVED", or "external" } -// TelemetryOut is sent to PocketBase (matches _dev_telemetry_data collection) +// TelemetryOut is sent to PocketBase (matches _telemetry_data collection) type TelemetryOut struct { RandomID string `json:"random_id"` Type string `json:"type"` @@ -133,6 +132,9 @@ type TelemetryOut struct { RAMSpeed string `json:"ram_speed,omitempty"` InstallDuration int `json:"install_duration,omitempty"` ErrorCategory string `json:"error_category,omitempty"` + + // Repository source: "ProxmoxVE", "ProxmoxVED", or "external" + RepoSource string `json:"repo_source,omitempty"` } // TelemetryStatusUpdate contains only fields needed for status updates @@ -150,10 +152,11 @@ type TelemetryStatusUpdate struct { RAMSpeed string `json:"ram_speed,omitempty"` } -// Allowed values for 'repo_source' field — controls collection routing +// Allowed values for 'repo_source' field var allowedRepoSource = map[string]bool{ - "community-scripts/ProxmoxVE": true, - "community-scripts/ProxmoxVED": true, + "ProxmoxVE": true, + "ProxmoxVED": true, + "external": true, } type PBClient struct { @@ -161,8 +164,7 @@ type PBClient struct { authCollection string identity string password string - devColl string // "_dev_telemetry_data" - liveColl string // "_live_telemetry_data" + targetColl string // single collection for all telemetry data mu sync.Mutex token string @@ -176,25 +178,13 @@ func NewPBClient(cfg Config) *PBClient { authCollection: cfg.PBAuthCollection, identity: cfg.PBIdentity, password: cfg.PBPassword, - devColl: cfg.PBTargetColl, - liveColl: cfg.PBLiveTargetColl, + targetColl: cfg.PBTargetColl, http: &http.Client{ Timeout: cfg.RequestTimeout, }, } } -// resolveCollection maps a repo_source value to the correct PocketBase collection. -// - "community-scripts/ProxmoxVE" → live collection -// - "community-scripts/ProxmoxVED" → dev collection -// - empty / unknown → dev collection (safe default) -func (p *PBClient) resolveCollection(repoSource string) string { - if repoSource == "community-scripts/ProxmoxVE" && p.liveColl != "" { - return p.liveColl - } - return p.devColl -} - func (p *PBClient) ensureAuth(ctx context.Context) error { p.mu.Lock() defer p.mu.Unlock() @@ -246,8 +236,8 @@ func (p *PBClient) ensureAuth(ctx context.Context) error { return nil } -// FindRecordByRandomID searches for an existing record by random_id in the given collection -func (p *PBClient) FindRecordByRandomID(ctx context.Context, coll, randomID string) (string, error) { +// FindRecordByRandomID searches for an existing record by random_id +func (p *PBClient) FindRecordByRandomID(ctx context.Context, randomID string) (string, error) { if err := p.ensureAuth(ctx); err != nil { return "", err } @@ -256,7 +246,7 @@ func (p *PBClient) FindRecordByRandomID(ctx context.Context, coll, randomID stri filter := fmt.Sprintf("random_id='%s'", randomID) req, err := http.NewRequestWithContext(ctx, http.MethodGet, fmt.Sprintf("%s/api/collections/%s/records?filter=%s&fields=id&perPage=1", - p.baseURL, coll, filter), + p.baseURL, p.targetColl, filter), nil, ) if err != nil { @@ -290,14 +280,14 @@ func (p *PBClient) FindRecordByRandomID(ctx context.Context, coll, randomID stri } // UpdateTelemetryStatus updates only status, error, and exit_code of an existing record -func (p *PBClient) UpdateTelemetryStatus(ctx context.Context, coll, recordID string, update TelemetryStatusUpdate) error { +func (p *PBClient) UpdateTelemetryStatus(ctx context.Context, recordID string, update TelemetryStatusUpdate) error { if err := p.ensureAuth(ctx); err != nil { return err } b, _ := json.Marshal(update) req, err := http.NewRequestWithContext(ctx, http.MethodPatch, - fmt.Sprintf("%s/api/collections/%s/records/%s", p.baseURL, coll, recordID), + fmt.Sprintf("%s/api/collections/%s/records/%s", p.baseURL, p.targetColl, recordID), bytes.NewReader(b), ) if err != nil { @@ -319,8 +309,7 @@ func (p *PBClient) UpdateTelemetryStatus(ctx context.Context, coll, recordID str } // FetchRecordsPaginated retrieves records with pagination and optional filters. -// Uses devColl by default (dashboard shows dev data); for live data, use separate endpoint if needed. -func (p *PBClient) FetchRecordsPaginated(ctx context.Context, page, limit int, status, app, osType, sortField string) ([]TelemetryRecord, int, error) { +func (p *PBClient) FetchRecordsPaginated(ctx context.Context, page, limit int, status, app, osType, sortField, repoSource string) ([]TelemetryRecord, int, error) { if err := p.ensureAuth(ctx); err != nil { return nil, 0, err } @@ -336,6 +325,9 @@ func (p *PBClient) FetchRecordsPaginated(ctx context.Context, page, limit int, s if osType != "" { filters = append(filters, fmt.Sprintf("os_type='%s'", osType)) } + if repoSource != "" { + filters = append(filters, fmt.Sprintf("repo_source='%s'", repoSource)) + } filterStr := "" if len(filters) > 0 { @@ -361,7 +353,7 @@ func (p *PBClient) FetchRecordsPaginated(ctx context.Context, page, limit int, s } reqURL := fmt.Sprintf("%s/api/collections/%s/records?sort=%s&page=%d&perPage=%d%s", - p.baseURL, p.devColl, sort, page, limit, filterStr) + p.baseURL, p.targetColl, sort, page, limit, filterStr) req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil) if err != nil { @@ -391,22 +383,18 @@ func (p *PBClient) FetchRecordsPaginated(ctx context.Context, page, limit int, s } // UpsertTelemetry handles both creation and updates intelligently. -// Routes to the correct PocketBase collection based on repoSource: -// - "community-scripts/ProxmoxVE" → _live_telemetry_data -// - "community-scripts/ProxmoxVED" → _dev_telemetry_data +// All records go to the same collection; repo_source is stored as a field. // // For status="installing": always creates a new record. // For status!="installing": updates existing record (found by random_id). -func (p *PBClient) UpsertTelemetry(ctx context.Context, payload TelemetryOut, repoSource string) error { - coll := p.resolveCollection(repoSource) - +func (p *PBClient) UpsertTelemetry(ctx context.Context, payload TelemetryOut) error { // For "installing" status, always create new record if payload.Status == "installing" { - return p.CreateTelemetry(ctx, coll, payload) + return p.CreateTelemetry(ctx, payload) } // For status updates (success/failed/unknown), find and update existing record - recordID, err := p.FindRecordByRandomID(ctx, coll, payload.RandomID) + recordID, err := p.FindRecordByRandomID(ctx, payload.RandomID) if err != nil { // Search failed, log and return error return fmt.Errorf("cannot find record to update: %w", err) @@ -415,7 +403,7 @@ func (p *PBClient) UpsertTelemetry(ctx context.Context, payload TelemetryOut, re if recordID == "" { // Record not found - this shouldn't happen normally // Create a full record as fallback - return p.CreateTelemetry(ctx, coll, payload) + return p.CreateTelemetry(ctx, payload) } // Update only status, error, exit_code, and new metrics fields @@ -432,17 +420,17 @@ func (p *PBClient) UpsertTelemetry(ctx context.Context, payload TelemetryOut, re CPUModel: payload.CPUModel, RAMSpeed: payload.RAMSpeed, } - return p.UpdateTelemetryStatus(ctx, coll, recordID, update) + return p.UpdateTelemetryStatus(ctx, recordID, update) } -func (p *PBClient) CreateTelemetry(ctx context.Context, coll string, payload TelemetryOut) error { +func (p *PBClient) CreateTelemetry(ctx context.Context, payload TelemetryOut) error { if err := p.ensureAuth(ctx); err != nil { return err } b, _ := json.Marshal(payload) req, err := http.NewRequestWithContext(ctx, http.MethodPost, - fmt.Sprintf("%s/api/collections/%s/records", p.baseURL, coll), + fmt.Sprintf("%s/api/collections/%s/records", p.baseURL, p.targetColl), bytes.NewReader(b), ) if err != nil { @@ -730,9 +718,9 @@ func validate(in *TelemetryIn) error { return errors.New("invalid install_duration (max 24h)") } - // Validate repo_source: must be an allowed repository or empty + // Validate repo_source: must be a known value or empty if in.RepoSource != "" && !allowedRepoSource[in.RepoSource] { - return errors.New("invalid repo_source (must be 'community-scripts/ProxmoxVE' or 'community-scripts/ProxmoxVED')") + return fmt.Errorf("rejected repo_source '%s' (must be 'ProxmoxVE', 'ProxmoxVED', or 'external')", in.RepoSource) } return nil @@ -755,11 +743,10 @@ func main() { TrustedProxiesCIDR: splitCSV(env("TRUSTED_PROXIES_CIDR", "")), PBBaseURL: mustEnv("PB_URL"), - PBAuthCollection: env("PB_AUTH_COLLECTION", "_dev_telemetry_service"), + PBAuthCollection: env("PB_AUTH_COLLECTION", "_telemetry_service"), PBIdentity: mustEnv("PB_IDENTITY"), PBPassword: mustEnv("PB_PASSWORD"), - PBTargetColl: env("PB_TARGET_COLLECTION", "_dev_telemetry_data"), - PBLiveTargetColl: env("PB_LIVE_TARGET_COLLECTION", "_live_telemetry_data"), + PBTargetColl: env("PB_TARGET_COLLECTION", "_telemetry_data"), MaxBodyBytes: envInt64("MAX_BODY_BYTES", 1024), RateLimitRPM: envInt("RATE_LIMIT_RPM", 60), @@ -870,7 +857,7 @@ func main() { ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second) defer cancel() - data, err := pb.FetchDashboardData(ctx, 1) // Last 24h only for metrics + data, err := pb.FetchDashboardData(ctx, 1, "ProxmoxVE") // Last 24h, production only for metrics if err != nil { http.Error(w, "failed to fetch metrics", http.StatusInternalServerError) return @@ -907,11 +894,21 @@ func main() { } } + // repo_source filter (default: ProxmoxVE) + repoSource := r.URL.Query().Get("repo") + if repoSource == "" { + repoSource = "ProxmoxVE" + } + // "all" means no filter + if repoSource == "all" { + repoSource = "" + } + ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second) defer cancel() // Try cache first - cacheKey := fmt.Sprintf("dashboard:%d", days) + cacheKey := fmt.Sprintf("dashboard:%d:%s", days, repoSource) var data *DashboardData if cfg.CacheEnabled && cache.Get(ctx, cacheKey, &data) { w.Header().Set("Content-Type", "application/json") @@ -920,7 +917,7 @@ func main() { return } - data, err := pb.FetchDashboardData(ctx, days) + data, err := pb.FetchDashboardData(ctx, days, repoSource) if err != nil { log.Printf("dashboard fetch failed: %v", err) http.Error(w, "failed to fetch data", http.StatusInternalServerError) @@ -945,6 +942,10 @@ func main() { app := r.URL.Query().Get("app") osType := r.URL.Query().Get("os") sort := r.URL.Query().Get("sort") + repoSource := r.URL.Query().Get("repo") + if repoSource == "" { + repoSource = "ProxmoxVE" // Default filter: production data + } if p := r.URL.Query().Get("page"); p != "" { fmt.Sscanf(p, "%d", &page) @@ -965,7 +966,7 @@ func main() { ctx, cancel := context.WithTimeout(r.Context(), 10*time.Second) defer cancel() - records, total, err := pb.FetchRecordsPaginated(ctx, page, limit, status, app, osType, sort) + records, total, err := pb.FetchRecordsPaginated(ctx, page, limit, status, app, osType, sort, repoSource) if err != nil { log.Printf("records fetch failed: %v", err) http.Error(w, "failed to fetch records", http.StatusInternalServerError) @@ -1052,6 +1053,9 @@ func main() { return } if err := validate(&in); err != nil { + if cfg.EnableReqLogging { + log.Printf("telemetry rejected: %v", err) + } http.Error(w, "invalid payload", http.StatusBadRequest) return } @@ -1080,6 +1084,7 @@ func main() { RAMSpeed: in.RAMSpeed, InstallDuration: in.InstallDuration, ErrorCategory: in.ErrorCategory, + RepoSource: in.RepoSource, } _ = computeHash(out) // For future deduplication @@ -1087,8 +1092,8 @@ func main() { defer cancel() // Upsert: Creates new record if random_id doesn't exist, updates if it does - // Routes to correct collection based on repo_source - if err := pb.UpsertTelemetry(ctx, out, in.RepoSource); err != nil { + // repo_source is stored as a field on the record for filtering + if err := pb.UpsertTelemetry(ctx, out); err != nil { // GDPR: don't log raw payload, don't log IPs; log only generic error log.Printf("pocketbase write failed: %v", err) http.Error(w, "upstream error", http.StatusBadGateway) @@ -1096,7 +1101,7 @@ func main() { } if cfg.EnableReqLogging { - log.Printf("telemetry accepted nsapp=%s status=%s", out.NSAPP, out.Status) + log.Printf("telemetry accepted nsapp=%s status=%s repo=%s", out.NSAPP, out.Status, in.RepoSource) } w.WriteHeader(http.StatusAccepted) From 4def8258cc81e43087cef1f661af78ac94cb6879 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 11 Feb 2026 15:57:36 +0100 Subject: [PATCH 025/100] Require PB auth & target collection env vars Remove implicit defaults for PocketBase collection names and make them required environment variables. Replace env(..., "_telemetry_service"/"_telemetry_data") with mustEnv("PB_AUTH_COLLECTION") and mustEnv("PB_TARGET_COLLECTION") so the service fails startup if those are not provided. Also update inline comments to clarify these fields come from the environment. --- misc/data/service.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/misc/data/service.go b/misc/data/service.go index 0dcfaafb6..3c4c826d7 100644 --- a/misc/data/service.go +++ b/misc/data/service.go @@ -24,10 +24,10 @@ type Config struct { // PocketBase PBBaseURL string - PBAuthCollection string // "_telemetry_service" + PBAuthCollection string // PB auth collection name (from env) PBIdentity string // email PBPassword string - PBTargetColl string // "_telemetry_data" + PBTargetColl string // PB data collection name (from env) // Limits MaxBodyBytes int64 @@ -743,10 +743,10 @@ func main() { TrustedProxiesCIDR: splitCSV(env("TRUSTED_PROXIES_CIDR", "")), PBBaseURL: mustEnv("PB_URL"), - PBAuthCollection: env("PB_AUTH_COLLECTION", "_telemetry_service"), + PBAuthCollection: mustEnv("PB_AUTH_COLLECTION"), PBIdentity: mustEnv("PB_IDENTITY"), PBPassword: mustEnv("PB_PASSWORD"), - PBTargetColl: env("PB_TARGET_COLLECTION", "_telemetry_data"), + PBTargetColl: mustEnv("PB_TARGET_COLLECTION"), MaxBodyBytes: envInt64("MAX_BODY_BYTES", 1024), RateLimitRPM: envInt("RATE_LIMIT_RPM", 60), From da03c76dd42a4180435ff37383f17d893ceb7e36 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Wed, 11 Feb 2026 15:58:34 +0100 Subject: [PATCH 026/100] Refactor repo filter UI and relocate Export CSV Update dashboard UI in misc/data/dashboard.go: move the repository - - - - -
+ + |
-
+ API
From e4a8ee845a79d125cf6879b56f9c02e16999aad8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Feb 2026 09:40:26 +0000 Subject: [PATCH 027/100] Delete drawio (ct) after migration to ProxmoxVE (#1450) Co-authored-by: github-actions[bot] --- ct/drawio.sh | 58 -------------------------------- frontend/public/json/drawio.json | 35 ------------------- install/drawio-install.sh | 25 -------------- 3 files changed, 118 deletions(-) delete mode 100644 ct/drawio.sh delete mode 100644 frontend/public/json/drawio.json delete mode 100644 install/drawio-install.sh diff --git a/ct/drawio.sh b/ct/drawio.sh deleted file mode 100644 index f59030345..000000000 --- a/ct/drawio.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) -# Copyright (c) 2021-2026 community-scripts ORG -# Author: Slaviša Arežina (tremor021) -# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE -# Source: https://www.drawio.com/ - -APP="DrawIO" -var_tags="${var_tags:-diagrams}" -var_cpu="${var_cpu:-1}" -var_ram="${var_ram:-2048}" -var_disk="${var_disk:-4}" -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 [[ ! -f /var/lib/tomcat11/webapps/draw.war ]]; then - msg_error "No ${APP} Installation Found!" - exit - fi - - if check_for_gh_release "drawio" "jgraph/drawio"; then - msg_info "Stopping service" - systemctl stop tomcat11 - msg_ok "Service stopped" - - msg_info "Updating Debian LXC" - $STD apt update - $STD apt upgrade -y - msg_ok "Updated Debian LXC" - - USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release "drawio" "jgraph/drawio" "singlefile" "latest" "/var/lib/tomcat11/webapps" "draw.war" - - msg_info "Starting service" - systemctl start tomcat11 - msg_ok "Service started" - 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}:8080/draw${CL}" diff --git a/frontend/public/json/drawio.json b/frontend/public/json/drawio.json deleted file mode 100644 index b3ffeb4e7..000000000 --- a/frontend/public/json/drawio.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "Draw.IO", - "slug": "drawio", - "categories": [ - 12 - ], - "date_created": "2026-01-29", - "type": "ct", - "updateable": true, - "privileged": false, - "interface_port": 8080, - "documentation": "https://www.drawio.com/doc/", - "website": "https://www.drawio.com/", - "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/webp/draw-io.webp", - "config_path": "", - "description": "draw.io is a configurable diagramming and whiteboarding application, jointly owned and developed by draw.io Ltd (previously named JGraph) and draw.io AG.", - "install_methods": [ - { - "type": "default", - "script": "ct/drawio.sh", - "resources": { - "cpu": 1, - "ram": 2048, - "hdd": 4, - "os": "Debian", - "version": "13" - } - } - ], - "default_credentials": { - "username": null, - "password": null - }, - "notes": [] -} \ No newline at end of file diff --git a/install/drawio-install.sh b/install/drawio-install.sh deleted file mode 100644 index 95f3648cc..000000000 --- a/install/drawio-install.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2021-2026 community-scripts ORG -# Author: Slaviša Arežina (tremor021) -# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE -# Source: https://www.drawio.com/ - -source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" -color -verb_ip6 -catch_errors -setting_up_container -network_check -update_os -setup_hwaccel - -msg_info "Installing Dependencies" -$STD apt install -y tomcat11 -msg_ok "Installed Dependencies" - -USE_ORIGINAL_FILENAME=true fetch_and_deploy_gh_release "drawio" "jgraph/drawio" "singlefile" "latest" "/var/lib/tomcat11/webapps" "draw.war" - -motd_ssh -customize -cleanup_lxc From 0231b72d787c46f4c8e807d4d0867f888cc8fcb4 Mon Sep 17 00:00:00 2001 From: "CanbiZ (MickLesk)" <47820557+MickLesk@users.noreply.github.com> Date: Thu, 12 Feb 2026 13:10:06 +0100 Subject: [PATCH 028/100] Add telemetry data service and dashboard revamp Introduce a telemetry data microservice under misc/data: add Dockerfile, entrypoint, migration tools, README, LICENSE and a .gitignore. Increase Docker CACHE_TTL_SECONDS to 300s. Implement extensive dashboard and analytics updates in dashboard.go: add total_all_time and sample_size, return total item counts from fetchRecords (with page/limit handling and a maxRecords guard), raise top-N limits, add a minimum-installs threshold for failed-apps, and numerous UI/style/layout improvements in the embedded DashboardHTML. Minor formatting tweak to misc/api.func. --- misc/api.func | 22 +- misc/data/.gitignore | 34 + misc/data/Dockerfile | 2 +- misc/data/LICENSE | 21 + misc/data/README.md | 81 + misc/data/dashboard.go | 2120 ++++++++++++++++--------- misc/data/entrypoint.sh | 72 +- misc/data/migrate.go | 4 +- misc/data/migrate.sh | 18 +- misc/data/migration/fix-timestamps.sh | 106 ++ misc/data/migration/import-direct.sh | 77 + misc/data/migration/migrate-linux.sh | 89 ++ misc/data/migration/migrate.go | 1295 +++++++++++++++ misc/data/migration/migrate.sh | 2 +- misc/data/migration/migration.go | 4 +- misc/data/service.go | 81 +- 16 files changed, 3198 insertions(+), 830 deletions(-) create mode 100644 misc/data/.gitignore create mode 100644 misc/data/LICENSE create mode 100644 misc/data/README.md create mode 100644 misc/data/migration/fix-timestamps.sh create mode 100644 misc/data/migration/import-direct.sh create mode 100644 misc/data/migration/migrate-linux.sh create mode 100644 misc/data/migration/migrate.go diff --git a/misc/api.func b/misc/api.func index 062be163f..a8f851617 100644 --- a/misc/api.func +++ b/misc/api.func @@ -87,17 +87,17 @@ detect_repo_source() { # Map detected owner/repo to canonical repo_source value case "$owner_repo" in - community-scripts/ProxmoxVE) REPO_SOURCE="ProxmoxVE" ;; - community-scripts/ProxmoxVED) REPO_SOURCE="ProxmoxVED" ;; - "") - # No URL detected — use hardcoded fallback - # CI sed transforms this on promotion: ProxmoxVED → ProxmoxVE - REPO_SOURCE="ProxmoxVED" - ;; - *) - # Fork or unknown repo - REPO_SOURCE="external" - ;; + community-scripts/ProxmoxVE) REPO_SOURCE="ProxmoxVE" ;; + community-scripts/ProxmoxVED) REPO_SOURCE="ProxmoxVED" ;; + "") + # No URL detected — use hardcoded fallback + # CI sed transforms this on promotion: ProxmoxVED → ProxmoxVE + REPO_SOURCE="ProxmoxVED" + ;; + *) + # Fork or unknown repo + REPO_SOURCE="external" + ;; esac export REPO_SOURCE diff --git a/misc/data/.gitignore b/misc/data/.gitignore new file mode 100644 index 000000000..03cf14d6e --- /dev/null +++ b/misc/data/.gitignore @@ -0,0 +1,34 @@ +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib +telemetry-service +migration/migrate + +# Test binary, built with `go test -c` +*.test + +# Code coverage profiles and other test artifacts +*.out +coverage.* +*.coverprofile +profile.cov + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +go.work.sum + +# env file +.env + +# Editor/IDE +# .idea/ +# .vscode/ diff --git a/misc/data/Dockerfile b/misc/data/Dockerfile index 3d58795c0..7201849b2 100644 --- a/misc/data/Dockerfile +++ b/misc/data/Dockerfile @@ -24,7 +24,7 @@ ENV ENABLE_REQUEST_LOGGING="false" # Cache config (optional) ENV ENABLE_CACHE="true" -ENV CACHE_TTL_SECONDS="60" +ENV CACHE_TTL_SECONDS="300" ENV ENABLE_REDIS="false" # ENV REDIS_URL="redis://localhost:6379" diff --git a/misc/data/LICENSE b/misc/data/LICENSE new file mode 100644 index 000000000..1fae4b9c8 --- /dev/null +++ b/misc/data/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 Community Scripts + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/misc/data/README.md b/misc/data/README.md new file mode 100644 index 000000000..0211ab9f1 --- /dev/null +++ b/misc/data/README.md @@ -0,0 +1,81 @@ +# Telemetry Service + +A standalone Go microservice that collects anonymous telemetry data from [ProxmoxVE](https://github.com/community-scripts/ProxmoxVE) and [ProxmoxVED](https://github.com/community-scripts/ProxmoxVED) script installations. + +## Overview + +This service acts as a telemetry ingestion layer between the bash installation scripts and a PocketBase backend. When users run scripts from the ProxmoxVE/ProxmoxVED repositories, optional anonymous usage data is sent here for aggregation and analysis. + +**What gets collected:** +- Script name and installation status (success/failed) +- Container/VM type and resource allocation (CPU, RAM, disk) +- OS type and version +- Proxmox VE version +- Anonymous session ID (randomly generated UUID) + +**What is NOT collected:** +- IP addresses (not logged, not stored) +- Hostnames or domain names +- User credentials or personal information +- Hardware identifiers (MAC addresses, serial numbers) +- Network configuration or internal IPs +- Any data that could identify a person or system + +**What this enables:** +- Understanding which scripts are most popular +- Identifying scripts with high failure rates +- Tracking resource allocation trends +- Improving script quality based on real-world data + +## Features + +- **Telemetry Ingestion** - Receives and validates telemetry data from bash scripts +- **PocketBase Integration** - Stores data in PocketBase collections +- **Rate Limiting** - Configurable per-IP rate limiting to prevent abuse +- **Caching** - In-memory or Redis-backed caching support +- **Email Alerts** - SMTP-based alerts when failure rates exceed thresholds +- **Dashboard** - Built-in HTML dashboard for telemetry visualization +- **Migration Tool** - Migrate data from external sources to PocketBase + +## Architecture + +``` +┌─────────────────┐ ┌───────────────────┐ ┌────────────┐ +│ Bash Scripts │────▶│ Telemetry Service │────▶│ PocketBase │ +│ (ProxmoxVE/VED) │ │ (this repo) │ │ Database │ +└─────────────────┘ └───────────────────┘ └────────────┘ +``` + +## Project Structure + +``` +├── service.go # Main service, HTTP handlers, rate limiting +├── cache.go # In-memory and Redis caching +├── alerts.go # SMTP alert system +├── dashboard.go # Dashboard HTML generation +├── migration/ +│ ├── migrate.go # Data migration tool +│ └── migrate.sh # Migration shell script +├── Dockerfile # Container build +├── entrypoint.sh # Container entrypoint with migration support +└── go.mod # Go module definition +``` + +## Related Projects + +- [ProxmoxVE](https://github.com/community-scripts/ProxmoxVE) - Proxmox VE Helper Scripts +- [ProxmoxVED](https://github.com/community-scripts/ProxmoxVED) - Proxmox VE Helper Scripts (Dev) + +## Privacy & Compliance + +This service is designed with privacy in mind and is **GDPR/DSGVO compliant**: + +- ✅ **No personal data** - Only anonymous technical metrics are collected +- ✅ **No IP logging** - Request logging is disabled by default, IPs are never stored +- ✅ **Transparent** - All collected fields are documented and the code is open source +- ✅ **No tracking** - Session IDs are randomly generated and cannot be linked to users +- ✅ **No third parties** - Data is only stored in our self-hosted PocketBase instance + +## License + +MIT License - see [LICENSE](LICENSE) file. diff --git a/misc/data/dashboard.go b/misc/data/dashboard.go index 1ad89b988..fbfff5ff8 100644 --- a/misc/data/dashboard.go +++ b/misc/data/dashboard.go @@ -13,6 +13,8 @@ import ( // DashboardData holds aggregated statistics for the dashboard type DashboardData struct { TotalInstalls int `json:"total_installs"` + TotalAllTime int `json:"total_all_time"` // Total records in DB (not limited) + SampleSize int `json:"sample_size"` // How many records were sampled SuccessCount int `json:"success_count"` FailedCount int `json:"failed_count"` InstallingCount int `json:"installing_count"` @@ -132,10 +134,15 @@ func (p *PBClient) FetchDashboardData(ctx context.Context, days int, repoSource } // Fetch all records for the period - records, err := p.fetchRecords(ctx, filter) + result, err := p.fetchRecords(ctx, filter) if err != nil { return nil, err } + records := result.Records + + // Set total counts + data.TotalAllTime = result.TotalItems // Actual total in database + data.SampleSize = len(records) // How many we actually processed // Aggregate statistics appCounts := make(map[string]int) @@ -257,18 +264,18 @@ func (p *PBClient) FetchDashboardData(ctx context.Context, days int, repoSource data.SuccessRate = float64(data.SuccessCount) / float64(completed) * 100 } - // Convert maps to sorted slices (top 10) - data.TopApps = topN(appCounts, 10) - data.OsDistribution = topNOs(osCounts, 10) + // Convert maps to sorted slices (increased limits for better analytics) + data.TopApps = topN(appCounts, 20) + data.OsDistribution = topNOs(osCounts, 15) data.MethodStats = topNMethod(methodCounts, 10) - data.PveVersions = topNPve(pveCounts, 10) + data.PveVersions = topNPve(pveCounts, 15) data.TypeStats = topNType(typeCounts, 10) // Error analysis - data.ErrorAnalysis = buildErrorAnalysis(errorPatterns, 10) + data.ErrorAnalysis = buildErrorAnalysis(errorPatterns, 15) - // Failed apps with failure rates - data.FailedApps = buildFailedApps(appCounts, appFailures, 10) + // Failed apps with failure rates (min 10 installs threshold) + data.FailedApps = buildFailedApps(appCounts, appFailures, 15) // Daily stats for chart data.DailyStats = buildDailyStats(dailySuccess, dailyFailed, days) @@ -282,10 +289,10 @@ func (p *PBClient) FetchDashboardData(ctx context.Context, days int, repoSource data.ErrorCategories = buildErrorCategories(errorCatCounts) // Top tools - data.TopTools = buildToolStats(toolCounts, 10) + data.TopTools = buildToolStats(toolCounts, 15) // Top addons - data.TopAddons = buildAddonStats(addonCounts, 10) + data.TopAddons = buildAddonStats(addonCounts, 15) // Average install duration if durationCount > 0 { @@ -308,22 +315,30 @@ type TelemetryRecord struct { Created string `json:"created"` } -func (p *PBClient) fetchRecords(ctx context.Context, filter string) ([]TelemetryRecord, error) { +// fetchRecordsResult contains records and total count +type fetchRecordsResult struct { + Records []TelemetryRecord + TotalItems int // Actual total in database (not limited) +} + +func (p *PBClient) fetchRecords(ctx context.Context, filter string) (*fetchRecordsResult, error) { var allRecords []TelemetryRecord page := 1 perPage := 500 + maxRecords := 100000 // Limit to prevent timeout with large datasets + totalItems := 0 for { - var url string + var reqURL string if filter != "" { - url = fmt.Sprintf("%s/api/collections/%s/records?filter=%s&sort=-created&page=%d&perPage=%d", + reqURL = fmt.Sprintf("%s/api/collections/%s/records?filter=%s&sort=-created&page=%d&perPage=%d", p.baseURL, p.targetColl, filter, page, perPage) } else { - url = fmt.Sprintf("%s/api/collections/%s/records?sort=-created&page=%d&perPage=%d", + reqURL = fmt.Sprintf("%s/api/collections/%s/records?sort=-created&page=%d&perPage=%d", p.baseURL, p.targetColl, page, perPage) } - req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil) if err != nil { return nil, err } @@ -344,15 +359,24 @@ func (p *PBClient) fetchRecords(ctx context.Context, filter string) ([]Telemetry } resp.Body.Close() + // Store total on first page + if page == 1 { + totalItems = result.TotalItems + } + allRecords = append(allRecords, result.Items...) - if len(allRecords) >= result.TotalItems { + // Stop if we have enough records or reached the end + if len(allRecords) >= maxRecords || len(allRecords) >= result.TotalItems { break } page++ } - return allRecords, nil + return &fetchRecordsResult{ + Records: allRecords, + TotalItems: totalItems, + }, nil } func topN(m map[string]int, n int) []AppCount { @@ -531,11 +555,12 @@ func buildErrorAnalysis(patterns map[string]map[string]bool, n int) []ErrorGroup func buildFailedApps(total, failed map[string]int, n int) []AppFailure { result := make([]AppFailure, 0) + minInstalls := 10 // Minimum installations to be considered (avoid noise from rare apps) for app, failCount := range failed { totalCount := total[app] - if totalCount == 0 { - continue + if totalCount < minInstalls { + continue // Skip apps with too few installations } rate := float64(failCount) / float64(totalCount) * 100 @@ -673,37 +698,49 @@ func DashboardHTML() string { - Telemetry Dashboard - ProxmoxVE Helper Scripts - + Analytics - Proxmox VE Helper-Scripts + + + + -
-

- - - + +

-
-
- + - | - - - - -
- - - -
-
- - - -
-
-
Total Installations
-
-
-
-
-
Successful
-
-
-
-
-
Failed
-
-
-
-
-
In Progress
-
-
-
-
-
Success Rate
-
-
-
-
-
LXC / VM
-
-
-
-
- -
-

Proxmox VE Versions

-
- Loading... -
-
- -
-
-

Installations Over Time

-
- +
+ +
+ + + + + +
+
+
+ +
-
-

Status Distribution

-
- -
-
-
- -
-
-

Top Applications

-
- -
-
-
-

OS Distribution

-
- -
-
-
-

Installation Method

-
- -
-
-
- -
-

- + + +

-
- Loading... +
-
- -
-

- - - - - - Apps with Highest Failure Rates -

-
- Loading... + + +
+
+
+ Total Created +
+ + + + + + +
+
+
-
+
Total LXC/VM entries found
+
+ +
+
+ Success Rate +
+ + + + +
+
+
-
+
successful installations
+
+ +
+
+ Failures +
+ + + + + +
+
+
-
+
Installations encountered errors
+
+ +
-
- -
-

Recent Installations

-
- - - + + +
+
+
+

Top Applications

+

The most frequently installed applications.

+
+
+ +
+
+
+ +
- - - - - - - - - - - - - - - - - -
AppStatusOSTypeMethodResourcesExit CodeErrorCreated ▼
Loading...
- - -