Guest User

Updating LXC Booklore to Grimmory

a guest
Mar 22nd, 2026
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.73 KB | Software | 0 0
  1. #!/usr/bin/env bash
  2. source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
  3. # Copyright (c) 2021-2026 community-scripts ORG
  4. # Author: MickLesk (CanbiZ)
  5. # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
  6. # Source: https://github.com/grimmory-tools/grimmory
  7. # Modified by jferdom. Lines 79-80 commented by suggestion of Erebus.
  8.  
  9. APP="Grimmory"
  10. var_tags="${var_tags:-books;library}"
  11. var_cpu="${var_cpu:-3}"
  12. var_ram="${var_ram:-3072}"
  13. var_disk="${var_disk:-7}"
  14. var_os="${var_os:-debian}"
  15. var_version="${var_version:-13}"
  16. var_unprivileged="${var_unprivileged:-1}"
  17.  
  18. header_info "$APP"
  19. variables
  20. color
  21. catch_errors
  22.  
  23. function update_script() {
  24.   header_info
  25.   check_container_storage
  26.   check_container_resources
  27.  
  28.   if [[ ! -d /opt/booklore ]]; then
  29.     if [[ ! -d /opt/grimmory ]]; then
  30.         msg_error "No BookLore or ${APP} Installation Found!"
  31.         exit
  32.     fi
  33.   fi
  34.  
  35.   if check_for_gh_release "grimmory" "grimmory-tools/grimmory"; then
  36.     JAVA_VERSION="25" setup_java
  37.     NODE_VERSION="22" setup_nodejs
  38.     setup_mariadb
  39.     setup_yq
  40.     ensure_dependencies ffmpeg
  41.  
  42.     msg_info "Stopping Service"
  43.     if [[ -d /opt/grimmory ]]; then
  44.         systemctl stop grimmory
  45.     else
  46.         systemctl stop booklore
  47.     fi
  48.     msg_ok "Stopped Service"
  49.  
  50.     if grep -qE "^BOOKLORE_(DATA_PATH|BOOKDROP_PATH|BOOKS_PATH|PORT)=" /opt/booklore_storage/.env 2>/dev/null; then
  51.       msg_info "Migrating old environment variables"
  52.       sed -i 's/^BOOKLORE_DATA_PATH=/APP_PATH_CONFIG=/g' /opt/booklore_storage/.env
  53.       sed -i 's/^BOOKLORE_BOOKDROP_PATH=/APP_BOOKDROP_FOLDER=/g' /opt/booklore_storage/.env
  54.       sed -i '/^BOOKLORE_BOOKS_PATH=/d' /opt/booklore_storage/.env
  55.       sed -i '/^BOOKLORE_PORT=/d' /opt/booklore_storage/.env
  56.       msg_ok "Migrated old environment variables"
  57.     fi
  58.  
  59.     msg_info "Backing up old installation"
  60.     if [[ -d /opt/grimmory ]]; then
  61.         mv /opt/grimmory /opt/grimmory_bak
  62.     else
  63.         mv /opt/booklore /opt/booklore_bak
  64.     fi
  65.     msg_ok "Backed up old installation"
  66.    
  67.     if [[ -d /opt/grimmory ]]; then
  68.         msg_info "Migrating booklore to grimmory"
  69.     fi
  70.  
  71.     fetch_and_deploy_gh_release "grimmory" "grimmory-tools/grimmory" "tarball"
  72.  
  73.     msg_info "Building Frontend"
  74.     cd /opt/grimmory/booklore-ui
  75.     $STD npm install --force
  76.     $STD npm run build --configuration=production
  77.     msg_ok "Built Frontend"
  78.  
  79.     msg_info "Embedding Frontend into Backend"
  80.  #   mkdir -p /opt/grimmory/booklore-api/src/main/resources/static
  81.  #   cp -r /opt/grimmory/booklore-ui/dist/grimmory/browser/* /opt/grimmory/booklore-api/src/main/resources/static/
  82.     msg_ok "Embedded Frontend into Backend"
  83.  
  84.     msg_info "Building Backend"
  85.     cd /opt/grimmory/booklore-api
  86.     APP_VERSION=$(get_latest_github_release "grimmory-tools/grimmory")
  87.     msg_info "${APP_VERSION}"
  88.     yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml
  89.     $STD ./gradlew clean build -x test --no-daemon
  90.     mkdir -p /opt/grimmory/dist
  91.     JAR_PATH=$(find /opt/grimmory/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1)
  92.     if [[ -z "$JAR_PATH" ]]; then
  93.       msg_error "Backend JAR not found"
  94.       exit
  95.     fi
  96.     cp "$JAR_PATH" /opt/grimmory/dist/app.jar
  97.     msg_ok "Built Backend"
  98.  
  99.     if systemctl is-active --quiet nginx 2>/dev/null; then
  100.       msg_info "Removing Nginx (no longer needed)"
  101.       systemctl disable --now nginx
  102.       $STD apt-get purge -y nginx nginx-common
  103.       msg_ok "Removed Nginx"
  104.     fi
  105.  
  106.     if ! grep -q "^SERVER_PORT=" /opt/booklore_storage/.env 2>/dev/null; then
  107.       echo "SERVER_PORT=6060" >>/opt/booklore_storage/.env
  108.     fi
  109.    
  110.     if test -f /etc/systemd/system/booklore.service; then mv /etc/systemd/system/booklore.service /etc/systemd/system/grimmory.service; fi
  111.  
  112.     sed -i 's|WorkingDirectory=.*|WorkingDirectory=/opt/grimmory/dist|' /etc/systemd/system/grimmory.service
  113.     sed -i 's|ExecStart=.*|ExecStart=/usr/bin/java -XX:+UseG1GC -XX:+UseStringDeduplication -XX:+UseCompactObjectHeaders -XX:MaxRAMPercentage=75.0 -XX:+ExitOnOutOfMemoryError -jar /opt/grimmory/dist/app.jar|' /etc/systemd/system/grimmory.service
  114.    
  115.     systemctl daemon-reload
  116.  
  117.     msg_info "Starting Service"
  118.     systemctl start grimmory
  119.     if [[ -d /opt/grimmory_bak ]]; then
  120.         rm -rf /opt/grimmory_bak
  121.     fi
  122.    
  123.     if [[ -d /opt/booklore_bak ]]; then
  124.         rm -rf /opt/booklore_bak
  125.     fi
  126.     msg_ok "Started Service"
  127.     msg_ok "Updated successfully!"
  128.   fi
  129.   exit
  130. }
  131.  
  132. start
  133. build_container
  134. description
  135.  
  136. msg_ok "Completed successfully!\n"
  137. echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
  138. echo -e "${INFO}${YW} Access it using the following URL:${CL}"
  139. echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:6060${CL}"
  140.  
Advertisement
Add Comment
Please, Sign In to add comment