Update run.sh

This commit is contained in:
David Schroeder
2026-07-25 18:15:45 -05:00
parent 6362844f1a
commit 873bb17b62
+14 -4
View File
@@ -8,7 +8,9 @@ source /opt/idssys/ta-proxmenu/defaults.inc
SWITCH_TO_V2() { SWITCH_TO_V2() {
local repository='/opt/idssys/ta-proxmenu' local repository='/opt/idssys/ta-proxmenu'
local current_branch local current_branch
local head_commit
local local_commit local local_commit
local main_commit
local remote_commit local remote_commit
if [[ ! -d "${repository}/.git" ]]; then if [[ ! -d "${repository}/.git" ]]; then
@@ -17,10 +19,6 @@ SWITCH_TO_V2() {
fi fi
current_branch="$(git -C "$repository" branch --show-current 2>/dev/null)" current_branch="$(git -C "$repository" branch --show-current 2>/dev/null)"
if [[ -z "$current_branch" ]]; then
echo -e "${idsCL[Red]}TA-ProxMenu is in a detached HEAD state; branch switching was refused.${idsCL[Default]}"
return 1
fi
if [[ "$current_branch" == "V2" ]]; then if [[ "$current_branch" == "V2" ]]; then
exec /opt/idssys/ta-proxmenu/run.sh exec /opt/idssys/ta-proxmenu/run.sh
fi fi
@@ -32,11 +30,23 @@ SWITCH_TO_V2() {
echo -e "${idsCL[LightCyan]}Fetching TA-ProxMenu branch 'V2'...${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Fetching TA-ProxMenu branch 'V2'...${idsCL[Default]}"
if ! timeout 30 git -C "$repository" fetch --prune origin \ if ! timeout 30 git -C "$repository" fetch --prune origin \
'+refs/heads/main:refs/remotes/origin/main' \
'+refs/heads/V2:refs/remotes/origin/V2' >/dev/null 2>&1; then '+refs/heads/V2:refs/remotes/origin/V2' >/dev/null 2>&1; then
echo -e "${idsCL[Red]}Could not fetch branch 'V2' from origin.${idsCL[Default]}" echo -e "${idsCL[Red]}Could not fetch branch 'V2' from origin.${idsCL[Default]}"
return 1 return 1
fi fi
if [[ -z "$current_branch" ]]; then
head_commit="$(git -C "$repository" rev-parse --verify 'HEAD^{commit}' 2>/dev/null)"
main_commit="$(git -C "$repository" rev-parse --verify \
'refs/remotes/origin/main^{commit}' 2>/dev/null)"
if [[ -z "$head_commit" || "$head_commit" != "$main_commit" ]]; then
echo -e "${idsCL[Red]}TA-ProxMenu has an unrecognized detached HEAD; branch switching was refused.${idsCL[Default]}"
return 1
fi
echo -e "${idsCL[LightCyan]}Recovered the legacy updater's detached main checkout.${idsCL[Default]}"
fi
remote_commit="$(git -C "$repository" rev-parse --verify \ remote_commit="$(git -C "$repository" rev-parse --verify \
'refs/remotes/origin/V2^{commit}' 2>/dev/null)" || { 'refs/remotes/origin/V2^{commit}' 2>/dev/null)" || {
echo -e "${idsCL[Red]}Origin does not provide a usable V2 branch.${idsCL[Default]}" echo -e "${idsCL[Red]}Origin does not provide a usable V2 branch.${idsCL[Default]}"