From 259794f0a3e07ef40e8787f05fba055b9cd62cc9 Mon Sep 17 00:00:00 2001 From: Lucas Zampieri Date: Thu, 24 Jul 2025 10:21:24 +0100 Subject: [PATCH] Apply PR review suggestions - Remove explicit dependency installation - Use fetch_and_deploy_gh_release helper function - Add version checking before updates - Use direct curl command for release version checking Signed-off-by: Lucas Zampieri --- ct/cleanuparr.sh | 34 ++++++++++++++++++---------------- install/cleanuparr-install.sh | 16 +--------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/ct/cleanuparr.sh b/ct/cleanuparr.sh index 05ef4ae0..6aea73e9 100755 --- a/ct/cleanuparr.sh +++ b/ct/cleanuparr.sh @@ -27,23 +27,25 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_info "Stopping ${APP}" - systemctl stop cleanuparr - msg_ok "Stopped ${APP}" - msg_info "Updating ${APP}" - cd /opt/cleanuparr - RELEASE=$(curl -fsSL https://api.github.com/repos/Cleanuparr/Cleanuparr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') - curl -fsSLO "https://github.com/Cleanuparr/Cleanuparr/releases/download/v${RELEASE}/Cleanuparr-${RELEASE}-linux-amd64.zip" - unzip -oq "Cleanuparr-${RELEASE}-linux-amd64.zip" - rm -f "Cleanuparr-${RELEASE}-linux-amd64.zip" - chmod +x /opt/cleanuparr/Cleanuparr - msg_ok "Updated ${APP}" + RELEASE=$(curl -fsSL https://api.github.com/repos/Cleanuparr/Cleanuparr/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - msg_info "Starting ${APP}" - systemctl start cleanuparr - msg_ok "Started ${APP}" - msg_ok "Updated Successfully" + if [[ "${RELEASE}" != "$(cat ~/.Cleanuparr 2>/dev/null)" ]] || [[ ! -f ~/.Cleanuparr ]]; then + msg_info "Stopping ${APP}" + systemctl stop cleanuparr + msg_ok "Stopped ${APP}" + + msg_info "Updating ${APP} to v${RELEASE}" + fetch_and_deploy_gh_release "Cleanuparr" "Cleanuparr/Cleanuparr" "prebuild" "$RELEASE" "/opt/cleanuparr" "*linux-amd64.zip" + msg_ok "Updated ${APP}" + + msg_info "Starting ${APP}" + systemctl start cleanuparr + msg_ok "Started ${APP}" + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi exit } @@ -54,4 +56,4 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" echo -e "${INFO}${YW} Access it using the following URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:11011${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:11011${CL}" diff --git a/install/cleanuparr-install.sh b/install/cleanuparr-install.sh index 89ae2dd9..22dabb5c 100755 --- a/install/cleanuparr-install.sh +++ b/install/cleanuparr-install.sh @@ -13,22 +13,8 @@ setting_up_container network_check update_os -msg_info "Installing Dependencies" -$STD apt-get install -y \ - curl \ - sudo \ - mc \ - unzip -msg_ok "Installed Dependencies" - msg_info "Installing Cleanuparr" -RELEASE=$(curl -fsSL https://api.github.com/repos/Cleanuparr/Cleanuparr/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') -mkdir -p /opt/cleanuparr -cd /opt/cleanuparr -curl -fsSLO "https://github.com/Cleanuparr/Cleanuparr/releases/download/v${RELEASE}/Cleanuparr-${RELEASE}-linux-amd64.zip" -unzip -q "Cleanuparr-${RELEASE}-linux-amd64.zip" -rm -f "Cleanuparr-${RELEASE}-linux-amd64.zip" -chmod +x /opt/cleanuparr/Cleanuparr +fetch_and_deploy_gh_release "Cleanuparr" "Cleanuparr/Cleanuparr" "prebuild" "latest" "/opt/cleanuparr" "*linux-amd64.zip" msg_ok "Installed Cleanuparr" msg_info "Creating Service"