Compare commits

..

1 Commits

Author SHA1 Message Date
CanbiZ
abd433fb4e Change category ID from 15 to 13 in swizzin.json 2025-09-09 11:32:43 +02:00
7 changed files with 83 additions and 544 deletions

View File

@@ -26,10 +26,6 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
- Refactor GitHubStarsButton to wrap in Link component for external navigation [@BramSuurdje](https://github.com/BramSuurdje) ([#7492](https://github.com/community-scripts/ProxmoxVE/pull/7492))
- #### 📝 Script Information
- swizzin: Change category from nvr to media [@MickLesk](https://github.com/MickLesk) ([#7511](https://github.com/community-scripts/ProxmoxVE/pull/7511))
## 2025-09-08
### 🚀 Updated Scripts

View File

@@ -1,83 +0,0 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: vhsdream
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/gelbphoenix/autocaliweb
APP="Autocaliweb"
var_tags="${var_tags:-ebooks}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-6}"
var_os="${var_os:-debian}"
var_version="${var_version:-12}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/autocaliweb ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
setup_uv
RELEASE=$(curl -fsSL https://api.github.com/repos/gelbphoenix/autocaliweb/releases/latest | jq '.tag_name' | sed 's/^"v//;s/"$//')
if check_for_gh_release "autocaliweb" "gelbphoenix/autocaliweb"; then
msg_info "Stopping Services"
systemctl stop autocaliweb metadata-change-detector acw-ingest-service acw-auto-zipper
msg_ok "Stopped Services"
INSTALL_DIR="/opt/autocaliweb"
export VIRTUAL_ENV="${INSTALL_DIR}/venv"
$STD tar -cf ~/autocaliweb_bkp.tar "$INSTALL_DIR"/{metadata_change_logs,dirs.json,.env,scripts/ingest_watcher.sh,scripts/auto_zipper_wrapper.sh,scripts/metadata_change_detector_wrapper.sh}
fetch_and_deploy_gh_release "autocaliweb" "gelbphoenix/autocaliweb" "tarball" "latest" "/opt/autocaliweb"
msg_info "Updating ${APP}"
cd "$INSTALL_DIR"
if [[ ! -d "$VIRTUAL_ENV" ]]; then
$STD uv venv "$VIRTUAL_ENV"
fi
$STD uv sync --all-extras --active
cd "$INSTALL_DIR"/koreader/plugins
PLUGIN_DIGEST="$(find acwsync.koplugin -type f -name "*.lua" -o -name "*.json" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)"
echo "Plugin files digest: $PLUGIN_DIGEST" >acwsync.koplugin/${PLUGIN_DIGEST}.digest
echo "Build date: $(date)" >>acwsync.koplugin/${PLUGIN_DIGEST}.digest
echo "Files included:" >>acwsync.koplugin/${PLUGIN_DIGEST}.digest
$STD zip -r koplugin.zip acwsync.koplugin/
cp -r koplugin.zip "$INSTALL_DIR"/cps/static
mkdir -p "$INSTALL_DIR"/metadata_temp
$STD tar -xf ~/autocaliweb_bkp.tar --directory /
KEPUB_VERSION="$(/usr/bin/kepubify --version)"
CALIBRE_RELEASE="$(curl -s https://api.github.com/repos/kovidgoyal/calibre/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)"
echo "${KEPUB_VERSION#v}" >"$INSTALL_DIR"/KEPUBIFY_RELEASE
echo "${CALIBRE_RELEASE#v}" >/"$INSTALL_DIR"/CALIBRE_RELEASE
sed 's/^/v/' ~/.autocaliweb >"$INSTALL_DIR"/ACW_RELEASE
chown -R acw:acw "$INSTALL_DIR"
rm ~/autocaliweb_bkp.tar
msg_ok "Updated $APP"
msg_info "Starting Services"
systemctl start autocaliweb metadata-change-detector acw-ingest-service acw-auto-zipper
msg_ok "Started Services"
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}:8083${CL}"

View File

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

View File

@@ -34,13 +34,12 @@ function update_script() {
msg_ok "Stopped $APP"
msg_info "Backing up data"
BK="/opt/planka-backup"
mkdir -p "$BK"/{favicons,user-avatars,background-images,attachments}
[ -f /opt/planka/.env ] && mv /opt/planka/.env "$BK"/
[ -d /opt/planka/public/favicons ] && cp -a /opt/planka/public/favicons/. "$BK/favicons/"
[ -d /opt/planka/public/user-avatars ] && cp -a /opt/planka/public/user-avatars/. "$BK/user-avatars/"
[ -d /opt/planka/public/background-images ] && cp -a /opt/planka/public/background-images/. "$BK/background-images/"
[ -d /opt/planka/private/attachments ] && cp -a /opt/planka/private/attachments/. "$BK/attachments/"
mkdir -p /opt/planka-backup/{favicons,user-avatars,background-images,attachments}
mv /opt/planka/.env /opt/planka-backup
[ -d /opt/planka/public/favicons ] && mv /opt/planka/public/favicons/* /opt/planka-backup/favicons/
[ -d /opt/planka/public/user-avatars ] && mv /opt/planka/public/user-avatars/* /opt/planka-backup/user-avatars/
[ -d /opt/planka/public/background-images ] && mv /opt/planka/public/background-images/* /opt/planka-backup/background-images/
[ -d /opt/planka/private/attachments ] && mv /opt/planka/private/attachments/* /opt/planka-backup/attachments/
rm -rf /opt/planka
msg_ok "Backed up data"
@@ -52,13 +51,11 @@ function update_script() {
msg_ok "Updated Frontend"
msg_info "Restoring data"
[ -f "$BK/.env" ] && mv "$BK/.env" /opt/planka/.env
mkdir -p /opt/planka/public/{favicons,user-avatars,background-images} /opt/planka/private/attachments
[ -d "$BK/favicons" ] && cp -a "$BK/favicons/." /opt/planka/public/favicons/
[ -d "$BK/user-avatars" ] && cp -a "$BK/user-avatars/." /opt/planka/public/user-avatars/
[ -d "$BK/background-images" ] && cp -a "$BK/background-images/." /opt/planka/public/background-images/
[ -d "$BK/attachments" ] && cp -a "$BK/attachments/." /opt/planka/private/attachments/
rm -rf "$BK"
mv /opt/planka-backup/.env /opt/planka/
[ -d /opt/planka-backup/favicons ] && mv /opt/planka-backup/favicons/* /opt/planka/public/favicons/
[ -d /opt/planka-backup/user-avatars ] && mv /opt/planka-backup/user-avatars/* /opt/planka/public/user-avatars/
[ -d /opt/planka-backup/background-images ] && mv /opt/planka-backup/background-images/* /opt/planka/public/background-images/
[ -d /opt/planka-backup/attachments ] && mv /opt/planka-backup/attachments/* /opt/planka/private/attachments/
msg_ok "Restored data"
msg_info "Starting $APP"

View File

@@ -1,35 +0,0 @@
{
"name": "Autocaliweb",
"slug": "autocaliweb",
"categories": [
13
],
"date_created": "2025-08-30",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 8083,
"documentation": "https://github.com/gelbphoenix/autocaliweb/wiki",
"config_path": "/etc/autocaliweb",
"website": "https://github.com/gelbphoenix/autocaliweb",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/autocaliweb.webp",
"description": "A modern web management system for eBooks, eComics and PDFs",
"install_methods": [
{
"type": "default",
"script": "ct/autocaliweb.sh",
"resources": {
"cpu": 2,
"ram": 2048,
"hdd": 6,
"os": "Debian",
"version": "12"
}
}
],
"default_credentials": {
"username": "admin",
"password": "admin123"
},
"notes": []
}

View File

@@ -1,69 +1,4 @@
[
{
"name": "element-hq/synapse",
"version": "v1.138.0",
"date": "2025-09-09T11:25:50Z"
},
{
"name": "traefik/traefik",
"version": "v3.5.2",
"date": "2025-09-09T10:28:12Z"
},
{
"name": "authelia/authelia",
"version": "v4.39.9",
"date": "2025-09-09T10:20:45Z"
},
{
"name": "chrisvel/tududi",
"version": "v0.80",
"date": "2025-07-24T14:12:39Z"
},
{
"name": "docker/compose",
"version": "v2.39.3",
"date": "2025-09-09T08:27:27Z"
},
{
"name": "OctoPrint/OctoPrint",
"version": "1.11.3",
"date": "2025-09-09T08:03:31Z"
},
{
"name": "readeck/readeck",
"version": "0.20.2",
"date": "2025-09-09T06:09:25Z"
},
{
"name": "Jackett/Jackett",
"version": "v0.22.2444",
"date": "2025-09-09T06:00:01Z"
},
{
"name": "TandoorRecipes/recipes",
"version": "2.1.2",
"date": "2025-09-09T05:55:58Z"
},
{
"name": "gotson/komga",
"version": "1.23.4",
"date": "2025-09-09T02:47:05Z"
},
{
"name": "Tautulli/Tautulli",
"version": "v2.16.0",
"date": "2025-09-09T01:05:45Z"
},
{
"name": "jeedom/core",
"version": "4.4.20",
"date": "2025-09-09T00:27:11Z"
},
{
"name": "steveiliop56/tinyauth",
"version": "v3.6.2",
"date": "2025-07-17T12:08:03Z"
},
{
"name": "YunoHost/yunohost",
"version": "debian/12.1.20",
@@ -89,11 +24,6 @@
"version": "v5.40.2",
"date": "2025-09-08T20:59:44Z"
},
{
"name": "keycloak/keycloak",
"version": "26.0.15",
"date": "2025-08-27T12:12:03Z"
},
{
"name": "booklore-app/booklore",
"version": "v1.2.1",
@@ -169,16 +99,36 @@
"version": "v25.3",
"date": "2025-09-01T09:47:06Z"
},
{
"name": "TandoorRecipes/recipes",
"version": "2.1.1",
"date": "2025-09-08T06:39:30Z"
},
{
"name": "firefly-iii/firefly-iii",
"version": "v6.3.2",
"date": "2025-08-19T04:08:36Z"
},
{
"name": "Jackett/Jackett",
"version": "v0.22.2441",
"date": "2025-09-08T06:01:57Z"
},
{
"name": "webmin/webmin",
"version": "2.501",
"date": "2025-09-08T04:50:25Z"
},
{
"name": "jeedom/core",
"version": "4.4.19",
"date": "2025-09-08T00:27:05Z"
},
{
"name": "steveiliop56/tinyauth",
"version": "v3.6.2",
"date": "2025-07-17T12:08:03Z"
},
{
"name": "paperless-ngx/paperless-ngx",
"version": "v2.18.4",
@@ -216,8 +166,8 @@
},
{
"name": "runtipi/runtipi",
"version": "v4.4.0",
"date": "2025-09-02T19:26:18Z"
"version": "nightly",
"date": "2025-09-07T12:25:06Z"
},
{
"name": "semaphoreui/semaphore",
@@ -294,6 +244,11 @@
"version": "v0.12.7",
"date": "2025-09-05T18:11:36Z"
},
{
"name": "keycloak/keycloak",
"version": "26.0.15",
"date": "2025-08-27T12:12:03Z"
},
{
"name": "Brandawg93/PeaNUT",
"version": "v5.14.2",
@@ -304,6 +259,11 @@
"version": "2025.9.0",
"date": "2025-09-05T14:21:34Z"
},
{
"name": "chrisvel/tududi",
"version": "v0.80",
"date": "2025-07-24T14:12:39Z"
},
{
"name": "home-assistant/core",
"version": "2025.9.1",
@@ -454,6 +414,11 @@
"version": "v4.4.0",
"date": "2025-09-02T17:04:25Z"
},
{
"name": "element-hq/synapse",
"version": "v1.137.0",
"date": "2025-08-26T09:51:47Z"
},
{
"name": "rabbitmq/rabbitmq-server",
"version": "v4.1.4",
@@ -474,6 +439,11 @@
"version": "v25.5.0",
"date": "2025-09-02T01:00:11Z"
},
{
"name": "authelia/authelia",
"version": "v4.39.8",
"date": "2025-09-02T00:44:45Z"
},
{
"name": "postgres/postgres",
"version": "REL_18_RC1",
@@ -519,6 +489,11 @@
"version": "v1.7.0",
"date": "2025-09-01T10:10:34Z"
},
{
"name": "readeck/readeck",
"version": "0.20.1",
"date": "2025-09-01T07:35:48Z"
},
{
"name": "LibreTranslate/LibreTranslate",
"version": "v1.7.3",
@@ -584,6 +559,11 @@
"version": "v1.9.2",
"date": "2025-08-28T07:06:14Z"
},
{
"name": "gotson/komga",
"version": "1.23.3",
"date": "2025-08-28T02:50:06Z"
},
{
"name": "pocket-id/pocket-id",
"version": "v1.10.0",
@@ -599,6 +579,11 @@
"version": "v11.2.1",
"date": "2025-08-27T15:19:02Z"
},
{
"name": "traefik/traefik",
"version": "v3.5.1",
"date": "2025-08-27T09:21:19Z"
},
{
"name": "documenso/documenso",
"version": "v1.12.2-rc.6",
@@ -844,6 +829,11 @@
"version": "2.38.0",
"date": "2025-08-08T21:47:19Z"
},
{
"name": "docker/compose",
"version": "v2.39.2",
"date": "2025-08-08T16:06:06Z"
},
{
"name": "apache/tika",
"version": "3.2.2",
@@ -884,6 +874,11 @@
"version": "v2.0.116",
"date": "2025-08-05T04:45:21Z"
},
{
"name": "Tautulli/Tautulli",
"version": "v2.15.3",
"date": "2025-08-03T17:27:16Z"
},
{
"name": "linuxserver/Heimdall",
"version": "v2.7.4",
@@ -1124,6 +1119,11 @@
"version": "v2.0.0.4645",
"date": "2017-03-07T18:56:06Z"
},
{
"name": "OctoPrint/OctoPrint",
"version": "1.11.2",
"date": "2025-06-10T11:07:14Z"
},
{
"name": "glanceapp/glance",
"version": "v0.8.4",

View File

@@ -1,330 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2025 Community Scripts ORG
# Author: vhsdream
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/gelbphoenix/autocaliweb
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 --no-install-recommends \
python3-dev \
sqlite3 \
build-essential \
libldap2-dev \
libssl-dev \
libsasl2-dev \
imagemagick \
ghostscript \
libmagic1 \
libxi6 \
libxslt1.1 \
libxtst6 \
libxrandr2 \
libxkbfile1 \
libxcomposite1 \
libopengl0 \
libnss3 \
libxkbcommon0 \
libegl1 \
libxdamage1 \
libgl1 \
libglx-mesa0 \
xz-utils \
xdg-utils \
inotify-tools \
binutils \
unrar-free \
zip
msg_ok "Installed dependencies"
fetch_and_deploy_gh_release "kepubify" "pgaskin/kepubify" "singlefile" "latest" "/usr/bin" "kepubify-linux-64bit"
KEPUB_VERSION="$(/usr/bin/kepubify --version | awk '{print $2}')"
msg_info "Installing Calibre"
CALIBRE_RELEASE="$(curl -s https://api.github.com/repos/kovidgoyal/calibre/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)"
CALIBRE_VERSION=${CALIBRE_RELEASE#v}
curl -fsSL https://github.com/kovidgoyal/calibre/releases/download/${CALIBRE_RELEASE}/calibre-${CALIBRE_VERSION}-x86_64.txz -o /tmp/calibre.txz
mkdir -p /opt/calibre
$STD tar -xf /tmp/calibre.txz -C /opt/calibre
rm /tmp/calibre.txz
$STD /opt/calibre/calibre_postinstall
msg_ok "Calibre installed"
setup_uv
fetch_and_deploy_gh_release "autocaliweb" "gelbphoenix/autocaliweb" "tarball" "latest" "/opt/autocaliweb"
msg_info "Configuring Autocaliweb"
INSTALL_DIR="/opt/autocaliweb"
CONFIG_DIR="/etc/autocaliweb"
CALIBRE_LIB_DIR="/opt/calibre-library"
INGEST_DIR="/opt/acw-book-ingest"
SERVICE_USER="acw"
SERVICE_GROUP="acw"
SCRIPTS_DIR="${INSTALL_DIR}/scripts"
export VIRTUAL_ENV="${INSTALL_DIR}/venv"
mkdir -p "$CONFIG_DIR"/{.config/calibre/plugins,log_archive,.acw_conversion_tmp}
mkdir -p "$CONFIG_DIR"/processed_books/{converted,imported,failed,fixed_originals}
mkdir -p "$INSTALL_DIR"/{metadata_change_logs,metadata_temp}
mkdir -p {"$CALIBRE_LIB_DIR","$INGEST_DIR"}
echo "$CALIBRE_VERSION" >"$INSTALL_DIR"/CALIBRE_RELEASE
echo "${KEPUB_VERSION#v}" >"$INSTALL_DIR"/KEPUBIFY_RELEASE
sed 's/^/v/' ~/.autocaliweb >"$INSTALL_DIR"/ACW_RELEASE
cd "$INSTALL_DIR"
$STD uv venv "$VIRTUAL_ENV"
$STD uv sync --all-extras --active
cat <<EOF >./dirs.json
{
"ingest_folder": "$INGEST_DIR",
"calibre_library_dir": "$CALIBRE_LIB_DIR",
"tmp_conversion_dir": "$CONFIG_DIR/.acw_conversion_tmp"
}
EOF
useradd -s /usr/sbin/nologin -d "$CONFIG_DIR" -M "$SERVICE_USER"
ln -sf "$CONFIG_DIR"/.config/calibre/plugins "$CONFIG_DIR"/calibre_plugins
cat <<EOF >"$INSTALL_DIR"/.env
ACW_INSTALL_DIR=$INSTALL_DIR
ACW_CONFIG_DIR=$CONFIG_DIR
ACW_USER=$SERVICE_USER
ACW_GROUP=$SERVICE_GROUP
LIBRARY_DIR=$CALIBRE_LIB_DIR
EOF
msg_ok "Configured Autocaliweb"
msg_info "Creating ACWSync Plugin for KOReader"
cd "$INSTALL_DIR"/koreader/plugins
PLUGIN_DIGEST="$(find acwsync.koplugin -type f -name "*.lua" -o -name "*.json" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)"
echo "Plugin files digest: $PLUGIN_DIGEST" >acwsync.koplugin/${PLUGIN_DIGEST}.digest
echo "Build date: $(date)" >>acwsync.koplugin/${PLUGIN_DIGEST}.digest
echo "Files included:" >>acwsync.koplugin/${PLUGIN_DIGEST}.digest
$STD zip -r koplugin.zip acwsync.koplugin/
cp -r koplugin.zip "$INSTALL_DIR"/cps/static
msg_ok "Created ACWSync Plugin"
msg_info "Initializing databases"
KEPUBIFY_PATH=$(command -v kepubify 2>/dev/null || echo "/usr/bin/kepubify")
EBOOK_CONVERT_PATH=$(command -v ebook-convert 2>/dev/null || echo "/usr/bin/ebook-convert")
CALIBRE_BIN_DIR=$(dirname "$EBOOK_CONVERT_PATH")
curl -fsSL https://github.com/gelbphoenix/autocaliweb/raw/refs/heads/main/library/metadata.db -o "$CALIBRE_LIB_DIR"/metadata.db
curl -fsSL https://github.com/gelbphoenix/autocaliweb/raw/refs/heads/main/library/app.db -o "$CONFIG_DIR"/app.db
sqlite3 "$CONFIG_DIR/app.db" <<EOS
UPDATE settings SET
config_kepubifypath='$KEPUBIFY_PATH',
config_converterpath='$EBOOK_CONVERT_PATH',
config_binariesdir='$CALIBRE_BIN_DIR',
config_calibre_dir='$CALIBRE_LIB_DIR',
config_logfile='$CONFIG_DIR/autocaliweb.log',
config_access_logfile='$CONFIG_DIR/access.log'
WHERE 1=1;
EOS
msg_ok "Initialized databases"
msg_info "Creating scripts and service files"
# auto-ingest watcher
cat <<EOF >"$SCRIPTS_DIR"/ingest_watcher.sh
#!/bin/bash
INSTALL_PATH="$INSTALL_DIR"
WATCH_FOLDER=\$(grep -o '"ingest_folder": "[^"]*' \${INSTALL_PATH}/dirs.json | grep -o '[^"]*\$')
echo "[acw-ingest-service] Watching folder: \$WATCH_FOLDER"
# Monitor the folder for new files
/usr/bin/inotifywait -m -r --format="%e %w%f" -e close_write -e moved_to "\$WATCH_FOLDER" |
while read -r events filepath ; do
echo "[acw-ingest-service] New files detected - \$filepath - Starting Ingest Processor..."
# Use the Python interpreter from the virtual environment
\${INSTALL_PATH}/venv/bin/python \${INSTALL_PATH}/scripts/ingest_processor.py "\$filepath"
done
EOF
# auto-zipper
cat <<EOF >"$SCRIPTS_DIR"/auto_zipper_wrapper.sh
#!/bin/bash
# Source virtual environment
source ${INSTALL_DIR}/venv/bin/activate
WAKEUP="23:59"
while true; do
# Replace expr with modern Bash arithmetic (safer and less prone to parsing issues)
# fix: expr: non-integer argument and sleep: missing operand
SECS=\$(( \$(date -d "\$WAKEUP" +%s) - \$(date -d "now" +%s) ))
if [[ \$SECS -lt 0 ]]; then
SECS=\$(( \$(date -d "tomorrow \$WAKEUP" +%s) - \$(date -d "now" +%s) ))
fi
echo "[acw-auto-zipper] Next run in \$SECS seconds."
sleep \$SECS &
wait \$!
# Use virtual environment python
python ${SCRIPTS_DIR}/auto_zip.py
if [[ \$? == 1 ]]; then
echo "[acw-auto-zipper] Error occurred during script initialisation."
elif [[ \$? == 2 ]]; then
echo "[acw-auto-zipper] Error occurred while zipping today's files."
elif [[ \$? == 3 ]]; then
echo "[acw-auto-zipper] Error occurred while trying to remove zipped files."
fi
sleep 60
done
EOF
# metadata change detector
cat <<EOF >"$SCRIPTS_DIR"/metadata_change_detector_wrapper.sh
#!/bin/bash
# metadata_change_detector_wrapper.sh - Wrapper for periodic metadata enforcement
# Source virtual environment
source ${INSTALL_DIR}/venv/bin/activate
# Configuration
CHECK_INTERVAL=300 # Check every 5 minutes (300 seconds)
METADATA_LOGS_DIR="${INSTALL_DIR}/metadata_change_logs"
echo "[metadata-change-detector] Starting metadata change detector service..."
echo "[metadata-change-detector] Checking for changes every \$CHECK_INTERVAL seconds"
while true; do
# Check if there are any log files to process
if [ -d "\$METADATA_LOGS_DIR" ] && [ "\$(ls -A \$METADATA_LOGS_DIR 2>/dev/null)" ]; then
echo "[metadata-change-detector] Found metadata change logs, processing..."
# Process each log file
for log_file in "\$METADATA_LOGS_DIR"/*.json; do
if [ -f "\$log_file" ]; then
log_name=\$(basename "\$log_file")
echo "[metadata-change-detector] Processing log: \$log_name"
# Call cover_enforcer.py with the log file
${INSTALL_DIR}/venv/bin/python ${SCRIPTS_DIR}/cover_enforcer.py --log "\$log_name"
if [ \$? -eq 0 ]; then
echo "[metadata-change-detector] Successfully processed \$log_name"
else
echo "[metadata-change-detector] Error processing \$log_name"
fi
fi
done
else
echo "[metadata-change-detector] No metadata changes detected"
fi
echo "[metadata-change-detector] Sleeping for \$CHECK_INTERVAL seconds..."
sleep \$CHECK_INTERVAL
done
EOF
chmod +x "$SCRIPTS_DIR"/{ingest_watcher.sh,auto_zipper_wrapper.sh,metadata_change_detector_wrapper.sh}
chown -R "$SERVICE_USER":"$SERVICE_GROUP" {"$INSTALL_DIR","$CONFIG_DIR","$INGEST_DIR","$CALIBRE_LIB_DIR"}
cat <<EOF >/etc/systemd/system/autocaliweb.service
[Unit]
Description=Autocaliweb
After=network.target
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=$SERVICE_USER
Group=$SERVICE_GROUP
WorkingDirectory=$INSTALL_DIR
Environment=PATH=$INSTALL_DIR/venv/bin:/usr/bin:/bin
Environment=PYTHONPATH=$SCRIPTS_DIR:$INSTALL_DIR
Environment=PYTHONDONTWRITEBYTECODE=1
Environment=PYTHONUNBUFFERED=1
Environment=CALIBRE_DBPATH=$CONFIG_DIR
EnvironmentFile=$INSTALL_DIR/.env
ExecStart=$INSTALL_DIR/venv/bin/python $INSTALL_DIR/cps.py -p $CONFIG_DIR/app.db
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/acw-ingest-service.service
[Unit]
Description=Autocaliweb Ingest Processor Service
After=autocaliweb.service
Requires=autocaliweb.service
[Service]
User=${SERVICE_USER}
Group=${SERVICE_GROUP}
WorkingDirectory=${INSTALL_DIR}
Environment=CALIBRE_DBPATH=${CONFIG_DIR}
Environment=HOME=${CONFIG_DIR}
ExecStart=/bin/bash ${SCRIPTS_DIR}/ingest_watcher.sh
Restart=always
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/acw-auto-zipper.service
[Unit]
Description=Autocaliweb Auto Zipper Service
After=network.target
[Service]
User=${SERVICE_USER}
Group=${SERVICE_GROUP}
WorkingDirectory=${INSTALL_DIR}
Environment=CALIBRE_DBPATH=${CONFIG_DIR}
ExecStart=${SCRIPTS_DIR}/auto_zipper_wrapper.sh
Restart=always
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target
EOF
cat <<EOF >/etc/systemd/system/metadata-change-detector.service
[Unit]
Description=Autocaliweb Metadata Change Detector
After=network.target
[Service]
User=${SERVICE_USER}
Group=${SERVICE_GROUP}
WorkingDirectory=${INSTALL_DIR}
ExecStart=/bin/bash ${SCRIPTS_DIR}/metadata_change_detector_wrapper.sh
Restart=always
StandardOutput=journal
StandardError=journal
Environment=CALIBRE_DBPATH=${CONFIG_DIR}
Environment=HOME=${CONFIG_DIR}
[Install]
WantedBy=multi-user.target
EOF
systemctl -q enable --now autocaliweb acw-ingest-service acw-auto-zipper metadata-change-detector
msg_ok "Created scripts and service files"
motd_ssh
customize
msg_info "Cleaning up"
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"