Last active
March 6, 2025 22:20
-
-
Save vhsdream/58fb87c4b10e8fd5a09b3cfcf99cb4f0 to your computer and use it in GitHub Desktop.
Calibre-Web Automated Proxmox LXC install script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# Dirty install script for Calibre-Web Automated | |
# Done over top of a Calibre-Web install via Proxmox Helper Script | |
# https://github.com/community-scripts/ProxmoxVE/blob/main/install/calibre-web-install.sh | |
# Author: vhsdream 2025 | |
# USE AT YOUR OWN RISK | |
# AFTER RUNNING THIS SCRIPT IT'S LIKELY YOU CAN NO LONGER USE THE 'update' FUNCTION | |
# FROM Proxmox Helper Scripts | |
set -euo pipefail | |
# give warning | |
echo "This script only works if Calibre-Web was installed with the Proxmox Helper Script" && sleep 3 | |
echo "If it succeeds, you can no longer use the 'update' function from Proxmox Helper Scripts" && sleep 3 | |
echo "Run this script at your own risk. I TAKE NO RESPONSIBILITY FOR DATA LOSS!" && sleep 3 | |
echo "You have 5 seconds to cancel before the script proceeds..." && sleep 6 | |
# stop Calibre-web | |
echo "Stopping Calibre-Web service & installing CWA dependencies..." && sleep 1 | |
systemctl disable -q --now cps | |
apt-get update && \ | |
apt-get install -y --no-install-recommends \ | |
build-essential \ | |
git \ | |
libldap2-dev \ | |
libsasl2-dev \ | |
ghostscript \ | |
libldap-2.5-0 \ | |
libmagic1 \ | |
libsasl2-2 \ | |
libxi6 \ | |
libxslt1.1 \ | |
python3-venv \ | |
xdg-utils \ | |
inotify-tools \ | |
sqlite3 \ | |
echo "Dependencies installed." && sleep 2 | |
# get CWA fork with modified scripts | |
echo "Cloning Calibre-Web Automated & switching to latest release branch..." && sleep 1 | |
cd /opt | |
RELEASE=$(curl -s https://api.github.com/repos/crocodilestick/Calibre-Web-Automated/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') | |
git clone https://github.com/crocodilestick/Calibre-Web-Automated.git /opt/cwa --single-branch &>/dev/null | |
cd /opt/cwa | |
git checkout V${RELEASE} &>/dev/null | |
echo "Repo ready." && sleep 1 | |
# install additional reqs for CWA | |
echo "Installing Python requirements for CWA..." && sleep 1 | |
pip install -r requirements.txt -qqq | |
echo "Installed." && sleep 2 | |
# Install git patch file | |
echo "Applying git patch for Proxmox LXC compatibility..." && sleep 1 | |
# Patch will likely need to be downloaded from somewhere | |
# wget -q https://github-location-of-patch.patch | |
wget -q https://gist.githubusercontent.com/vhsdream/2e81afeff139c5746db1ede88c01cc7b/raw/51238206e87aec6c0abeccce85dec9f2b0c89000/proxmox-lxc.patch -O /opt/proxmox-lxc.patch | |
git apply /opt/proxmox-lxc.patch &>/dev/null | |
# creating dirs, according to setup-cwa.sh and the cwa-init s6 script (with some changes for compatibility) | |
echo "Creating required directories for CWA..." && sleep 1 | |
mkdir -p /opt/cwa-book-ingest | |
mkdir -p /var/lib/cwa/{metadata_change_logs,metadata_temp,log_archive,.cwa_conversion_tmp,processed_books} | |
mkdir -p /var/lib/cwa/processed_books/{converted,imported,failed,fixed_originals} | |
touch /var/lib/cwa/convert-library.log # fixes https://github.com/vhsdream/cwa-lxc/issues/1 | |
# the 'calibre-library' is simply the /opt/calibre-web dir so no need to change | |
# make shell scripts executable | |
cd /opt/cwa/scripts && chmod +x check-cwa-services.sh ingest-service.sh change-detector.sh | |
# copy modified calibre-web files from CWA | |
echo "Copying patched Calibre-Web files to local Python lib folder..." && sleep 1 | |
cp -r /opt/cwa/root/app/calibre-web/cps/* /usr/local/lib/python3*/dist-packages/calibreweb/cps | |
# Create service files for CWA workers | |
echo "Creating CWA worker service files..." && sleep 1 | |
cat <<EOF >/etc/systemd/system/cwa-autolibrary.service | |
[Unit] | |
Description=Calibre-Web Automated Auto-Library Service | |
After=network.target cps.service | |
[Service] | |
Type=simple | |
WorkingDirectory=/opt/cwa | |
ExecStart=/usr/bin/python3 /opt/cwa/scripts/auto_library.py | |
TimeoutStopSec=10 | |
KillMode=process | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat <<EOF >/etc/systemd/system/cwa-ingester.service | |
[Unit] | |
Description=Calibre-Web Automated Ingest Service | |
After=network.target cps.service cwa-autolibrary.service | |
[Service] | |
Type=simple | |
WorkingDirectory=/opt/cwa | |
ExecStart=/usr/bin/bash -c /opt/cwa/scripts/ingest-service.sh | |
TimeoutStopSec=10 | |
KillMode=process | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat <<EOF >/etc/systemd/system/cwa-change-detector.service | |
[Unit] | |
Description=Calibre-Web Automated Metadata Change Detector Service | |
After=network.target cps.service cwa-autolibrary.service | |
[Service] | |
Type=simple | |
WorkingDirectory=/opt/cwa | |
ExecStart=/usr/bin/bash -c /opt/cwa/scripts/change-detector.sh | |
TimeoutStopSec=10 | |
KillMode=process | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat <<EOF >/etc/systemd/system/cwa.target | |
[Unit] | |
Description=Calibre-Web Automated Services | |
After=network-online.target | |
Wants=cps.service cwa-autolibrary.service cwa-ingester.service cwa-change-detector.service cwa-autozip.timer | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
echo "Service files created." && sleep 1 | |
# Create service for auto-zip backups and systemd timer | |
echo "Creating Auto-Zip service & timer..." && sleep 1 | |
cat <<EOF >/etc/systemd/system/cwa-autozip.service | |
[Unit] | |
Description=Calibre-Web Automated Nightly Auto-Zip Backup Service | |
After=network.target cps.service | |
[Service] | |
Type=simple | |
WorkingDirectory=/var/lib/cwa/processed_books | |
ExecStart=/usr/bin/python3 /opt/cwa/scripts/auto_zip.py | |
Restart=on-failure | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
cat <<EOF >/etc/systemd/system/cwa-autozip.timer | |
[Unit] | |
Description=Calibre-Web Automated Nightly Auto-Zip Backup Timer | |
RefuseManualStart=no | |
RefuseManualStop=no | |
[Timer] | |
Persistent=true | |
# run every day at 11:59PM | |
OnCalendar=*-*-* 23:59:00 | |
Unit=cwa-autozip.service | |
[Install] | |
WantedBy=timers.target | |
EOF | |
echo "Auto-backup service & timer created" && sleep 1 | |
# Enable CWA Service target | |
echo "Enabling & starting services via cwa.target..." && sleep 1 | |
systemctl daemon-reload | |
systemctl enable -q --now cwa.target | |
echo "CWA started! (hopefully)" && sleep 1 | |
# then cleanup etc etc | |
echo "Cleaning up..." && sleep 1 | |
apt autoremove - y &>/dev/null && apt autoclean -y &>/dev/null | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment