New Script: Calibre-Web Automated
This commit is contained in:
parent
bdad391191
commit
7763945268
82
ct/calibre-web-automated.sh
Normal file
82
ct/calibre-web-automated.sh
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func)
|
||||||
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
|
# Author: vhsdream
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/crocodilestick/Calibre-Web-Automated
|
||||||
|
|
||||||
|
APP="Calibre-Web-Automated"
|
||||||
|
var_tags="eBook"
|
||||||
|
var_cpu="2"
|
||||||
|
var_ram="2048"
|
||||||
|
var_disk="4"
|
||||||
|
var_os="debian"
|
||||||
|
var_version="12"
|
||||||
|
var_unprivileged="1"
|
||||||
|
|
||||||
|
header_info "$APP"
|
||||||
|
variables
|
||||||
|
color
|
||||||
|
catch_errors
|
||||||
|
|
||||||
|
function update_script() {
|
||||||
|
header_info
|
||||||
|
check_container_storage
|
||||||
|
check_container_resources
|
||||||
|
|
||||||
|
if [[ ! -d /opt/cwa ]]; then
|
||||||
|
msg_error "No ${APP} Installation Found!"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
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) }')
|
||||||
|
if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then
|
||||||
|
msg_info "Stopping $APP"
|
||||||
|
systemctl stop cps cwa-autolibrary cwa-ingester cwa-change-detector cwa-autozip.timer
|
||||||
|
msg_ok "Stopped $APP"
|
||||||
|
|
||||||
|
msg_info "Creating Backup"
|
||||||
|
$STD tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/cwa /opt/calibre-web/metadata.db
|
||||||
|
cp dirs.json /opt/dirs.json.bak # not sure if necessary
|
||||||
|
msg_ok "Backup Created"
|
||||||
|
|
||||||
|
msg_info "Updating $APP to v${RELEASE}"
|
||||||
|
cd /opt/kepubify
|
||||||
|
rm -rf kepubify-linux-64bit
|
||||||
|
curl -fsSLO https://github.com/pgaskin/kepubify/releases/latest/download/kepubify-linux-64bit
|
||||||
|
chmod +x kepubify-linux-64bit
|
||||||
|
cd /opt/calibre-web
|
||||||
|
$STD pip install --upgrade calibreweb[goodreads,metadata,kobo]
|
||||||
|
cd /opt/cwa
|
||||||
|
$STD git pull
|
||||||
|
$STD pip install -r requirements.txt
|
||||||
|
wget -q https://raw.githubusercontent.com/vhsdream/cwa-lxc/refs/heads/dev/proxmox-lxc.patch -O /opt/cwa.patch # not for production
|
||||||
|
$STD git apply --whitespace=fix /opt/cwa.patch # not for production
|
||||||
|
cp -r /opt/cwa/root/app/calibre-web/cps/* /usr/local/lib/python3*/dist-packages/calibreweb/cps
|
||||||
|
msg_ok "Updated $APP to v${RELEASE}"
|
||||||
|
|
||||||
|
msg_info "Starting $APP"
|
||||||
|
systemctl start cps cwa-autolibrary cwa-ingester cwa-change-detector cwa-autozip.timer
|
||||||
|
msg_ok "Started $APP"
|
||||||
|
|
||||||
|
msg_info "Cleaning Up"
|
||||||
|
rm -rf /opt/cwa.patch
|
||||||
|
rm -rf "/opt/${APP}_backup_$(date +%F).tar.gz"
|
||||||
|
msg_ok "Cleanup Completed"
|
||||||
|
|
||||||
|
echo "${RELEASE}" >/opt/${APP}_version.txt
|
||||||
|
msg_ok "Update Successful"
|
||||||
|
else
|
||||||
|
msg_ok "No update required. ${APP} is already at v${RELEASE}"
|
||||||
|
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}:8083${CL}"
|
204
install/calibre-web-automated-install.sh
Normal file
204
install/calibre-web-automated-install.sh
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (c) 2021-2025 community-scripts ORG
|
||||||
|
# Author: vhsdream
|
||||||
|
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
|
||||||
|
# Source: https://github.com/crocodilestick/Calibre-Web-Automated
|
||||||
|
|
||||||
|
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
|
||||||
|
color
|
||||||
|
verb_ip6
|
||||||
|
catch_errors
|
||||||
|
setting_up_container
|
||||||
|
network_check
|
||||||
|
update_os
|
||||||
|
|
||||||
|
msg_info "Installing Dependencies"
|
||||||
|
$STD apt-get install -y \
|
||||||
|
curl \
|
||||||
|
sudo \
|
||||||
|
mc \
|
||||||
|
build-essential \
|
||||||
|
imagemagick \
|
||||||
|
git \
|
||||||
|
libldap2-dev \
|
||||||
|
libsasl2-dev \
|
||||||
|
ghostscript \
|
||||||
|
libldap-2.5-0 \
|
||||||
|
libmagic1 \
|
||||||
|
libsasl2-2 \
|
||||||
|
libxi6 \
|
||||||
|
libxslt1.1 \
|
||||||
|
python3-pip \
|
||||||
|
python3-venv \
|
||||||
|
xdg-utils \
|
||||||
|
inotify-tools \
|
||||||
|
sqlite3
|
||||||
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
msg_info "Installing Kepubify"
|
||||||
|
mkdir -p /opt/kepubify
|
||||||
|
cd /opt/kepubify
|
||||||
|
curl -fsSLO https://github.com/pgaskin/kepubify/releases/latest/download/kepubify-linux-64bit &>/dev/null
|
||||||
|
chmod +x kepubify-linux-64bit
|
||||||
|
msg_ok "Installed Kepubify"
|
||||||
|
|
||||||
|
msg_info "Installing Calibre-Web"
|
||||||
|
rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED
|
||||||
|
mkdir -p /opt/calibre-web
|
||||||
|
$STD apt-get install -y calibre
|
||||||
|
$STD wget https://github.com/janeczku/calibre-web/raw/master/library/metadata.db -P /opt/calibre-web
|
||||||
|
$STD pip install calibreweb[goodreads,metadata,kobo]
|
||||||
|
$STD pip install jsonschema
|
||||||
|
msg_ok "Installed Calibre-Web"
|
||||||
|
|
||||||
|
msg_info "Creating Calibre-Web Service"
|
||||||
|
cat <<EOF >/etc/systemd/system/cps.service
|
||||||
|
[Unit]
|
||||||
|
Description=Calibre-Web Server
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/opt/calibre-web
|
||||||
|
ExecStart=/usr/local/bin/cps
|
||||||
|
TimeoutStopSec=20
|
||||||
|
KillMode=process
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
msg_ok "Service file created"
|
||||||
|
|
||||||
|
msg_info "Starting and then stopping Calibre-Web Service"
|
||||||
|
systemctl start cps && sleep 5 && systemctl stop cps
|
||||||
|
msg_ok "Calibre-Web Service successfully cycled"
|
||||||
|
|
||||||
|
msg_info "Setup ${APPLICATION}"
|
||||||
|
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) }')
|
||||||
|
$STD git clone https://github.com/crocodilestick/Calibre-Web-Automated.git /opt/cwa --single-branch
|
||||||
|
cd /opt/cwa
|
||||||
|
$STD git checkout V${RELEASE}
|
||||||
|
$STD pip install -r requirements.txt
|
||||||
|
wget -q https://raw.githubusercontent.com/vhsdream/cwa-lxc/refs/heads/dev/proxmox-lxc.patch -O /opt/cwa.patch # not for production
|
||||||
|
$STD git apply --whitespace=fix /opt/cwa.patch # not for production
|
||||||
|
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
|
||||||
|
msg_ok "Setup ${APPLICATION}"
|
||||||
|
|
||||||
|
msg_info "Creating necessary files & directories"
|
||||||
|
mkdir -p /opt/cwa/{metadata_change_logs,metadata_temp}
|
||||||
|
mkdir -p /opt/cwa-book-ingest
|
||||||
|
mkdir -p /var/lib/cwa/{processed_books,log_archive,.cwa_conversion_tmp}
|
||||||
|
mkdir -p /var/lib/cwa/processed_books/{converted,imported,failed,fixed_originals}
|
||||||
|
touch /var/lib/cwa/convert-library.log
|
||||||
|
msg_ok "Directories & files created"
|
||||||
|
|
||||||
|
msg_info "Copying patched Calibre-Web files into local Python lib folder"
|
||||||
|
cp -r /opt/cwa/root/app/calibre-web/cps/* /usr/local/lib/python3*/dist-packages/calibreweb/cps
|
||||||
|
msg_ok "Files copied"
|
||||||
|
|
||||||
|
msg_info "Creating Services and Timers"
|
||||||
|
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=mixed
|
||||||
|
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=mixed
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
systemctl enable -q --now cwa.target
|
||||||
|
msg_ok "Created Services and Timers"
|
||||||
|
|
||||||
|
motd_ssh
|
||||||
|
customize
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
msg_info "Cleaning up"
|
||||||
|
rm -rf /opt/cwa.patch
|
||||||
|
$STD apt-get -y autoremove
|
||||||
|
$STD apt-get -y autoclean
|
||||||
|
msg_ok "Cleaned"
|
43
json/calibre-web-automated.json
Normal file
43
json/calibre-web-automated.json
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name": "Calibre-Web-Automated",
|
||||||
|
"slug": "calibre-web-automated",
|
||||||
|
"categories": [
|
||||||
|
11
|
||||||
|
],
|
||||||
|
"date_created": "2025-03-02",
|
||||||
|
"type": "ct",
|
||||||
|
"updateable": true,
|
||||||
|
"privileged": false,
|
||||||
|
"interface_port": 8083,
|
||||||
|
"documentation": null,
|
||||||
|
"website": "https://github.com/crocodilestick/Calibre-Web-Automated",
|
||||||
|
"logo": "https://sasquatters.com/media/2017/04/Calibre-web-banner-768x512.jpg",
|
||||||
|
"description": "Calibre-Web but automated and with Calibre features! Fully automate and simplify your eBook set up!",
|
||||||
|
"install_methods": [
|
||||||
|
{
|
||||||
|
"type": "default",
|
||||||
|
"script": "ct/calibre-web-automated.sh",
|
||||||
|
"resources": {
|
||||||
|
"cpu": 2,
|
||||||
|
"ram": 2048,
|
||||||
|
"hdd": 4,
|
||||||
|
"os": "debian",
|
||||||
|
"version": "12"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"default_credentials": {
|
||||||
|
"username": "admin",
|
||||||
|
"password": "admin123"
|
||||||
|
},
|
||||||
|
"notes": [
|
||||||
|
{
|
||||||
|
"text": "This LXC is not interchangeable with the Calibre-Web LXC",
|
||||||
|
"type": "warning"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "Options enabled by default: Kobo sync; Goodreads author info; metadata extaction from epub, fb2, pdf; cover extraction from cbr, cbz, cbt files"
|
||||||
|
"type": "info"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user