From 0e2c793f921e444f59b25a8a0265ccc838a6d6e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Wed, 9 Jul 2025 10:53:35 +0200 Subject: [PATCH] Refactor (#5841) --- ct/excalidraw.sh | 17 ++++------------- install/excalidraw-install.sh | 13 +++---------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/ct/excalidraw.sh b/ct/excalidraw.sh index 1744439a0..b93b62377 100644 --- a/ct/excalidraw.sh +++ b/ct/excalidraw.sh @@ -28,20 +28,16 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - RELEASE=$(curl -fsSL https://api.github.com/repos/excalidraw/excalidraw/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') - if [[ "${RELEASE}" != "$(cat /opt/excalidraw_version.txt)" ]] || [[ ! -f /opt/excalidraw_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat ~/.excalidraw 2>/dev/null)" ]] || [[ ! -f ~/.excalidraw ]]; then msg_info "Stopping $APP" systemctl stop excalidraw msg_ok "Stopped $APP" - msg_info "Updating $APP to v${RELEASE}" - cd /tmp - temp_file=$(mktemp) - curl -fsSL "https://github.com/excalidraw/excalidraw/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" - tar xzf $temp_file rm -rf /opt/excalidraw - mv excalidraw-${RELEASE} /opt/excalidraw + fetch_and_deploy_gh_release "excalidraw" "excalidraw/excalidraw" + + msg_info "Updating $APP to v${RELEASE}" cd /opt/excalidraw $STD yarn msg_ok "Updated $APP to v${RELEASE}" @@ -50,11 +46,6 @@ function update_script() { systemctl start excalidraw msg_ok "Started $APP" - msg_info "Cleaning Up" - rm -rf $temp_file - msg_ok "Cleanup Completed" - - echo "${RELEASE}" >/opt/excalidraw_version.txt msg_ok "Update Successful" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/install/excalidraw-install.sh b/install/excalidraw-install.sh index 885a39c91..39e30bd1b 100644 --- a/install/excalidraw-install.sh +++ b/install/excalidraw-install.sh @@ -14,21 +14,15 @@ network_check update_os msg_info "Installing Dependencies" -$STD apt-get install -y \ - xdg-utils +$STD apt-get install -y xdg-utils msg_ok "Installed Dependencies" NODE_VERSION="22" NODE_MODULE="yarn@latest" setup_nodejs +fetch_and_deploy_gh_release "excalidraw" "excalidraw/excalidraw" -msg_info "Setup Excalidraw" -temp_file=$(mktemp) -RELEASE=$(curl -fsSL https://api.github.com/repos/excalidraw/excalidraw/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -curl -fsSL "https://github.com/excalidraw/excalidraw/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" -tar xzf $temp_file -mv excalidraw-${RELEASE} /opt/excalidraw +msg_info "Configuring Excalidraw" cd /opt/excalidraw $STD yarn -echo "${RELEASE}" >/opt/excalidraw_version.txt msg_ok "Setup Excalidraw" msg_info "Creating Service" @@ -53,7 +47,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -f $temp_file $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned"