diff --git a/ct/openthread-br.sh b/ct/openthread-br.sh index 08db77a19..e9641e4cc 100644 --- a/ct/openthread-br.sh +++ b/ct/openthread-br.sh @@ -2,7 +2,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) # Copyright (c) 2021-2026 community-scripts ORG -# Author: MickLesk (CanbiZ) +# Author: MickLesk (CanbiZ) | Co-Author: Tom Frenzel (tomfrenzel) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://openthread.io/guides/border-router @@ -32,29 +32,23 @@ function update_script() { exit fi - cd /opt/ot-br-posix - LOCAL_COMMIT=$(git rev-parse HEAD) - $STD git fetch --depth 1 origin main - REMOTE_COMMIT=$(git rev-parse origin/main) + if check_for_gh_release "openthread-br" "openthread/ot-br-posix"; then + msg_info "Stopping Services" + systemctl stop otbr-web + systemctl stop otbr-agent + msg_ok "Stopped Services" - if [[ "${LOCAL_COMMIT}" == "${REMOTE_COMMIT}" ]]; then - msg_ok "Already up to date (${LOCAL_COMMIT:0:7})" - exit - fi + msg_info "Backing up Configuration" + cp /etc/default/otbr-agent /etc/default/otbr-agent.bak + msg_ok "Backed up Configuration" - msg_info "Stopping Services" - systemctl stop otbr-web - systemctl stop otbr-agent - msg_ok "Stopped Services" - - msg_info "Backing up Configuration" - cp /etc/default/otbr-agent /etc/default/otbr-agent.bak - msg_ok "Backed up Configuration" - - msg_info "Updating Source" - $STD git reset --hard origin/main - $STD git submodule update --depth 1 --init --recursive - msg_ok "Updated Source" + msg_info "Fetching GitHub release OpenThread-BR (${CHECK_UPDATE_RELEASE#v})" + cd /opt/ot-br-posix + $STD git fetch --depth 1 origin tag "$CHECK_UPDATE_RELEASE" + $STD git checkout -f "$CHECK_UPDATE_RELEASE" + $STD git submodule update --depth 1 --init --recursive + echo "${CHECK_UPDATE_RELEASE#v}" > ~/.openthread-br + msg_ok "Deployed GitHub release OpenThread-BR (${CHECK_UPDATE_RELEASE#v})" msg_info "Rebuilding OpenThread Border Router (Patience)" cd /opt/ot-br-posix/build @@ -104,6 +98,7 @@ EOF systemctl start otbr-web msg_ok "Started Services" msg_ok "Updated successfully!" + fi exit } diff --git a/install/openthread-br-install.sh b/install/openthread-br-install.sh index 779bb3951..8e68e3250 100644 --- a/install/openthread-br-install.sh +++ b/install/openthread-br-install.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Copyright (c) 2021-2026 community-scripts ORG -# Author: MickLesk (CanbiZ) +# Author: MickLesk (CanbiZ) | Co-Author: Tom Frenzel (tomfrenzel) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE # Source: https://openthread.io/guides/border-router @@ -39,12 +39,19 @@ msg_ok "Installed Dependencies" setup_nodejs -msg_info "Cloning OpenThread Border Router" +RELEASE=$(get_latest_gh_tag "openthread/ot-br-posix") +if [[ -z "$RELEASE" ]]; then + msg_error "Failed to fetch latest release tag" + exit 1 +fi + +msg_info "Fetching GitHub release OpenThread-BR (${RELEASE#v})" # git clone is needed to fetch submodules, fetch_and_deploy_gh_release doesn't support this. We use --depth 1 to minimize the amount of data cloned, but it still may take a while. -$STD git clone --depth 1 https://github.com/openthread/ot-br-posix /opt/ot-br-posix +$STD git clone --depth 1 --branch "$RELEASE" https://github.com/openthread/ot-br-posix /opt/ot-br-posix cd /opt/ot-br-posix $STD git submodule update --depth 1 --init --recursive -msg_ok "Cloned OpenThread Border Router" +echo "${RELEASE#v}" > ~/.openthread-br +msg_ok "Deployed GitHub release OpenThread-BR (${RELEASE#v})" msg_info "Building OpenThread Border Router (Patience)" mkdir -p build && cd build