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!"
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
}

View File

@ -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 <<EOF >/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"