diff --git a/README.md b/README.md index 51c0a64..d857a79 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,9 @@ Run as `root` on a Proxmox VE host: bash <(curl -fsSL https://go.scity.us/install-tapm) ``` -The installed launcher loads the shared iDSSYS defaults and opens the -interactive menu. Update availability is checked in the background and cached; -updates are installed only when explicitly selected or requested with -`tapm update`. +The installed launcher loads TA-ProxMenu's bundled defaults and colors, then +opens the interactive menu. Updates are installed only when explicitly +selected or requested with `tapm update`. On a clustered Proxmox host, both `tapm update` and the management-menu update update every online cluster node over Proxmox's root SSH trust, then update the @@ -27,12 +26,6 @@ When testing this branch, use `tapm main` to switch the installed copy back to the published main branch. The command refuses to switch when local changes, local-only commits, or diverged branch history would be at risk. -The required iDSSYS Defaults repository is handled separately: it is -automatically refreshed before launch when its last successful check is more -than four hours old. If the remote is unavailable, the installed copy is used. -Updates are fast-forward-only. Local file changes, local-only commits, and -diverged histories are preserved and reported instead of being overwritten. - The TA-ProxMenu Management menu can safely switch TA-ProxMenu between branches published on its Git origin. Branch switching is refused when the installed repository has local changes or when the destination branch has commits that would be @@ -73,8 +66,7 @@ portal without changing ProxMenu. - Proxmox VE and root privileges - Bash, Git, curl, wget, Python 3, and standard Debian package tools -- `/opt/idssys/defaults/default.inc` -- `/opt/idssys/defaults/colors.inc` +- The bundled `defaults.inc` and `colors.inc` files The Keepalived deployment additionally requires a healthy, quorate Proxmox cluster and passwordless root SSH between cluster nodes. @@ -111,7 +103,7 @@ Pulse can also be deployed without installing TA-ProxMenu. Run the standalone bootstrap as root on a Proxmox VE host: ```bash -bash <(curl -fsSL https://git.schroedercity.com/TAI/TA-ProxMenu/raw/branch/V2/install-pulse.sh) +bash <(curl -fsSL https://tagit.technologyarch.com/taiadmin/TA-ProxMenu/raw/branch/V2/install-pulse.sh) ``` The bootstrap downloads the Pulse deployment module and its LXC storage helper @@ -170,9 +162,9 @@ GITEA_DOMAIN=git.example.com Replace it with the deployed HTTPS origin, without an API path. There is no hard-coded operational broker URL; authorization fails with a configuration message when the variable is missing or invalid. `GITEA_DOMAIN` is a hostname, -without `https://` or a path, and controls Gitea connectivity plus restoration -of the `voltron/iDS-Defaults.git` repository. Repository updates do not -overwrite the system configuration file. +without `https://` or a path. Repository updates use the installed +TA-ProxMenu checkout's configured Git `origin` and do not overwrite the system +configuration file. On the first V2 launch after installation or upgrade, TA-ProxMenu detects a missing or incomplete `/etc/ta-proxmenu/config.env` and interactively requests diff --git a/colors.inc b/colors.inc new file mode 100755 index 0000000..13d461f --- /dev/null +++ b/colors.inc @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# + +declare -A idsCL +idsCL[Default]="\e[39m" +idsCL[White]="\e[97m" +idsCL[LightGray]="\e[37m" +idsCL[DarkGray]="\e[90m" +idsCL[Black]="\e[30m" +idsCL[Red]="\e[31m" +idsCL[RedBold]="\e[31;1m" +idsCL[LightRed]="\e[91m" +idsCL[Magenta]="\e[35m" +idsCL[LightMagenta]="\e[95m" +idsCL[Blue]="\e[34m" +idsCL[LightBlue]="\e[94m" +idsCL[Cyan]="\e[36m" +idsCL[LightCyan]="\e[96m" +idsCL[Green]="\e[32m" +idsCL[LightGreen]="\e[92m" +idsCL[Yellow]="\e[33m" +idsCL[LightYellow]="\e[93m" + +declare -A idsBG +idsBG[Default]="\e[49m" +idsBG[Black]="\e[40m" +idsBG[Red]="\e[41m" +idsBG[Green]="\e[42m" +idsBG[Yellow]="\e[43m" +idsBG[Blue]="\e[44m" +idsBG[Magenta]="\e[45m" +idsBG[Cyan]="\e[46m" +idsBG[LightGray]="\e[47m" +idsBG[DarkGray]="\e[100m" +idsBG[LightRed]="\e[101m" +idsBG[LightGreen]="\e[102m" +idsBG[LightYellow]="\e[103m" +idsBG[LightBlue]="\e[104m" +idsBG[LightMagenta]="\e[105m" +idsBG[LightCyan]="\e[106m" +idsBG[White]="\e[107m" + +declare -A idsST +idsST[Reset]="\e[0m" +idsST[Bold]="\e[1m" +idsST[Dim]="\e[2m" +idsST[UnderLine]="\e[4m" +idsST[Blink]="\e[5m" +idsST[Invert]="\e[7m" +idsST[Hidden]="\e[8m" diff --git a/defaults.inc b/defaults.inc index 9e93d07..a700730 100755 --- a/defaults.inc +++ b/defaults.inc @@ -3,7 +3,7 @@ action="${1:-}" FOLDER='/opt/idssys/ta-proxmenu' -VERS='2026.7.28-1' +VERS='2026.7.28-2' noupdate=' ' @@ -26,10 +26,22 @@ TAPM_FLEET_ENSURE_IDENTITY || true S1_BROKER_PACKAGE='sentinelone-linux' S1_PACKAGE='tapm-sentinelone.deb' +# Imported from iDS-Defaults/default.inc. These are the only shared-default +# functions TA-ProxMenu calls. +EXIT1() { + clear + exit 0 +} + +ENTER2CONTINUE() { + echo + read -r -s -p "[Press ENTER to continue]" + echo -e "\e[1A\n\e[0K\r\n" +} + # if [ -f /etc/apt/sources.list.d/gyptazy.list ]; then # rm -f /etc/apt/sources.list.d/gyptazy.list /etc/apt/keyrings/gyptazy.asc # echo "deb https://repo.gyptazy.com/stable /" > /etc/apt/sources.list.d/proxlb.list # wget -O /etc/apt/trusted.gpg.d/proxlb.asc https://repo.gyptazy.com/repository.gpg # apt-get update # fi - diff --git a/install-pulse.sh b/install-pulse.sh index d86c097..bbd2849 100755 --- a/install-pulse.sh +++ b/install-pulse.sh @@ -4,7 +4,7 @@ set -u -o pipefail TAPM_PULSE_SOURCE_BRANCH="${TAPM_PULSE_SOURCE_BRANCH:-V2}" -TAPM_PULSE_SOURCE_BASE="${TAPM_PULSE_SOURCE_BASE:-https://git.schroedercity.com/TAI/TA-ProxMenu/raw/branch/${TAPM_PULSE_SOURCE_BRANCH}}" +TAPM_PULSE_SOURCE_BASE="${TAPM_PULSE_SOURCE_BASE:-https://tagit.technologyarch.com/taiadmin/TA-ProxMenu/raw/branch/${TAPM_PULSE_SOURCE_BRANCH}}" TAPM_PULSE_BOOTSTRAP_DIR='' TAPM_TEMP_DIR='' declare -a TAPM_TEMP_DIRS=() diff --git a/proxmenu-scripts.sh b/proxmenu-scripts.sh index 15cd0fc..129daa3 100755 --- a/proxmenu-scripts.sh +++ b/proxmenu-scripts.sh @@ -2,8 +2,7 @@ # TA-Proxmenu - Proxmox Setup Scripts for TA Use -[ "${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 source /opt/idssys/ta-proxmenu/inc/git-update.inc source /opt/idssys/ta-proxmenu/inc/ha-status.inc diff --git a/run.sh b/run.sh index 04378bc..c8e3ffa 100755 --- a/run.sh +++ b/run.sh @@ -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 diff --git a/tests/test-pulse-standalone.sh b/tests/test-pulse-standalone.sh index 8363613..3fac251 100755 --- a/tests/test-pulse-standalone.sh +++ b/tests/test-pulse-standalone.sh @@ -16,9 +16,9 @@ assert_failure "source branch traversal rejected" \ TAPM_PULSE_VALID_SOURCE_BRANCH '../main' assert_success "HTTPS source base accepted" \ TAPM_PULSE_VALID_SOURCE_BASE \ - https://git.schroedercity.com/TAI/TA-ProxMenu/raw/branch/V2 + https://tagit.technologyarch.com/taiadmin/TA-ProxMenu/raw/branch/V2 assert_failure "HTTP source base rejected" \ TAPM_PULSE_VALID_SOURCE_BASE \ - http://git.schroedercity.com/TAI/TA-ProxMenu/raw/branch/V2 + http://tagit.technologyarch.com/taiadmin/TA-ProxMenu/raw/branch/V2 finish_tests diff --git a/tests/test-self-contained-runtime.sh b/tests/test-self-contained-runtime.sh new file mode 100755 index 0000000..023663c --- /dev/null +++ b/tests/test-self-contained-runtime.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -u -o pipefail + +TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +source "${TEST_ROOT}/tests/testlib.sh" +source "${TEST_ROOT}/colors.inc" + +assert_equal '\e[96m' "${idsCL[LightCyan]}" \ + "bundled foreground colors are available" +assert_equal '\e[103m' "${idsBG[LightYellow]}" \ + "bundled background colors are available" +assert_equal '\e[1m' "${idsST[Bold]}" \ + "bundled text styles are available" +assert_success "EXIT1 is bundled in TA-ProxMenu defaults" \ + grep -q '^EXIT1()' "${TEST_ROOT}/defaults.inc" +assert_success "ENTER2CONTINUE is bundled in TA-ProxMenu defaults" \ + grep -q '^ENTER2CONTINUE()' "${TEST_ROOT}/defaults.inc" +assert_failure "runtime launchers do not reference external iDS defaults" \ + grep -E -q '/opt/idssys/defaults|iDS-Defaults' \ + "${TEST_ROOT}/run.sh" "${TEST_ROOT}/proxmenu-scripts.sh" + +finish_tests