Skip to content

Commit eba06a2

Browse files
'Add new script' (#5977)
1 parent ac1d7f8 commit eba06a2

4 files changed

Lines changed: 364 additions & 0 deletions

File tree

ct/bar-assistant.sh

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
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: bvdberg01 | CanbiZ
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/karlomikus/bar-assistant
7+
# Source: https://github.com/karlomikus/vue-salt-rim
8+
# Source: https://www.meilisearch.com/
9+
10+
APP="Bar-Assistant"
11+
var_tags="${var_tags:-cocktails;drinks}"
12+
var_cpu="${var_cpu:-2}"
13+
var_ram="${var_ram:-2048}"
14+
var_disk="${var_disk:-4}"
15+
var_os="${var_os:-debian}"
16+
var_version="${var_version:-12}"
17+
var_unprivileged="${var_unprivileged:-1}"
18+
19+
header_info "$APP"
20+
variables
21+
color
22+
catch_errors
23+
24+
function update_script() {
25+
header_info
26+
check_container_storage
27+
check_container_resources
28+
if [[ ! -d /opt/bar-assistant ]]; then
29+
msg_error "No ${APP} Installation Found!"
30+
exit
31+
fi
32+
RELEASE_MEILISEARCH=$(curl -fsSL https://api.github.com/repos/meilisearch/meilisearch/releases/latest | jq -r '.tag_name | sub("^v"; "")')
33+
RELEASE_BARASSISTANT=$(curl -fsSL https://api.github.com/repos/karlomikus/bar-assistant/releases/latest | jq -r '.tag_name | sub("^v"; "")')
34+
RELEASE_SALTRIM=$(curl -fsSL https://api.github.com/repos/karlomikus/vue-salt-rim/releases/latest | jq -r '.tag_name | sub("^v"; "")')
35+
36+
if [[ "${RELEASE_BARASSISTANT}" != "$(cat ~/.bar-assistant 2>/dev/null)" ]] || [[ ! -f ~/.bar-assistant ]]; then
37+
msg_info "Stopping nginx"
38+
systemctl stop nginx
39+
msg_ok "Stopped nginx"
40+
41+
msg_info "Backing up Bar Assistant"
42+
mv /opt/bar-assistant /opt/bar-assistant-backup
43+
msg_ok "Backed up Bar Assistant"
44+
45+
fetch_and_deploy_gh_release "bar-assistant" "karlomikus/bar-assistant" "tarball" "latest" "/opt/bar-assistant"
46+
47+
msg_info "Updating ${APP} to ${RELEASE_BARASSISTANT}"
48+
cp -r /opt/bar-assistant-backup/.env /opt/bar-assistant/.env
49+
cp -r /opt/bar-assistant-backup/storage/bar-assistant /opt/bar-assistant/storage/bar-assistant
50+
cd /opt/bar-assistant
51+
$STD composer install --no-interaction
52+
$STD php artisan migrate --force
53+
$STD php artisan storage:link
54+
$STD php artisan bar:setup-meilisearch
55+
$STD php artisan scout:sync-index-settings
56+
$STD php artisan config:cache
57+
$STD php artisan route:cache
58+
$STD php artisan event:cache
59+
chown -R www-data:www-data /opt/bar-assistant
60+
msg_ok "Updated $APP to ${RELEASE_BARASSISTANT}"
61+
62+
msg_info "Starting nginx"
63+
systemctl start nginx
64+
msg_ok "Started nginx"
65+
66+
msg_info "Cleaning up"
67+
rm -rf /opt/bar-assistant-backup
68+
msg_ok "Cleaned"
69+
else
70+
msg_ok "No update required. ${APP} is already at ${RELEASE_BARASSISTANT}"
71+
fi
72+
73+
if [[ "${RELEASE_SALTRIM}" != "$(cat ~/.vue-salt-rim 2>/dev/null)" ]] || [[ ! -f ~/.vue-salt-rim ]]; then
74+
msg_info "Backing up Vue Salt Rim"
75+
mv /opt/vue-salt-rim /opt/vue-salt-rim-backup
76+
msg_ok "Backed up Vue Salt Rim"
77+
78+
msg_info "Stopping nginx"
79+
systemctl stop nginx
80+
msg_ok "Stopped nginx"
81+
82+
fetch_and_deploy_gh_release "vue-salt-rim" "karlomikus/vue-salt-rim" "tarball" "latest" "/opt/vue-salt-rim"
83+
84+
msg_info "Updating Salt Rim to ${RELEASE_SALTRIM}"
85+
cp /opt/vue-salt-rim-backup/public/config.js /opt/vue-salt-rim/public/config.js
86+
cd /opt/vue-salt-rim
87+
$STD npm install
88+
$STD npm run build
89+
msg_ok "Updated $APP to ${RELEASE_SALTRIM}"
90+
91+
msg_info "Starting nginx"
92+
systemctl start nginx
93+
msg_ok "Started nginx"
94+
95+
msg_info "Cleaning up"
96+
rm -rf /opt/vue-salt-rim-backup
97+
msg_ok "Cleaned"
98+
msg_ok "Updated"
99+
else
100+
msg_ok "No update required. Salt Rim is already at ${RELEASE_SALTRIM}"
101+
fi
102+
103+
if [[ "${RELEASE_MEILISEARCH}" != "$(cat ~/.meilisearch 2>/dev/null)" ]] || [[ ! -f ~/.meilisearch ]]; then
104+
msg_info "Stopping Meilisearch"
105+
systemctl stop meilisearch
106+
msg_ok "Stopped Meilisearch"
107+
108+
fetch_and_deploy_gh_release "meilisearch" "meilisearch/meilisearch" "binary"
109+
110+
msg_info "Starting Meilisearch"
111+
systemctl start meilisearch
112+
msg_ok "Started Meilisearch"
113+
114+
msg_ok "Updated Meilisearch"
115+
else
116+
msg_ok "No update required. Meilisearch is already at ${RELEASE_MEILISEARCH}"
117+
fi
118+
exit
119+
}
120+
121+
start
122+
build_container
123+
description
124+
125+
msg_ok "Completed Successfully!\n"
126+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
127+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
128+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

ct/headers/bar-assistant

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/bar-assistant.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/bar-assistant-install.sh

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: bvdberg01 | CanbiZ
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/karlomikus/bar-assistant
7+
# Source: https://github.com/karlomikus/vue-salt-rim
8+
# Source: https://www.meilisearch.com/
9+
10+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
11+
color
12+
verb_ip6
13+
catch_errors
14+
setting_up_container
15+
network_check
16+
update_os
17+
18+
msg_info "Installing Dependencies"
19+
$STD apt-get install -y \
20+
redis-server \
21+
nginx \
22+
lsb-release \
23+
libvips
24+
#php-{ffi,opcache,redis,zip,pdo-sqlite,bcmath,pdo,curl,dom,fpm}
25+
msg_ok "Installed Dependencies"
26+
27+
PHP_VERSION="8.3" PHP_FPM=YES PHP_MODULE="ffi,opcache,redis,zip,pdo-sqlite,bcmath,pdo,curl,dom,fpm" setup_php
28+
setup_composer
29+
NODE_VERSION="22" setup_nodejs
30+
fetch_and_deploy_gh_release "meilisearch" "meilisearch/meilisearch" "binary"
31+
fetch_and_deploy_gh_release "bar-assistant" "karlomikus/bar-assistant" "tarball" "latest" "/opt/bar-assistant"
32+
fetch_and_deploy_gh_release "vue-salt-rim" "karlomikus/vue-salt-rim" "tarball" "latest" "/opt/vue-salt-rim"
33+
34+
msg_info "Configuring PHP"
35+
PHPVER=$(php -r 'echo PHP_MAJOR_VERSION . "." . PHP_MINOR_VERSION . "\n";')
36+
sed -i.bak -E 's/^\s*;?\s*ffi\.enable\s*=.*/ffi.enable=true/' /etc/php/${PHPVER}/fpm/php.ini
37+
$STD systemctl reload php${PHPVER}-fpm
38+
msg_info "configured PHP"
39+
40+
msg_info "Configure MeiliSearch"
41+
curl -fsSL https://raw.githubusercontent.com/meilisearch/meilisearch/latest/config.toml -o /etc/meilisearch.toml
42+
MASTER_KEY=$(openssl rand -base64 12)
43+
sed -i \
44+
-e 's|^env =.*|env = "production"|' \
45+
-e "s|^# master_key =.*|master_key = \"$MASTER_KEY\"|" \
46+
-e 's|^db_path =.*|db_path = "/var/lib/meilisearch/data"|' \
47+
-e 's|^dump_dir =.*|dump_dir = "/var/lib/meilisearch/dumps"|' \
48+
-e 's|^snapshot_dir =.*|snapshot_dir = "/var/lib/meilisearch/snapshots"|' \
49+
-e 's|^# no_analytics = true|no_analytics = true|' \
50+
-e 's|^http_addr =.*|http_addr = "127.0.0.1:7700"|' \
51+
/etc/meilisearch.toml
52+
msg_ok "Configured MeiliSearch"
53+
54+
msg_info "Creating MeiliSearch service"
55+
cat <<EOF >/etc/systemd/system/meilisearch.service
56+
[Unit]
57+
Description=Meilisearch
58+
After=network.target
59+
60+
[Service]
61+
ExecStart=/usr/bin/meilisearch --config-file-path /etc/meilisearch.toml
62+
Restart=always
63+
64+
[Install]
65+
WantedBy=multi-user.target
66+
EOF
67+
systemctl enable -q --now meilisearch
68+
sleep 5
69+
msg_ok "Created Service MeiliSearch"
70+
71+
msg_info "Installing Bar Assistant"
72+
cd /opt/bar-assistant
73+
cp /opt/bar-assistant/.env.dist /opt/bar-assistant/.env
74+
MeiliSearch_API_KEY=$(curl -s -X GET 'http://127.0.0.1:7700/keys' -H "Authorization: Bearer $MASTER_KEY" | grep -o '"key":"[^"]*"' | head -n 1 | sed 's/"key":"//;s/"//')
75+
MeiliSearch_API_KEY_UID=$(curl -s -X GET 'http://127.0.0.1:7700/keys' -H "Authorization: Bearer $MASTER_KEY" | grep -o '"uid":"[^"]*"' | head -n 1 | sed 's/"uid":"//;s/"//')
76+
LOCAL_IP=$(hostname -I | awk '{print $1}')
77+
sed -i -e "s|^APP_URL=|APP_URL=http://${LOCAL_IP}/bar/|" \
78+
-e "s|^MEILISEARCH_HOST=|MEILISEARCH_HOST=http://127.0.0.1:7700|" \
79+
-e "s|^MEILISEARCH_KEY=|MEILISEARCH_KEY=${MASTER_KEY}|" \
80+
-e "s|^MEILISEARCH_API_KEY=|MEILISEARCH_API_KEY=${MeiliSearch_API_KEY}|" \
81+
-e "s|^MEILISEARCH_API_KEY_UID=|MEILISEARCH_API_KEY_UID=${MeiliSearch_API_KEY_UID}|" \
82+
/opt/bar-assistant/.env
83+
$STD composer install --no-interaction
84+
$STD php artisan key:generate
85+
touch storage/bar-assistant/database.ba3.sqlite
86+
$STD php artisan migrate --force
87+
$STD php artisan storage:link
88+
$STD php artisan bar:setup-meilisearch
89+
$STD php artisan scout:sync-index-settings
90+
$STD php artisan config:cache
91+
$STD php artisan route:cache
92+
$STD php artisan event:cache
93+
mkdir /opt/bar-assistant/storage/bar-assistant/uploads/temp
94+
chown -R www-data:www-data /opt/bar-assistant
95+
msg_ok "Installed Bar Assistant"
96+
97+
msg_info "Installing Salt Rim"
98+
cd /opt/vue-salt-rim
99+
cat <<EOF >/opt/vue-salt-rim/public/config.js
100+
window.srConfig = {}
101+
window.srConfig.API_URL = "http://${LOCAL_IP}/bar"
102+
window.srConfig.MEILISEARCH_URL = "http://${LOCAL_IP}/search"
103+
EOF
104+
$STD npm install
105+
$STD npm run build
106+
msg_ok "Installed Salt Rim"
107+
108+
msg_info "Creating Service"
109+
cat <<EOF >/etc/nginx/sites-available/barassistant.conf
110+
server {
111+
listen 80 default_server;
112+
listen [::]:80 default_server;
113+
server_name _;
114+
115+
location = /favicon.ico { access_log off; log_not_found off; }
116+
location = /robots.txt { access_log off; log_not_found off; }
117+
118+
client_max_body_size 100M;
119+
120+
location /bar/ {
121+
proxy_pass http://127.0.0.1:8080/;
122+
proxy_set_header Host \$host;
123+
proxy_set_header X-Real-IP \$remote_addr;
124+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
125+
proxy_set_header X-Forwarded-Proto \$scheme;
126+
}
127+
128+
location /search/ {
129+
proxy_pass http://127.0.0.1:7700/;
130+
}
131+
132+
location / {
133+
proxy_pass http://127.0.0.1:8081/;
134+
proxy_set_header Host \$host;
135+
proxy_set_header X-Real-IP \$remote_addr;
136+
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
137+
proxy_set_header X-Forwarded-Proto \$scheme;
138+
}
139+
}
140+
141+
server {
142+
listen 127.0.0.1:8080;
143+
server_name example.com;
144+
root /opt/bar-assistant/public;
145+
146+
add_header X-Frame-Options "SAMEORIGIN";
147+
add_header X-Content-Type-Options "nosniff";
148+
149+
index index.php;
150+
charset utf-8;
151+
152+
location / {
153+
try_files \$uri \$uri/ /index.php?\$query_string;
154+
}
155+
156+
location = /favicon.ico { access_log off; log_not_found off; }
157+
location = /robots.txt { access_log off; log_not_found off; }
158+
159+
error_page 404 /index.php;
160+
161+
location ~ ^/index\.php(/|$) {
162+
fastcgi_pass unix:/var/run/php/php$PHPVER-fpm.sock;
163+
fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name;
164+
include fastcgi_params;
165+
fastcgi_hide_header X-Powered-By;
166+
}
167+
168+
location ~ /\.(?!well-known).* {
169+
deny all;
170+
}
171+
}
172+
173+
server {
174+
listen 127.0.0.1:8081;
175+
server_name _;
176+
root /opt/vue-salt-rim/dist;
177+
178+
location / {
179+
try_files \$uri \$uri/ /index.html;
180+
}
181+
}
182+
EOF
183+
184+
ln -s /etc/nginx/sites-available/barassistant.conf /etc/nginx/sites-enabled/
185+
rm -f /etc/nginx/sites-enabled/default
186+
$STD systemctl reload nginx
187+
msg_ok "Created Service"
188+
189+
motd_ssh
190+
customize
191+
192+
msg_info "Cleaning up"
193+
$STD apt-get -y autoremove
194+
$STD apt-get -y autoclean
195+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)