From e5bea1f49af17906c04554f6034b2d30334de126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Sat, 5 Jul 2025 18:02:58 +0200 Subject: [PATCH] Refactor (#5723) --- ct/dashy.sh | 10 +++++----- install/dashy-install.sh | 5 +---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/ct/dashy.sh b/ct/dashy.sh index e841ba7c2..2bd30a1f0 100644 --- a/ct/dashy.sh +++ b/ct/dashy.sh @@ -29,7 +29,7 @@ function update_script() { fi RELEASE=$(curl -fsSL https://api.github.com/repos/Lissy93/dashy/releases/latest | grep '"tag_name":' | cut -d'"' -f4) - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat ~/.dashy 2>/dev/null)" ]] || [[ ! -f ~/.dashy ]]; then msg_info "Stopping ${APP}" systemctl stop dashy msg_ok "Stopped ${APP}" @@ -43,14 +43,13 @@ function update_script() { fi msg_ok "Backed up conf.yml" - msg_info "Updating ${APP} to ${RELEASE}" rm -rf /opt/dashy - mkdir -p /opt/dashy - curl -fsSL "https://github.com/Lissy93/dashy/archive/refs/tags/${RELEASE}.tar.gz" | tar -xz -C /opt/dashy --strip-components=1 + fetch_and_deploy_gh_release "dashy" "Lissy93/dashy" + + msg_info "Updating ${APP} to ${RELEASE}" cd /opt/dashy npm install npm run build - echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP} to ${RELEASE}" msg_info "Restoring conf.yml" @@ -65,6 +64,7 @@ function update_script() { msg_info "Starting Dashy" systemctl start dashy msg_ok "Started Dashy" + msg_ok "Updated Successfully" else msg_ok "No update required. ${APP} is already at ${RELEASE}" diff --git a/install/dashy-install.sh b/install/dashy-install.sh index 3bda31cfb..a93434585 100644 --- a/install/dashy-install.sh +++ b/install/dashy-install.sh @@ -14,15 +14,12 @@ network_check update_os NODE_VERSION="22" setup_nodejs +fetch_and_deploy_gh_release "dashy" "Lissy93/dashy" -RELEASE=$(curl -fsSL https://api.github.com/repos/Lissy93/dashy/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') msg_info "Installing Dashy ${RELEASE} (Patience)" -mkdir -p /opt/dashy -curl -fsSL "https://github.com/Lissy93/dashy/archive/refs/tags/${RELEASE}.tar.gz" | tar -xz -C /opt/dashy --strip-components=1 cd /opt/dashy $STD npm install $STD npm run build -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Installed Dashy ${RELEASE}" msg_info "Creating Service"