From 520bae01d653ba66da6562d2b40b00028bdc921a Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 23:11:24 +0200 Subject: [PATCH] BookLore (#5524) --- ct/booklore.sh | 79 +++++++++++++++++++++ ct/headers/booklore | 6 ++ frontend/public/json/booklore.json | 35 +++++++++ install/booklore-install.sh | 109 +++++++++++++++++++++++++++++ 4 files changed, 229 insertions(+) create mode 100644 ct/booklore.sh create mode 100644 ct/headers/booklore create mode 100644 frontend/public/json/booklore.json create mode 100644 install/booklore-install.sh diff --git a/ct/booklore.sh b/ct/booklore.sh new file mode 100644 index 000000000..59dd81c30 --- /dev/null +++ b/ct/booklore.sh @@ -0,0 +1,79 @@ +#!/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: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/adityachandelgit/BookLore + +APP="BookLore" +var_tags="${var_tags:-books;library}" +var_cpu="${var_cpu:-3}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-7}" +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/booklore ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/adityachandelgit/BookLore/releases/latest | yq '.tag_name' | sed 's/^v//') + if [[ "${RELEASE}" != "$(cat ~/.booklore 2>/dev/null)" ]] || [[ ! -f ~/.booklore ]]; then + msg_info "Stopping $APP" + systemctl stop booklore + msg_ok "Stopped $APP" + + fetch_and_deploy_gh_release "booklore" "adityachandelgit/BookLore" + + msg_info "Building Frontend" + cd /opt/booklore/booklore-ui + $STD npm install --force + $STD npm run build --configuration=production + msg_ok "Built Frontend" + + msg_info "Building Backend" + cd /opt/booklore/booklore-api + APP_VERSION=$(curl -fsSL https://api.github.com/repos/adityachandelgit/BookLore/releases/latest | yq '.tag_name' | sed 's/^v//') + yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml + $STD ./gradlew clean build --no-daemon + mkdir -p /opt/booklore/dist + JAR_PATH=$(find /opt/booklore/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1) + if [[ -z "$JAR_PATH" ]]; then + msg_error "Backend JAR not found" + exit 1 + fi + cp "$JAR_PATH" /opt/booklore/dist/app.jar + msg_ok "Built Backend" + + msg_info "Starting $APP" + systemctl start booklore + systemctl reload nginx + msg_ok "Started $APP" + + 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}:6060${CL}" diff --git a/ct/headers/booklore b/ct/headers/booklore new file mode 100644 index 000000000..267b0346f --- /dev/null +++ b/ct/headers/booklore @@ -0,0 +1,6 @@ + ____ __ __ + / __ )____ ____ / /__/ / ____ ________ + / __ / __ \/ __ \/ //_/ / / __ \/ ___/ _ \ + / /_/ / /_/ / /_/ / ,< / /___/ /_/ / / / __/ +/_____/\____/\____/_/|_/_____/\____/_/ \___/ + diff --git a/frontend/public/json/booklore.json b/frontend/public/json/booklore.json new file mode 100644 index 000000000..38f703f03 --- /dev/null +++ b/frontend/public/json/booklore.json @@ -0,0 +1,35 @@ +{ + "name": "BookLore", + "slug": "booklore", + "categories": [ + 13 + ], + "date_created": "2025-06-23", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 6060, + "documentation": "https://github.com/ejmg/booklore", + "website": "https://booklore.app/", + "logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/booklore.webp", + "config_path": "/opt/booklore_storage/.env", + "description": "BookLore is a self-hosted digital library for managing and reading books, offering a beautiful interface and support for metadata management. Built with a modern tech stack, it provides support for importing, organizing, and reading EPUBs and PDFs, while also managing cover images and book metadata.", + "install_methods": [ + { + "type": "default", + "script": "ct/booklore.sh", + "resources": { + "cpu": 3, + "ram": 2048, + "hdd": 7, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": null, + "password": null + }, + "notes": [] +} diff --git a/install/booklore-install.sh b/install/booklore-install.sh new file mode 100644 index 000000000..aee215d39 --- /dev/null +++ b/install/booklore-install.sh @@ -0,0 +1,109 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/adityachandelgit/BookLore + +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 nginx +msg_ok "Installed Dependencies" + +fetch_and_deploy_gh_release "booklore" "adityachandelgit/BookLore" +JAVA_VERSION="21" setup_java +NODE_VERSION="22" setup_nodejs +setup_mariadb +setup_yq + +msg_info "Setting up database" +DB_NAME=booklore_db +DB_USER=booklore_user +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" +$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" +$STD mariadb -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';" +$STD mariadb -u root -e "GRANT SELECT ON \`mysql\`.\`time_zone_name\` TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +{ + echo "BookLore Database Credentials" + echo "Database: $DB_NAME" + echo "Username: $DB_USER" + echo "Password: $DB_PASS" +} >>~/booklore.creds +msg_ok "Set up database" + +msg_info "Building Frontend" +cd /opt/booklore/booklore-ui +$STD npm install --force +$STD npm run build --configuration=production +msg_ok "Built Frontend" + +msg_info "Creating Environment" +mkdir -p /opt/booklore_storage{/data,/books} +cat </opt/booklore_storage/.env +DATABASE_URL=jdbc:mariadb://localhost:3306/$DB_NAME +DATABASE_USERNAME=$DB_USER +DATABASE_PASSWORD=$DB_PASS + +BOOKLORE_DATA_PATH=/opt/booklore_storage/data +BOOKLORE_BOOKS_PATH=/opt/booklore_storage/books +EOF +msg_ok "Created Environment" + +msg_info "Building Backend" +cd /opt/booklore/booklore-api +APP_VERSION=$(curl -fsSL https://api.github.com/repos/adityachandelgit/BookLore/releases/latest | yq '.tag_name' | sed 's/^v//') +yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml +$STD ./gradlew clean build --no-daemon +mkdir -p /opt/booklore/dist +JAR_PATH=$(find /opt/booklore/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1) +if [[ -z "$JAR_PATH" ]]; then + msg_error "Backend JAR not found" + exit 1 +fi +cp "$JAR_PATH" /opt/booklore/dist/app.jar +msg_ok "Built Backend" + +msg_info "Configure Nginx" +rm -rf /usr/share/nginx/html +ln -s /opt/booklore/booklore-ui/dist/booklore/browser /usr/share/nginx/html +cp /opt/booklore/nginx.conf /etc/nginx/nginx.conf +systemctl restart nginx +msg_ok "Configured Nginx" + +msg_info "Creating Systemd Service" +cat </etc/systemd/system/booklore.service +[Unit] +Description=BookLore Java Service +After=network.target + +[Service] +User=root +WorkingDirectory=/opt/booklore/dist +ExecStart=/usr/bin/java -jar /opt/booklore/dist/app.jar +EnvironmentFile=/opt/booklore_storage/.env +SuccessExitStatus=143 +TimeoutStopSec=10 +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now booklore +msg_ok "Created BookLore Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"