From 9e9bff2315529561316cc24c9abe3be5eb84b140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Thu, 31 Jul 2025 13:58:48 +0200 Subject: [PATCH] Refactor (#6417) --- ct/myspeed.sh | 19 ++++++++----------- install/myspeed-install.sh | 11 +++-------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/ct/myspeed.sh b/ct/myspeed.sh index 965c7f74d..43a08f8a8 100644 --- a/ct/myspeed.sh +++ b/ct/myspeed.sh @@ -28,31 +28,28 @@ function update_script() { exit fi RELEASE=$(curl -fsSL https://github.com/gnmyt/myspeed/releases/latest | grep "title>Release" | cut -d " " -f 5) - if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then - + if [[ ! -f ~/.myspeed ]] || [[ "${RELEASE}" != "$(cat ~/.myspeed)" ]]; then msg_info "Stopping ${APP} Service" systemctl stop myspeed msg_ok "Stopped ${APP} Service" - msg_info "Updating ${APP} to ${RELEASE}" + msg_info "Creating backup" cd /opt rm -rf myspeed_bak mv myspeed myspeed_bak - curl -fsSL "https://github.com/gnmyt/myspeed/releases/download/v$RELEASE/MySpeed-$RELEASE.zip" -o $(basename "https://github.com/gnmyt/myspeed/releases/download/v$RELEASE/MySpeed-$RELEASE.zip") - $STD unzip MySpeed-$RELEASE.zip -d myspeed - cd myspeed + msg_ok "Backup created" + + fetch_and_deploy_gh_release "myspeed" "gnmyt/myspeed" "prebuild" "latest" "/opt/myspeed" "MySpeed-*.zip" + + msg_info "Updating ${APP} to ${RELEASE}" + cd /opt/myspeed $STD npm install - echo "${RELEASE}" >/opt/${APP}_version.txt msg_ok "Updated ${APP} to ${RELEASE}" msg_info "Starting ${APP} Service" systemctl start myspeed msg_ok "Started ${APP} Service" - msg_info "Cleaning up" - rm -rf MySpeed-$RELEASE.zip - msg_ok "Cleaned" - msg_ok "Updated Successfully!\n" else msg_ok "No update required. ${APP} is already at ${RELEASE}" diff --git a/install/myspeed-install.sh b/install/myspeed-install.sh index 17bccfa64..b160abad2 100644 --- a/install/myspeed-install.sh +++ b/install/myspeed-install.sh @@ -20,15 +20,11 @@ $STD apt-get install -y \ msg_ok "Installed Dependencies" NODE_VERSION="22" setup_nodejs +fetch_and_deploy_gh_release "myspeed" "gnmyt/myspeed" "prebuild" "latest" "/opt/myspeed" "MySpeed-*.zip" -msg_info "Installing MySpeed" -RELEASE=$(curl -fsSL https://github.com/gnmyt/myspeed/releases/latest | grep "title>Release" | cut -d " " -f 5) -cd /opt -curl -fsSL "https://github.com/gnmyt/myspeed/releases/download/v$RELEASE/MySpeed-$RELEASE.zip" -o "MySpeed-$RELEASE.zip" -$STD unzip MySpeed-$RELEASE.zip -d myspeed -cd myspeed +msg_info "Configuring MySpeed" +cd /opt/myspeed $STD npm install -echo "${RELEASE}" >/opt/${APPLICATION}_version.txt msg_ok "Installed MySpeed" msg_info "Creating Service" @@ -56,6 +52,5 @@ customize msg_info "Cleaning up" $STD apt-get -y autoremove -rm -rf /opt/MySpeed-$RELEASE.zip $STD apt-get -y autoclean msg_ok "Cleaned"