update gir url
This commit is contained in:
@@ -1,105 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# TA-ProxMenu preloader
|
||||
|
||||
DEFAULTS_REPOSITORY='/opt/idssys/defaults'
|
||||
DEFAULTS_CACHE_DIR='/var/cache/ta-proxmenu'
|
||||
DEFAULTS_CHECK_FILE="${DEFAULTS_CACHE_DIR}/defaults-last-check"
|
||||
DEFAULTS_CHECK_SECONDS=14400
|
||||
source /opt/idssys/ta-proxmenu/inc/runtime-config.inc
|
||||
TAPM_ENSURE_RUNTIME_CONFIG || exit 1
|
||||
DEFAULTS_REPOSITORY_URL="${GITEA_URL}/voltron/iDS-Defaults.git"
|
||||
|
||||
source /opt/idssys/ta-proxmenu/inc/git-update.inc
|
||||
source /opt/idssys/ta-proxmenu/inc/cluster-update.inc
|
||||
|
||||
AUTO_UPDATE_DEFAULTS() {
|
||||
local checked_at=0
|
||||
local current_branch
|
||||
local now
|
||||
local state
|
||||
|
||||
mkdir -p "$DEFAULTS_CACHE_DIR" 2>/dev/null || true
|
||||
now="$(date +%s)"
|
||||
[[ -r "$DEFAULTS_CHECK_FILE" ]] && read -r checked_at <"$DEFAULTS_CHECK_FILE"
|
||||
|
||||
if [[ "$checked_at" =~ ^[0-9]+$ ]] &&
|
||||
(( now - checked_at < DEFAULTS_CHECK_SECONDS )); then
|
||||
return
|
||||
fi
|
||||
|
||||
exec 9>"${DEFAULTS_CACHE_DIR}/defaults-update.lock" || return
|
||||
flock -n 9 || return
|
||||
|
||||
# Another process may have completed the update while this one waited.
|
||||
checked_at=0
|
||||
[[ -r "$DEFAULTS_CHECK_FILE" ]] && read -r checked_at <"$DEFAULTS_CHECK_FILE"
|
||||
if [[ "$checked_at" =~ ^[0-9]+$ ]] &&
|
||||
(( now - checked_at < DEFAULTS_CHECK_SECONDS )); then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! -d "${DEFAULTS_REPOSITORY}/.git" ]]; then
|
||||
echo "iDSSYS Defaults is missing; restoring it from origin..."
|
||||
if [[ -z "$DEFAULTS_REPOSITORY_URL" ]]; then
|
||||
echo "WARNING: GITEA_DOMAIN is not configured; unable to restore iDSSYS Defaults." >&2
|
||||
return
|
||||
fi
|
||||
mkdir -p /opt/idssys
|
||||
if ! timeout 60 git clone \
|
||||
"$DEFAULTS_REPOSITORY_URL" "$DEFAULTS_REPOSITORY"; then
|
||||
echo "WARNING: Unable to restore iDSSYS Defaults." >&2
|
||||
return
|
||||
fi
|
||||
else
|
||||
current_branch="$(git -C "$DEFAULTS_REPOSITORY" branch --show-current 2>/dev/null)"
|
||||
if [[ "$current_branch" != "master" ]]; then
|
||||
echo "WARNING: iDSSYS Defaults is not on master; automatic update skipped." >&2
|
||||
date +%s >"$DEFAULTS_CHECK_FILE"
|
||||
return
|
||||
fi
|
||||
if TAPM_GIT_WORKTREE_DIRTY "$DEFAULTS_REPOSITORY"; then
|
||||
echo "WARNING: iDSSYS Defaults has local changes; automatic update skipped." >&2
|
||||
date +%s >"$DEFAULTS_CHECK_FILE"
|
||||
return
|
||||
fi
|
||||
if ! TAPM_GIT_FETCH_BRANCH "$DEFAULTS_REPOSITORY" master 20 \
|
||||
>/dev/null 2>&1; then
|
||||
echo "WARNING: Unable to check iDSSYS Defaults; using the installed copy." >&2
|
||||
return
|
||||
fi
|
||||
|
||||
state="$(TAPM_GIT_BRANCH_STATE "$DEFAULTS_REPOSITORY" master)"
|
||||
case "$state" in
|
||||
behind)
|
||||
echo "Updating required iDSSYS Defaults..."
|
||||
if ! TAPM_GIT_FAST_FORWARD "$DEFAULTS_REPOSITORY" master \
|
||||
>/dev/null 2>&1; then
|
||||
echo "WARNING: Unable to update iDSSYS Defaults; using the installed copy." >&2
|
||||
return
|
||||
fi
|
||||
;;
|
||||
current)
|
||||
;;
|
||||
ahead)
|
||||
echo "WARNING: iDSSYS Defaults has local commits not on origin; automatic update skipped." >&2
|
||||
;;
|
||||
diverged)
|
||||
echo "WARNING: iDSSYS Defaults has diverged from origin; automatic update skipped." >&2
|
||||
;;
|
||||
*)
|
||||
echo "WARNING: Unable to update iDSSYS Defaults; using the installed copy." >&2
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
date +%s >"$DEFAULTS_CHECK_FILE"
|
||||
}
|
||||
|
||||
AUTO_UPDATE_DEFAULTS
|
||||
|
||||
[ "${2:-}" != "q" ] && source /opt/idssys/defaults/colors.inc
|
||||
source /opt/idssys/defaults/default.inc
|
||||
[ "${2:-}" != "q" ] && source /opt/idssys/ta-proxmenu/colors.inc
|
||||
source /opt/idssys/ta-proxmenu/defaults.inc
|
||||
TAPM_FLEET_START "$VERS"
|
||||
trap 'TAPM_FLEET_FINISH "$?"' EXIT
|
||||
@@ -240,22 +148,9 @@ SWITCH_TAPM_BRANCH() {
|
||||
|
||||
INSTALL_LOCAL_UPDATES() {
|
||||
local current_branch
|
||||
local defaults_warning=0
|
||||
local update_failed=0
|
||||
|
||||
echo -e "${idsCL[LightCyan]}Checking for updates...${idsCL[Default]}"
|
||||
if [[ -z "$GITEA_URL" ]]; then
|
||||
echo -e "${idsCL[Red]}GITEA_DOMAIN is not configured in ${TAPM_CONFIG_FILE}.${idsCL[Default]}"
|
||||
return 1
|
||||
fi
|
||||
if ! curl --fail --silent --show-error --head \
|
||||
--connect-timeout 3 --max-time 10 "$GITEA_URL" >/dev/null; then
|
||||
echo -e "${idsCL[Red]}Could not connect to ${GITEA_DOMAIN}${idsCL[Default]}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
UPDATE_REPOSITORY /opt/idssys/defaults master "iDSSYS Defaults" ||
|
||||
defaults_warning=1
|
||||
|
||||
current_branch="$(git -C /opt/idssys/ta-proxmenu branch --show-current)"
|
||||
if [ -z "$current_branch" ]; then
|
||||
@@ -271,9 +166,6 @@ INSTALL_LOCAL_UPDATES() {
|
||||
if (( update_failed == 0 )); then
|
||||
source /opt/idssys/ta-proxmenu/defaults.inc
|
||||
echo -e "\n${idsCL[Green]}Update check complete. Installed version: ${VERS}${idsCL[Default]}"
|
||||
if (( defaults_warning == 1 )); then
|
||||
echo -e "${idsCL[LightYellow]}TA-ProxMenu was processed, but iDSSYS Defaults requires attention.${idsCL[Default]}"
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user