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] 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