Skip to content

Commit 0e2c793

Browse files
authored
Refactor (#5841)
1 parent 96a8f9d commit 0e2c793

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

ct/excalidraw.sh

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,16 @@ function update_script() {
2828
msg_error "No ${APP} Installation Found!"
2929
exit
3030
fi
31-
3231
RELEASE=$(curl -fsSL https://api.github.com/repos/excalidraw/excalidraw/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
33-
if [[ "${RELEASE}" != "$(cat /opt/excalidraw_version.txt)" ]] || [[ ! -f /opt/excalidraw_version.txt ]]; then
32+
if [[ "${RELEASE}" != "$(cat ~/.excalidraw 2>/dev/null)" ]] || [[ ! -f ~/.excalidraw ]]; then
3433
msg_info "Stopping $APP"
3534
systemctl stop excalidraw
3635
msg_ok "Stopped $APP"
3736

38-
msg_info "Updating $APP to v${RELEASE}"
39-
cd /tmp
40-
temp_file=$(mktemp)
41-
curl -fsSL "https://github.com/excalidraw/excalidraw/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
42-
tar xzf $temp_file
4337
rm -rf /opt/excalidraw
44-
mv excalidraw-${RELEASE} /opt/excalidraw
38+
fetch_and_deploy_gh_release "excalidraw" "excalidraw/excalidraw"
39+
40+
msg_info "Updating $APP to v${RELEASE}"
4541
cd /opt/excalidraw
4642
$STD yarn
4743
msg_ok "Updated $APP to v${RELEASE}"
@@ -50,11 +46,6 @@ function update_script() {
5046
systemctl start excalidraw
5147
msg_ok "Started $APP"
5248

53-
msg_info "Cleaning Up"
54-
rm -rf $temp_file
55-
msg_ok "Cleanup Completed"
56-
57-
echo "${RELEASE}" >/opt/excalidraw_version.txt
5849
msg_ok "Update Successful"
5950
else
6051
msg_ok "No update required. ${APP} is already at v${RELEASE}"

install/excalidraw-install.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,15 @@ network_check
1414
update_os
1515

1616
msg_info "Installing Dependencies"
17-
$STD apt-get install -y \
18-
xdg-utils
17+
$STD apt-get install -y xdg-utils
1918
msg_ok "Installed Dependencies"
2019

2120
NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs
21+
fetch_and_deploy_gh_release "excalidraw" "excalidraw/excalidraw"
2222

23-
msg_info "Setup Excalidraw"
24-
temp_file=$(mktemp)
25-
RELEASE=$(curl -fsSL https://api.github.com/repos/excalidraw/excalidraw/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
26-
curl -fsSL "https://github.com/excalidraw/excalidraw/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
27-
tar xzf $temp_file
28-
mv excalidraw-${RELEASE} /opt/excalidraw
23+
msg_info "Configuring Excalidraw"
2924
cd /opt/excalidraw
3025
$STD yarn
31-
echo "${RELEASE}" >/opt/excalidraw_version.txt
3226
msg_ok "Setup Excalidraw"
3327

3428
msg_info "Creating Service"
@@ -53,7 +47,6 @@ motd_ssh
5347
customize
5448

5549
msg_info "Cleaning up"
56-
rm -f $temp_file
5750
$STD apt-get -y autoremove
5851
$STD apt-get -y autoclean
5952
msg_ok "Cleaned"

0 commit comments

Comments
 (0)