Skip to content

Commit a6517f4

Browse files
authored
Refactor (#5735)
1 parent e492a9b commit a6517f4

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

ct/barcode-buddy.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,35 @@ function update_script() {
2323
header_info
2424
check_container_storage
2525
check_container_resources
26+
2627
if [[ ! -d /opt/barcodebuddy ]]; then
2728
msg_error "No ${APP} Installation Found!"
2829
exit
2930
fi
3031
RELEASE=$(curl -fsSL https://api.github.com/repos/Forceu/barcodebuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31-
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.barcodebuddy 2>/dev/null)" ]] || [[ ! -f ~/.barcodebuddy ]]; then
3233
msg_info "Stopping Service"
3334
systemctl stop apache2
3435
systemctl stop barcodebuddy
3536
msg_ok "Stopped Service"
3637

37-
msg_info "Updating ${APP} to v${RELEASE}"
38-
cd /opt
38+
msg_info "Backing up data"
3939
mv /opt/barcodebuddy/ /opt/barcodebuddy-backup
40-
curl -fsSL "https://github.com/Forceu/barcodebuddy/archive/refs/tags/v${RELEASE}.zip" -o $(basename "https://github.com/Forceu/barcodebuddy/archive/refs/tags/v${RELEASE}.zip")
41-
$STD unzip "v${RELEASE}.zip"
42-
mv "/opt/barcodebuddy-${RELEASE}" /opt/barcodebuddy
40+
msg_ok "Backed up data"
41+
42+
fetch_and_deploy_gh_release "barcodebuddy" "Forceu/barcodebuddy"
43+
44+
msg_info "Configuring ${APP}"
4345
cp -r /opt/barcodebuddy-backup/data/. /opt/barcodebuddy/data
4446
chown -R www-data:www-data /opt/barcodebuddy/data
45-
echo "${RELEASE}" >/opt/${APP}_version.txt
46-
msg_ok "Updated $APP to v${RELEASE}"
47+
msg_ok "Configured ${APP}"
4748

4849
msg_info "Starting Service"
4950
systemctl start apache2
5051
systemctl start barcodebuddy
5152
msg_ok "Started Service"
5253

5354
msg_info "Cleaning up"
54-
rm -r "/opt/v${RELEASE}.zip"
5555
rm -r /opt/barcodebuddy-backup
5656
msg_ok "Cleaned"
5757
msg_ok "Updated Successfully"

install/barcode-buddy-install.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,15 @@ update_os
1616
msg_info "Installing Dependencies"
1717
$STD apt-get install -y \
1818
apache2 \
19-
redis \
20-
php-{curl,date,json,mbstring,redis,sqlite3,sockets} \
21-
libapache2-mod-php
19+
redis
2220
msg_ok "Installed Dependencies"
2321

24-
msg_info "Installing barcodebuddy"
25-
RELEASE=$(curl -fsSL https://api.github.com/repos/Forceu/barcodebuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
26-
cd /opt
27-
curl -fsSL "https://github.com/Forceu/barcodebuddy/archive/refs/tags/v${RELEASE}.zip" -o "v${RELEASE}.zip"
28-
$STD unzip "v${RELEASE}.zip"
29-
mv "/opt/barcodebuddy-${RELEASE}" /opt/barcodebuddy
22+
PHP_VERSION="8.2" PHP_APACHE="YES" PHP_MODULE="date, json, redis, sqlite3, sockets" setup_php
23+
fetch_and_deploy_gh_release "barcodebuddy" "Forceu/barcodebuddy"
24+
25+
msg_info "Configuring barcodebuddy"
3026
chown -R www-data:www-data /opt/barcodebuddy/data
31-
echo "${RELEASE}" >/opt/${APPLICATION}_version.txt
32-
msg_ok "Installed barcodebuddy"
27+
msg_ok "Configured barcodebuddy"
3328

3429
msg_info "Creating Services"
3530
cat <<EOF >/etc/systemd/system/barcodebuddy.service
@@ -73,7 +68,6 @@ motd_ssh
7368
customize
7469

7570
msg_info "Cleaning up"
76-
rm -rf "/opt/v${RELEASE}.zip"
7771
$STD apt-get -y autoremove
7872
$STD apt-get -y autoclean
7973
msg_ok "Cleaned"

0 commit comments

Comments
 (0)