From bd3e93215bdc9faf7923eb7ab841bf3324898bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Tue, 19 Aug 2025 14:06:24 +0200 Subject: [PATCH] Refactor: TeddyCloud (#6963) * Refactor * Update --- ct/teddycloud.sh | 22 ++++++++++++---------- install/teddycloud-install.sh | 15 +++------------ 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/ct/teddycloud.sh b/ct/teddycloud.sh index eed14c2e1..b34e8a510 100644 --- a/ct/teddycloud.sh +++ b/ct/teddycloud.sh @@ -26,32 +26,34 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi + RELEASE="$(curl -fsSL https://api.github.com/repos/toniebox-reverse-engineering/teddycloud/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')" - VERSION="${RELEASE#tc_v}" - if [[ ! -f "/opt/${APP}_version.txt" || "${VERSION}" != "$(cat /opt/${APP}_version.txt)" ]]; then + if [[ ! -f ~/.teddycloud || "${RELEASE}" != "$(cat ~/.teddycloud)" ]]; then msg_info "Stopping ${APP}" systemctl stop teddycloud msg_ok "Stopped ${APP}" - msg_info "Updating ${APP} to v${VERSION}" - cd /opt + msg_info "Creating backup" mv /opt/teddycloud /opt/teddycloud_bak - curl -fsSL "https://github.com/toniebox-reverse-engineering/teddycloud/releases/download/${RELEASE}/teddycloud.amd64.release_v${VERSION}.zip" -o $(basename "https://github.com/toniebox-reverse-engineering/teddycloud/releases/download/${RELEASE}/teddycloud.amd64.release_v${VERSION}.zip") - $STD unzip -d /opt/teddycloud teddycloud.amd64.release_v${VERSION}.zip + msg_ok "Backup created" + + fetch_and_deploy_gh_release "teddycloud" "toniebox-reverse-engineering/teddycloud" "prebuild" "latest" "/opt/teddycloud" "teddycloud.amd64.release*.zip" + + msg_info "Restoring data" cp -R /opt/teddycloud_bak/certs /opt/teddycloud_bak/config /opt/teddycloud_bak/data /opt/teddycloud - echo "${VERSION}" >"/opt/${APP}_version.txt" - msg_ok "Updated ${APP} to v${VERSION}" + msg_ok "Data restored" msg_info "Starting ${APP}" systemctl start teddycloud msg_ok "Started ${APP}" msg_info "Cleaning up" - rm -rf /opt/teddycloud.amd64.release_v${VERSION}.zip rm -rf /opt/teddycloud_bak msg_ok "Cleaned" + + msg_ok "Updated successfully" else - msg_ok "No update required. ${APP} is already at v${VERSION}" + msg_ok "No update required. ${APP} is already at v${RELEASE}" fi exit } diff --git a/install/teddycloud-install.sh b/install/teddycloud-install.sh index d290c1bdc..99964a1af 100644 --- a/install/teddycloud-install.sh +++ b/install/teddycloud-install.sh @@ -20,15 +20,7 @@ $STD apt-get install -y \ ca-certificates msg_ok "Installed Dependencies" -msg_info "Installing TeddyCloud" -RELEASE="$(curl -fsSL https://api.github.com/repos/toniebox-reverse-engineering/teddycloud/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')" -VERSION="${RELEASE#tc_v}" -curl -fsSL "https://github.com/toniebox-reverse-engineering/teddycloud/releases/download/${RELEASE}/teddycloud.amd64.release_v${VERSION}.zip" -o "teddycloud.amd64.release_v${VERSION}.zip" -$STD unzip -d "/opt/teddycloud-${VERSION}" "teddycloud.amd64.release_v${VERSION}.zip" -ln -fns "/opt/teddycloud-${VERSION}" /opt/teddycloud -rm -rf teddycloud.amd64.release_v${VERSION}.zip -echo "${VERSION}" >"/opt/${APPLICATION}_version.txt" -msg_ok "Installed TeddyCloud" +fetch_and_deploy_gh_release "teddycloud" "toniebox-reverse-engineering/teddycloud" "prebuild" "latest" "/opt/teddycloud" "teddycloud.amd64.release*.zip" msg_info "Creating Service" cat </etc/systemd/system/teddycloud.service @@ -53,7 +45,6 @@ motd_ssh customize msg_info "Cleaning up" -$STD apt-get --yes autoremove -$STD apt-get --yes autoclean -rm -rf "teddycloud.amd64.release_v${VERSION}.zip" +$STD apt-get -y autoremove +$STD apt-get -y autoclean msg_ok "Cleaned"