From f9f3517ed404707beeed926dc31485a4f5e713a2 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 09:54:24 -0400 Subject: [PATCH 01/12] Autocaliweb: fix tar --- install/autocaliweb-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 4c6e6400..09dae8a5 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -51,7 +51,7 @@ 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 -$STD tar -xf /tmp/calibre.txz /opt/calibre +$STD tar -xf /tmp/calibre.txz -C /opt/calibre rm /tmp/calibre.txz $STD /opt/calibre/calibre_postinstall msg_ok "Calibre installed" From 230909ca3ea169d918783bcf80de42b55a65e0be Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 10:06:20 -0400 Subject: [PATCH 02/12] Autocaliweb: create calibre dir --- install/autocaliweb-install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 09dae8a5..faf315c1 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -51,6 +51,7 @@ 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 From 11b52f7703c9f20baf1753cf70982cb7cdaea187 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 14:34:02 -0400 Subject: [PATCH 03/12] Autocaliweb: add python3-dev and install via pyproject.toml --- install/autocaliweb-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index faf315c1..2a698b53 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -15,7 +15,7 @@ update_os msg_info "Installing dependencies" $STD apt-get install -y --no-install-recommends \ - git \ + python3-dev \ sqlite3 \ build-essential \ libldap2-dev \ @@ -78,7 +78,7 @@ mkdir -p {"$CALIBRE_LIB_DIR","$INGEST_DIR"} cd "$INSTALL_DIR" $STD uv venv "$VIRTUAL_ENV" -$STD uv sync --all-extras --active +$STD uv pip install -r pyproject.toml --all-extras cat <./dirs.json { "ingest_folder": "$INGEST_DIR", From 3325c153cf4f3b060a20a06a449566f8592ac086 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 14:44:17 -0400 Subject: [PATCH 04/12] Autocaliweb: source venv --- install/autocaliweb-install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 2a698b53..741bd9ff 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -78,7 +78,9 @@ mkdir -p {"$CALIBRE_LIB_DIR","$INGEST_DIR"} cd "$INSTALL_DIR" $STD uv venv "$VIRTUAL_ENV" +$STD source "$VIRTUAL_ENV" $STD uv pip install -r pyproject.toml --all-extras +$STD deactivate cat <./dirs.json { "ingest_folder": "$INGEST_DIR", From c48041711d4ebe9f0d1c11b340eedee9c841a8ed Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 14:49:59 -0400 Subject: [PATCH 05/12] fix --- install/autocaliweb-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 741bd9ff..0260f7ff 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -78,7 +78,7 @@ mkdir -p {"$CALIBRE_LIB_DIR","$INGEST_DIR"} cd "$INSTALL_DIR" $STD uv venv "$VIRTUAL_ENV" -$STD source "$VIRTUAL_ENV" +$STD source "$VIRTUAL_ENV"/bin/activate $STD uv pip install -r pyproject.toml --all-extras $STD deactivate cat <./dirs.json From 8fa33480fe0b85f29113931865784b2da5b415a2 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 15:00:34 -0400 Subject: [PATCH 06/12] Autocaliweb: fetch DB files since they aren't in release (why?) --- install/autocaliweb-install.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 0260f7ff..7f860ff3 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -106,9 +106,8 @@ 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") -cp "$INSTALL_DIR"/library/metadata.db "$CALIBRE_LIB_DIR"/metadata.db - -cp "$INSTALL_DIR"/library/app.db "$CONFIG_DIR"/app.db +curl -fsSL https://github.com/gelbphoenix/autocaliweb/raw/refs/heads/master/library/metadata.db -o "$CALIBRE_LIB_DIR"/metadata.db +curl -fsSL https://github.com/gelbphoenix/autocaliweb/raw/refs/heads/master/library/app.db -o "$CONFIG_DIR"/app.db sqlite3 "$CONFIG_DIR/app.db" < Date: Tue, 26 Aug 2025 15:14:05 -0400 Subject: [PATCH 07/12] Autocaliweb: export venv; fix issues with vars --- install/autocaliweb-install.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 7f860ff3..a5846d2e 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -69,7 +69,7 @@ INGEST_DIR="/opt/acw-book-ingest" SERVICE_USER="acw" SERVICE_GROUP="acw" SCRIPTS_DIR="${INSTALL_DIR}/scripts" -VIRTUAL_ENV="${INSTALL_DIR}/venv" +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} @@ -126,7 +126,8 @@ msg_info "Creating scripts and service files" cat <"$SCRIPTS_DIR"/ingest_watcher.sh #!/bin/bash -WATCH_FOLDER=\$(grep -o '"ingest_folder": "[^"]*' \${INSTALL_DIR}/dirs.json | grep -o '[^"]*\$') +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 @@ -134,7 +135,7 @@ echo "[acw-ingest-service] Watching folder: \$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 - \${VIRTUAL_ENV}/bin/python \${SCRIPTS_DIR}/ingest_processor.py "\$filepath" + ${VIRTUAL_ENV}/bin/python \${INSTALL_PATH}/ingest_processor.py "\$filepath" done EOF From f4b00c42fd79dce13d11da655f159dcc58140401 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 15:20:01 -0400 Subject: [PATCH 08/12] Autocaliweb: revert --- install/autocaliweb-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index a5846d2e..1ece6b6b 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -69,7 +69,7 @@ INGEST_DIR="/opt/acw-book-ingest" SERVICE_USER="acw" SERVICE_GROUP="acw" SCRIPTS_DIR="${INSTALL_DIR}/scripts" -export VIRTUAL_ENV="${INSTALL_DIR}/venv" +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} @@ -135,7 +135,7 @@ echo "[acw-ingest-service] Watching folder: \$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 - ${VIRTUAL_ENV}/bin/python \${INSTALL_PATH}/ingest_processor.py "\$filepath" + \${INSTALL_PATH}/venv/bin/python \${INSTALL_PATH}/scripts/ingest_processor.py "\$filepath" done EOF From 98b4abb2d6eb401469f144c84200b123010cace0 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 15:31:07 -0400 Subject: [PATCH 09/12] Autocaliweb: venv var gets unset after running deactivate --- install/autocaliweb-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 1ece6b6b..7b51f770 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -144,7 +144,7 @@ cat <"$SCRIPTS_DIR"/auto_zipper_wrapper.sh #!/bin/bash # Source virtual environment -source ${VIRTUAL_ENV}/bin/activate +source ${INSTALL_DIR}/venv/bin/activate WAKEUP="23:59" @@ -180,7 +180,7 @@ cat <"$SCRIPTS_DIR"/metadata_change_detector_wrapper.sh # metadata_change_detector_wrapper.sh - Wrapper for periodic metadata enforcement # Source virtual environment -source ${VIRTUAL_ENV}/bin/activate +source ${INSTALL_DIR}/venv/bin/activate # Configuration CHECK_INTERVAL=300 # Check every 5 minutes (300 seconds) From 8bd7d7cf7aae30d5b168b5aee54dd259cfa2a22f Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 15:36:39 -0400 Subject: [PATCH 10/12] Autocaliweb: missing $ --- install/autocaliweb-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 7b51f770..e09c06ca 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -88,7 +88,7 @@ cat <./dirs.json "tmp_conversion_dir": "$CONFIG_DIR/.acw_conversion_tmp" } EOF -useradd -s /usr/sbin/nologin -d "$CONFIG_DIR" -M "SERVICE_USER" +useradd -s /usr/sbin/nologin -d "$CONFIG_DIR" -M "$SERVICE_USER" ln -sf "$CONFIG_DIR"/.config/calibre/plugins "$CONFIG_DIR"/calibre_plugins msg_ok "Configured Autocaliweb" From 04214bf968bdf9249b3ec0ba5f4c2c71fc239859 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 18:01:05 -0400 Subject: [PATCH 11/12] Autocaliweb: add env, create version constraint for pyopenssl, use lock file for deps --- install/autocaliweb-install.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index e09c06ca..50b4a5b4 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -79,7 +79,9 @@ mkdir -p {"$CALIBRE_LIB_DIR","$INGEST_DIR"} cd "$INSTALL_DIR" $STD uv venv "$VIRTUAL_ENV" $STD source "$VIRTUAL_ENV"/bin/activate -$STD uv pip install -r pyproject.toml --all-extras +echo "pyopenssl>=24.2.1" >./constraint.txt +$STD uv pip compile requirements.txt optional-requirements.txt -c constraint.txt -o combined-requirements.lock +$STD uv pip sync combined-requirements.lock $STD deactivate cat <./dirs.json { @@ -90,6 +92,13 @@ cat <./dirs.json EOF useradd -s /usr/sbin/nologin -d "$CONFIG_DIR" -M "$SERVICE_USER" ln -sf "$CONFIG_DIR"/.config/calibre/plugins "$CONFIG_DIR"/calibre_plugins +cat <"$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" @@ -240,6 +249,7 @@ 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 @@ -251,7 +261,7 @@ StandardError=journal WantedBy=multi-user.target EOF -cat <"$SYS_PATH"/acw-ingestor.service +cat <"$SYS_PATH"/acw-ingest-service.service [Unit] Description=Autocaliweb Ingest Processor Service After=autocaliweb.service From 9710331bc1a84d5865d9be8578af16ce58259ab1 Mon Sep 17 00:00:00 2001 From: vhsdream Date: Tue, 26 Aug 2025 18:06:32 -0400 Subject: [PATCH 12/12] Autocaliweb: quiesce zip output; fix service file enable --- install/autocaliweb-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install/autocaliweb-install.sh b/install/autocaliweb-install.sh index 50b4a5b4..e282f782 100644 --- a/install/autocaliweb-install.sh +++ b/install/autocaliweb-install.sh @@ -107,7 +107,7 @@ PLUGIN_DIGEST="$(find acwsync.koplugin -type f -name "*.lua" -o -name "*.json" | 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 -zip -r koplugin.zip acwsync.koplugin/ +$STD zip -r koplugin.zip acwsync.koplugin/ cp -r koplugin.zip "$INSTALL_DIR"/cps/static msg_ok "Created ACWSync Plugin" @@ -320,7 +320,7 @@ Environment=HOME=${CONFIG_DIR} WantedBy=multi-user.target EOF -systemctl -q enable --now autocaliweb acw-ingestor acw-auto-zipper metadata-change-detector +systemctl -q enable --now autocaliweb acw-ingest-service acw-auto-zipper metadata-change-detector msg_ok "Created scripts and service files" motd_ssh