From 5867ef3288f9f5c377c8ccc823bb4e1e8d929887 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 16:12:20 +0200 Subject: [PATCH] Refactor: go2rtc (#6198) * Refactor * Update ct/go2rtc.sh --- ct/go2rtc.sh | 25 +++++++++++++++++-------- install/go2rtc-install.sh | 12 ++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/ct/go2rtc.sh b/ct/go2rtc.sh index ebe684095..e57d5d8fb 100644 --- a/ct/go2rtc.sh +++ b/ct/go2rtc.sh @@ -27,14 +27,23 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - msg_info "Updating $APP" - systemctl stop go2rtc - cd /opt/go2rtc - rm go2rtc_linux_amd64 - curl -fsSL "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64" -o $(basename "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64") - chmod +x go2rtc_linux_amd64 - systemctl start go2rtc - msg_ok "Updated $APP" + + RELEASE=$(curl -fsSL https://api.github.com/repos/AlexxIT/go2rtc/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat ~/.go2rtc 2>/dev/null)" ]] || [[ ! -f ~/.go2rtc ]]; then + msg_info "Stopping service" + systemctl stop go2rtc + msg_ok "Stopped service" + + fetch_and_deploy_gh_release "go2rtc" "AlexxIT/go2rtc" "singlefile" "latest" "/opt/go2rtc" "go2rtc_linux_amd64" + + msg_info "Starting service" + systemctl start go2rtc + msg_ok "Started service" + + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" + fi exit } diff --git a/install/go2rtc-install.sh b/install/go2rtc-install.sh index ab1d1bccc..a7cd0ac38 100644 --- a/install/go2rtc-install.sh +++ b/install/go2rtc-install.sh @@ -13,15 +13,10 @@ setting_up_container network_check update_os -msg_info "Installing go2rtc" -mkdir -p /opt/go2rtc -cd /opt/go2rtc -curl -fsSL "https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_amd64" -o "go2rtc_linux_amd64" -chmod +x go2rtc_linux_amd64 -msg_ok "Installed go2rtc" +fetch_and_deploy_gh_release "go2rtc" "AlexxIT/go2rtc" "singlefile" "latest" "/opt/go2rtc" "go2rtc_linux_amd64" msg_info "Creating Service" -service_path="/etc/systemd/system/go2rtc.service" +cat </etc/systemd/system/go2rtc.service echo "[Unit] Description=go2rtc service After=network.target @@ -32,7 +27,8 @@ User=root ExecStart=/opt/go2rtc/go2rtc_linux_amd64 [Install] -WantedBy=multi-user.target" >$service_path +WantedBy=multi-user.target +EOF systemctl enable -q --now go2rtc msg_ok "Created Service"