Skip to content

Commit cb7d58b

Browse files
authored
Refactor (#5725)
1 parent 115b21f commit cb7d58b

File tree

2 files changed

+39
-45
lines changed

2 files changed

+39
-45
lines changed

ct/bytestash.sh

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,47 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /opt/bytestash ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
RELEASE=$(curl -fsSL https://api.github.com/repos/jordan-dalby/ByteStash/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-
msg_info "Stopping Services"
33-
systemctl stop bytestash-backend
34-
systemctl stop bytestash-frontend
35-
msg_ok "Services Stopped"
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
27+
if [[ ! -d /opt/bytestash ]]; then
28+
msg_error "No ${APP} Installation Found!"
29+
exit
30+
fi
31+
RELEASE=$(curl -fsSL https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
32+
if [[ "${RELEASE}" != "$(cat ~/.bytestash 2>/dev/null)" ]] || [[ ! -f ~/.bytestash ]]; then
3633

37-
msg_info "Updating ${APP} to ${RELEASE}"
38-
temp_file=$(mktemp)
39-
curl -fsSL "https://github.com/jordan-dalby/ByteStash/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
40-
tar zxf $temp_file
41-
rm -rf /opt/bytestash/server/node_modules
42-
rm -rf /opt/bytestash/client/node_modules
43-
cp -rf ByteStash-${RELEASE}/* /opt/bytestash
44-
cd /opt/bytestash/server
45-
$STD npm install
46-
cd /opt/bytestash/client
47-
$STD npm install
48-
echo "${RELEASE}" >/opt/${APP}_version.txt
49-
msg_ok "Updated ${APP}"
34+
read -rp "${TAB3}Did you make a backup via application WebUI? (y/n): " backuped
35+
if [[ "$backuped" =~ ^[Yy]$ ]]; then
36+
msg_info "Stopping Services"
37+
systemctl stop bytestash-backend
38+
systemctl stop bytestash-frontend
39+
msg_ok "Services Stopped"
5040

51-
msg_info "Starting Services"
52-
systemctl start bytestash-backend
53-
systemctl start bytestash-frontend
54-
msg_ok "Started Services"
41+
rm -rf /opt/bytestash
42+
fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash"
5543

56-
msg_info "Cleaning Up"
57-
rm -f $temp_file
58-
msg_ok "Cleaned"
59-
msg_ok "Updated Successfully"
44+
msg_info "Configuring ByteStash"
45+
cd /opt/bytestash/server
46+
$STD npm install
47+
cd /opt/bytestash/client
48+
$STD npm install
49+
msg_ok "Updated ${APP}"
50+
51+
msg_info "Starting Services"
52+
systemctl start bytestash-backend
53+
systemctl start bytestash-frontend
54+
msg_ok "Started Services"
6055
else
61-
msg_ok "No update required. ${APP} is already at ${RELEASE}"
56+
msg_error "PLEASE MAKE A BACKUP FIRST!"
57+
exit
6258
fi
63-
exit
59+
msg_ok "Updated Successfully"
60+
else
61+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
62+
fi
63+
exit
6464
}
6565

6666
start
@@ -70,4 +70,4 @@ description
7070
msg_ok "Completed Successfully!\n"
7171
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
7272
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
73-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"
73+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}"

install/bytestash-install.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,17 @@ network_check
1414
update_os
1515

1616
NODE_VERSION="22" setup_nodejs
17+
fetch_and_deploy_gh_release "bytestash" "jordan-dalby/ByteStash"
1718

1819
msg_info "Installing ByteStash"
1920
JWT_SECRET=$(openssl rand -base64 32 | tr -d '/+=')
20-
temp_file=$(mktemp)
21-
RELEASE=$(curl -fsSL https://api.github.com/repos/jordan-dalby/ByteStash/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
22-
curl -fsSL "https://github.com/jordan-dalby/ByteStash/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
23-
tar zxf $temp_file
24-
mv ByteStash-${RELEASE} /opt/bytestash
2521
cd /opt/bytestash/server
2622
$STD npm install
2723
cd /opt/bytestash/client
2824
$STD npm install
29-
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
3025
msg_ok "Installed ByteStash"
3126

32-
read -p "${TAB3}Do you want to allow registration of multiple accounts? [y/n]: " allowreg
27+
read -rp "${TAB3}Do you want to allow registration of multiple accounts? [y/n]: " allowreg
3328

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

7570
msg_info "Cleaning up"
76-
rm -f $temp_file
7771
$STD apt-get -y autoremove
7872
$STD apt-get -y autoclean
7973
msg_ok "Cleaned"

0 commit comments

Comments
 (0)