|
| 1 | +#!/usr/bin/env bash |
| 2 | +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: vhsdream |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://github.com/gelbphoenix/autocaliweb |
| 7 | + |
| 8 | +APP="Autocaliweb" |
| 9 | +var_tags="${var_tags:-ebooks}" |
| 10 | +var_cpu="${var_cpu:-2}" |
| 11 | +var_ram="${var_ram:-2048}" |
| 12 | +var_disk="${var_disk:-6}" |
| 13 | +var_os="${var_os:-debian}" |
| 14 | +var_version="${var_version:-12}" |
| 15 | +var_unprivileged="${var_unprivileged:-1}" |
| 16 | + |
| 17 | +header_info "$APP" |
| 18 | +variables |
| 19 | +color |
| 20 | +catch_errors |
| 21 | + |
| 22 | +function update_script() { |
| 23 | + header_info |
| 24 | + check_container_storage |
| 25 | + check_container_resources |
| 26 | + if [[ ! -d /opt/autocaliweb ]]; then |
| 27 | + msg_error "No ${APP} Installation Found!" |
| 28 | + exit |
| 29 | + fi |
| 30 | + |
| 31 | + setup_uv |
| 32 | + |
| 33 | + RELEASE=$(curl -fsSL https://api.github.com/repos/gelbphoenix/autocaliweb/releases/latest | jq '.tag_name' | sed 's/^"v//;s/"$//') |
| 34 | + if check_for_gh_release "autocaliweb" "gelbphoenix/autocaliweb"; then |
| 35 | + msg_info "Stopping Services" |
| 36 | + systemctl stop autocaliweb metadata-change-detector acw-ingest-service acw-auto-zipper |
| 37 | + msg_ok "Stopped Services" |
| 38 | + |
| 39 | + INSTALL_DIR="/opt/autocaliweb" |
| 40 | + export VIRTUAL_ENV="${INSTALL_DIR}/venv" |
| 41 | + $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} |
| 42 | + fetch_and_deploy_gh_release "autocaliweb" "gelbphoenix/autocaliweb" "tarball" "latest" "/opt/autocaliweb" |
| 43 | + msg_info "Updating ${APP}" |
| 44 | + cd "$INSTALL_DIR" |
| 45 | + if [[ ! -d "$VIRTUAL_ENV" ]]; then |
| 46 | + $STD uv venv "$VIRTUAL_ENV" |
| 47 | + fi |
| 48 | + $STD uv sync --all-extras --active |
| 49 | + cd "$INSTALL_DIR"/koreader/plugins |
| 50 | + PLUGIN_DIGEST="$(find acwsync.koplugin -type f -name "*.lua" -o -name "*.json" | sort | xargs sha256sum | sha256sum | cut -d' ' -f1)" |
| 51 | + echo "Plugin files digest: $PLUGIN_DIGEST" >acwsync.koplugin/${PLUGIN_DIGEST}.digest |
| 52 | + echo "Build date: $(date)" >>acwsync.koplugin/${PLUGIN_DIGEST}.digest |
| 53 | + echo "Files included:" >>acwsync.koplugin/${PLUGIN_DIGEST}.digest |
| 54 | + $STD zip -r koplugin.zip acwsync.koplugin/ |
| 55 | + cp -r koplugin.zip "$INSTALL_DIR"/cps/static |
| 56 | + mkdir -p "$INSTALL_DIR"/metadata_temp |
| 57 | + $STD tar -xf ~/autocaliweb_bkp.tar --directory / |
| 58 | + KEPUB_VERSION="$(/usr/bin/kepubify --version)" |
| 59 | + CALIBRE_RELEASE="$(curl -s https://api.github.com/repos/kovidgoyal/calibre/releases/latest | grep -o '"tag_name": "[^"]*' | cut -d'"' -f4)" |
| 60 | + echo "${KEPUB_VERSION#v}" >"$INSTALL_DIR"/KEPUBIFY_RELEASE |
| 61 | + echo "${CALIBRE_RELEASE#v}" >/"$INSTALL_DIR"/CALIBRE_RELEASE |
| 62 | + sed 's/^/v/' ~/.autocaliweb >"$INSTALL_DIR"/ACW_RELEASE |
| 63 | + chown -R acw:acw "$INSTALL_DIR" |
| 64 | + rm ~/autocaliweb_bkp.tar |
| 65 | + msg_ok "Updated $APP" |
| 66 | + |
| 67 | + msg_info "Starting Services" |
| 68 | + systemctl start autocaliweb metadata-change-detector acw-ingest-service acw-auto-zipper |
| 69 | + msg_ok "Started Services" |
| 70 | + |
| 71 | + msg_ok "Updated Successfully" |
| 72 | + fi |
| 73 | + exit |
| 74 | +} |
| 75 | + |
| 76 | +start |
| 77 | +build_container |
| 78 | +description |
| 79 | + |
| 80 | +msg_ok "Completed Successfully!\n" |
| 81 | +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
| 82 | +echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
| 83 | +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:8083${CL}" |
0 commit comments