Refactor: TeddyCloud (#6963)

* Refactor

* Update
This commit is contained in:
Slaviša Arežina 2025-08-19 14:06:24 +02:00 committed by GitHub
parent 94b9aa4025
commit bd3e93215b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 22 deletions

View File

@ -26,32 +26,34 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi 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) }')" 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 ~/.teddycloud || "${RELEASE}" != "$(cat ~/.teddycloud)" ]]; then
if [[ ! -f "/opt/${APP}_version.txt" || "${VERSION}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Stopping ${APP}" msg_info "Stopping ${APP}"
systemctl stop teddycloud systemctl stop teddycloud
msg_ok "Stopped ${APP}" msg_ok "Stopped ${APP}"
msg_info "Updating ${APP} to v${VERSION}" msg_info "Creating backup"
cd /opt
mv /opt/teddycloud /opt/teddycloud_bak 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") msg_ok "Backup created"
$STD unzip -d /opt/teddycloud teddycloud.amd64.release_v${VERSION}.zip
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 cp -R /opt/teddycloud_bak/certs /opt/teddycloud_bak/config /opt/teddycloud_bak/data /opt/teddycloud
echo "${VERSION}" >"/opt/${APP}_version.txt" msg_ok "Data restored"
msg_ok "Updated ${APP} to v${VERSION}"
msg_info "Starting ${APP}" msg_info "Starting ${APP}"
systemctl start teddycloud systemctl start teddycloud
msg_ok "Started ${APP}" msg_ok "Started ${APP}"
msg_info "Cleaning up" msg_info "Cleaning up"
rm -rf /opt/teddycloud.amd64.release_v${VERSION}.zip
rm -rf /opt/teddycloud_bak rm -rf /opt/teddycloud_bak
msg_ok "Cleaned" msg_ok "Cleaned"
msg_ok "Updated successfully"
else else
msg_ok "No update required. ${APP} is already at v${VERSION}" msg_ok "No update required. ${APP} is already at v${RELEASE}"
fi fi
exit exit
} }

View File

@ -20,15 +20,7 @@ $STD apt-get install -y \
ca-certificates ca-certificates
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Installing TeddyCloud" fetch_and_deploy_gh_release "teddycloud" "toniebox-reverse-engineering/teddycloud" "prebuild" "latest" "/opt/teddycloud" "teddycloud.amd64.release*.zip"
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"
msg_info "Creating Service" msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/teddycloud.service cat <<EOF >/etc/systemd/system/teddycloud.service
@ -53,7 +45,6 @@ motd_ssh
customize customize
msg_info "Cleaning up" msg_info "Cleaning up"
$STD apt-get --yes autoremove $STD apt-get -y autoremove
$STD apt-get --yes autoclean $STD apt-get -y autoclean
rm -rf "teddycloud.amd64.release_v${VERSION}.zip"
msg_ok "Cleaned" msg_ok "Cleaned"