From 58a1c01daab5ead1ad283381acf559649efb3d58 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 23 Jun 2025 10:28:02 +0200 Subject: [PATCH] booklore --- ct/booklore.sh | 42 ++++++++++++++++++ install/booklore-install.sh | 86 +++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 ct/booklore.sh create mode 100644 install/booklore-install.sh diff --git a/ct/booklore.sh b/ct/booklore.sh new file mode 100644 index 00000000..8270c925 --- /dev/null +++ b/ct/booklore.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +source <(curl -s https://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE +# Source: https://github.com/adityachandelgit/BookLore + +APP="BookLore" +var_tags="${var_tags:-books;library}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-5}" +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 /var ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_info "Updating $APP LXC" + $STD apt-get update + $STD apt-get -y upgrade + msg_ok "Updated $APP LXC" + exit +} + +start +build_container +description + +msg_ok "Completed Successfully!\n" +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" diff --git a/install/booklore-install.sh b/install/booklore-install.sh new file mode 100644 index 00000000..c6000077 --- /dev/null +++ b/install/booklore-install.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVED/raw/main/LICENSE + +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" "/opt/booklore" +JAVA_VERSION="21" setup_java +NODE_VERSION="22" setup_nodejs + +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="0.0.1-Test" +yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml +$STD ./gradlew clean build --no-daemon +msg_ok "Built Backend" + +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/booklore-api +ExecStart=/usr/bin/java -jar build/libs/booklore-api-${APP_VERSION}.jar +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" + +msg_info "Configuring Nginx" +cat <<'EOF' >/etc/nginx/sites-available/booklore +server { + listen 80 default_server; + root /usr/share/nginx/html; + index index.html; + location /api/ { + proxy_pass http://localhost:8080/; + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto \$scheme; + } + location / { + try_files \$uri \$uri/ /index.html; + } +} +EOF + +ln -sf /etc/nginx/sites-available/booklore /etc/nginx/sites-enabled/default +$STD systemctl restart nginx +msg_ok "Configured Nginx" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"