Skip to content

Commit 520bae0

Browse files
BookLore (#5524)
1 parent 7057fba commit 520bae0

File tree

4 files changed

+229
-0
lines changed

4 files changed

+229
-0
lines changed

ct/booklore.sh

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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: MickLesk (CanbiZ)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/adityachandelgit/BookLore
7+
8+
APP="BookLore"
9+
var_tags="${var_tags:-books;library}"
10+
var_cpu="${var_cpu:-3}"
11+
var_ram="${var_ram:-2048}"
12+
var_disk="${var_disk:-7}"
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+
27+
if [[ ! -d /opt/booklore ]]; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
32+
RELEASE=$(curl -fsSL https://api.github.com/repos/adityachandelgit/BookLore/releases/latest | yq '.tag_name' | sed 's/^v//')
33+
if [[ "${RELEASE}" != "$(cat ~/.booklore 2>/dev/null)" ]] || [[ ! -f ~/.booklore ]]; then
34+
msg_info "Stopping $APP"
35+
systemctl stop booklore
36+
msg_ok "Stopped $APP"
37+
38+
fetch_and_deploy_gh_release "booklore" "adityachandelgit/BookLore"
39+
40+
msg_info "Building Frontend"
41+
cd /opt/booklore/booklore-ui
42+
$STD npm install --force
43+
$STD npm run build --configuration=production
44+
msg_ok "Built Frontend"
45+
46+
msg_info "Building Backend"
47+
cd /opt/booklore/booklore-api
48+
APP_VERSION=$(curl -fsSL https://api.github.com/repos/adityachandelgit/BookLore/releases/latest | yq '.tag_name' | sed 's/^v//')
49+
yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml
50+
$STD ./gradlew clean build --no-daemon
51+
mkdir -p /opt/booklore/dist
52+
JAR_PATH=$(find /opt/booklore/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1)
53+
if [[ -z "$JAR_PATH" ]]; then
54+
msg_error "Backend JAR not found"
55+
exit 1
56+
fi
57+
cp "$JAR_PATH" /opt/booklore/dist/app.jar
58+
msg_ok "Built Backend"
59+
60+
msg_info "Starting $APP"
61+
systemctl start booklore
62+
systemctl reload nginx
63+
msg_ok "Started $APP"
64+
65+
msg_ok "Update Successful"
66+
else
67+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
68+
fi
69+
exit
70+
}
71+
72+
start
73+
build_container
74+
description
75+
76+
msg_ok "Completed Successfully!\n"
77+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
78+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
79+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:6060${CL}"

ct/headers/booklore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
____ __ __
2+
/ __ )____ ____ / /__/ / ____ ________
3+
/ __ / __ \/ __ \/ //_/ / / __ \/ ___/ _ \
4+
/ /_/ / /_/ / /_/ / ,< / /___/ /_/ / / / __/
5+
/_____/\____/\____/_/|_/_____/\____/_/ \___/
6+

frontend/public/json/booklore.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

install/booklore-install.sh

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: MickLesk (CanbiZ)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/adityachandelgit/BookLore
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing Dependencies"
17+
$STD apt-get install -y nginx
18+
msg_ok "Installed Dependencies"
19+
20+
fetch_and_deploy_gh_release "booklore" "adityachandelgit/BookLore"
21+
JAVA_VERSION="21" setup_java
22+
NODE_VERSION="22" setup_nodejs
23+
setup_mariadb
24+
setup_yq
25+
26+
msg_info "Setting up database"
27+
DB_NAME=booklore_db
28+
DB_USER=booklore_user
29+
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
30+
$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;"
31+
$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';"
32+
$STD mariadb -u root -e "GRANT ALL PRIVILEGES ON $DB_NAME.* TO '$DB_USER'@'localhost';"
33+
$STD mariadb -u root -e "GRANT SELECT ON \`mysql\`.\`time_zone_name\` TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;"
34+
{
35+
echo "BookLore Database Credentials"
36+
echo "Database: $DB_NAME"
37+
echo "Username: $DB_USER"
38+
echo "Password: $DB_PASS"
39+
} >>~/booklore.creds
40+
msg_ok "Set up database"
41+
42+
msg_info "Building Frontend"
43+
cd /opt/booklore/booklore-ui
44+
$STD npm install --force
45+
$STD npm run build --configuration=production
46+
msg_ok "Built Frontend"
47+
48+
msg_info "Creating Environment"
49+
mkdir -p /opt/booklore_storage{/data,/books}
50+
cat <<EOF >/opt/booklore_storage/.env
51+
DATABASE_URL=jdbc:mariadb://localhost:3306/$DB_NAME
52+
DATABASE_USERNAME=$DB_USER
53+
DATABASE_PASSWORD=$DB_PASS
54+
55+
BOOKLORE_DATA_PATH=/opt/booklore_storage/data
56+
BOOKLORE_BOOKS_PATH=/opt/booklore_storage/books
57+
EOF
58+
msg_ok "Created Environment"
59+
60+
msg_info "Building Backend"
61+
cd /opt/booklore/booklore-api
62+
APP_VERSION=$(curl -fsSL https://api.github.com/repos/adityachandelgit/BookLore/releases/latest | yq '.tag_name' | sed 's/^v//')
63+
yq eval ".app.version = \"${APP_VERSION}\"" -i src/main/resources/application.yaml
64+
$STD ./gradlew clean build --no-daemon
65+
mkdir -p /opt/booklore/dist
66+
JAR_PATH=$(find /opt/booklore/booklore-api/build/libs -maxdepth 1 -type f -name "booklore-api-*.jar" ! -name "*plain*" | head -n1)
67+
if [[ -z "$JAR_PATH" ]]; then
68+
msg_error "Backend JAR not found"
69+
exit 1
70+
fi
71+
cp "$JAR_PATH" /opt/booklore/dist/app.jar
72+
msg_ok "Built Backend"
73+
74+
msg_info "Configure Nginx"
75+
rm -rf /usr/share/nginx/html
76+
ln -s /opt/booklore/booklore-ui/dist/booklore/browser /usr/share/nginx/html
77+
cp /opt/booklore/nginx.conf /etc/nginx/nginx.conf
78+
systemctl restart nginx
79+
msg_ok "Configured Nginx"
80+
81+
msg_info "Creating Systemd Service"
82+
cat <<EOF >/etc/systemd/system/booklore.service
83+
[Unit]
84+
Description=BookLore Java Service
85+
After=network.target
86+
87+
[Service]
88+
User=root
89+
WorkingDirectory=/opt/booklore/dist
90+
ExecStart=/usr/bin/java -jar /opt/booklore/dist/app.jar
91+
EnvironmentFile=/opt/booklore_storage/.env
92+
SuccessExitStatus=143
93+
TimeoutStopSec=10
94+
Restart=on-failure
95+
RestartSec=5
96+
97+
[Install]
98+
WantedBy=multi-user.target
99+
EOF
100+
systemctl enable -q --now booklore
101+
msg_ok "Created BookLore Service"
102+
103+
motd_ssh
104+
customize
105+
106+
msg_info "Cleaning up"
107+
$STD apt-get -y autoremove
108+
$STD apt-get -y autoclean
109+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)