From d9567636428983268aa2e495addc1b8d3ffea55a 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, 24 Jul 2025 21:00:41 +0200 Subject: [PATCH] Refactor (#6202) --- ct/duplicati.sh | 14 ++++---------- install/duplicati-install.sh | 13 +++---------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ct/duplicati.sh b/ct/duplicati.sh index 90bf43db7..fc313fa27 100644 --- a/ct/duplicati.sh +++ b/ct/duplicati.sh @@ -27,25 +27,19 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE=$(curl -fsSL https://api.github.com/repos/duplicati/duplicati/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') - if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + if [[ "${RELEASE}" != "$(cat ~/.duplicati)" ]] || [[ ! -f ~/.duplicati ]]; then msg_info "Stopping $APP" systemctl stop duplicati msg_ok "Stopped $APP" - msg_info "Updating $APP to v${RELEASE}" - curl -fsSL "https://github.com/duplicati/duplicati/releases/download/v${RELEASE}/duplicati-${RELEASE}-linux-x64-gui.deb" -o $(basename "https://github.com/duplicati/duplicati/releases/download/v${RELEASE}/duplicati-${RELEASE}-linux-x64-gui.deb") - $STD dpkg -i duplicati-${RELEASE}-linux-x64-gui.deb - echo "${RELEASE}" >/opt/${APP}_version.txt - msg_ok "Updated $APP to v${RELEASE}" + + fetch_and_deploy_gh_release "duplicati" "duplicati/duplicati" "binary" "latest" "/opt/duplicati" "linux-x64-gui.deb" msg_info "Starting $APP" systemctl start duplicati msg_ok "Started $APP" - msg_info "Cleaning Up" - rm -rf ~/duplicati-${RELEASE}-linux-x64-gui.deb - msg_ok "Cleanup Completed" - msg_ok "Update Successful" else msg_ok "No update required. ${APP} is already at v${RELEASE}" diff --git a/install/duplicati-install.sh b/install/duplicati-install.sh index 2d0ebf889..ad239cd7d 100644 --- a/install/duplicati-install.sh +++ b/install/duplicati-install.sh @@ -20,19 +20,16 @@ $STD apt-get install -y \ libfontconfig1 msg_ok "Installed Dependencies" -msg_info "Setting up Duplicati" -RELEASE=$(curl -fsSL https://api.github.com/repos/duplicati/duplicati/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') -curl -fsSL "https://github.com/duplicati/duplicati/releases/download/v${RELEASE}/duplicati-${RELEASE}-linux-x64-gui.deb" -o "duplicati-${RELEASE}-linux-x64-gui.deb" -$STD dpkg -i duplicati-${RELEASE}-linux-x64-gui.deb -echo "${RELEASE}" >/opt/Duplicati_version.txt -msg_ok "Finished setting up Duplicati" +fetch_and_deploy_gh_release "duplicati" "duplicati/duplicati" "binary" "latest" "/opt/duplicati" "linux-x64-gui.deb" +msg_info "Configuring duplicati" DECRYPTKEY=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) ADMINPASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) { echo "Admin password = ${ADMINPASS}" echo "Database encryption key = ${DECRYPTKEY}" } >>~/duplicati.creds +msg_ok "Configured duplicati" msg_info "Creating Service" cat </etc/systemd/system/duplicati.service @@ -54,10 +51,6 @@ motd_ssh customize msg_info "Cleaning up" -rm -f duplicati-${RELEASE}-linux-x64-gui.deb $STD apt-get -y autoremove $STD apt-get -y autoclean msg_ok "Cleaned" - -motd_ssh -customize