Skip to content

armgit / ODS

Public Imported from GitHub
0

ODS V3 Pre-Release: Public testing and refinement ahead of the official V3 launch. Turn your PC, Mac, or Linux box into a private AI server.

3.1 KB
Raw Blame
#!/bin/bash
# Contract: the macOS installer keeps the restored six-phase ODSGATE identity
# while redirected/non-interactive output remains stable and control-code free.

set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ODS_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
TEST_HOME="$(mktemp -d)"
trap 'rm -rf "$TEST_HOME"' EXIT

export ODS_HOME="$TEST_HOME/ods"
export ODS_UI_MODE="plain"
export NON_INTERACTIVE="true"
export NO_COLOR="1"
export ODS_INSTALLER_GUI=""
export CLOUD_MODE="false"
mkdir -p "$ODS_HOME"
printf 'BIND_ADDRESS=127.0.0.1\n' > "$ODS_HOME/.env"

# shellcheck source=/dev/null
. "$ODS_ROOT/installers/macos/lib/constants.sh"
# shellcheck source=/dev/null
. "$ODS_ROOT/installers/macos/lib/ui.sh"

# show_success_card only uses this command to offer an optional LAN URL.
ipconfig() { return 1; }

rendered="$({
    show_ods_banner
    phase=1
    while [[ "$phase" -le 6 ]]; do
        show_phase "$phase" 6 "TEST PHASE $phase" "test"
        phase=$((phase + 1))
    done
    show_success_card 3000 3001
} 2>&1)"

case "$rendered" in
    *"O D S G A T E"*) ;;
    *) echo "[FAIL] Restored ODSGATE identity is missing from the macOS banner" >&2; exit 1 ;;
esac
case "$rendered" in
    *"THE ODS GATEWAY IS OPEN"*) ;;
    *) echo "[FAIL] Restored gateway completion line is missing" >&2; exit 1 ;;
esac
case "$rendered" in
    *$'\033'*) echo "[FAIL] Plain macOS output contains an ANSI escape" >&2; exit 1 ;;
esac
case "$rendered" in
    *$'\r'*) echo "[FAIL] Plain macOS output contains a carriage return" >&2; exit 1 ;;
esac

phases="$(printf '%s\n' "$rendered" | sed -n 's/.*PHASE \([1-6]\)\/6.*/\1/p' | paste -sd, -)"
if [[ "$phases" != "1,2,3,4,5,6" ]]; then
    echo "[FAIL] Expected stable macOS phases 1,2,3,4,5,6; got: ${phases:-none}" >&2
    exit 1
fi

ENABLE_OPEN_WEBUI=false
printf 'BIND_ADDRESS=0.0.0.0\n' > "$ODS_HOME/.env"
lean_card="$(show_success_card 3000 3001)"
[[ "$lean_card" == *'Chat (Portal):'* && "$lean_card" == *'http://localhost:3001'* ]] \
    || { echo '[FAIL] Lean Mac success card did not point chat to Portal' >&2; exit 1; }
[[ "$lean_card" != *'http://localhost:3000'* && "$lean_card" == *'http://your-ip:3011'* \
    && "$lean_card" != *'http://your-ip:3001'* ]] \
    || { echo '[FAIL] Lean Mac success card did not use the signed-in Dashboard network port' >&2; exit 1; }

printf 'BIND_ADDRESS=0.0.0.0\nDASHBOARD_REMOTE_PORT=38444\n' > "$ODS_HOME/.env"
custom_port_card="$(show_success_card 3000 3001)"
[[ "$custom_port_card" == *'http://localhost:3001'* && "$custom_port_card" == *'http://your-ip:38444'* ]] \
    || { echo '[FAIL] Lean Mac success card ignored the configured Dashboard network port' >&2; exit 1; }
printf 'BIND_ADDRESS=0.0.0.0\n' > "$ODS_HOME/.env"

ENABLE_OPEN_WEBUI=true
webui_card="$(show_success_card 3000 3001)"
[[ "$webui_card" == *'Chat UI:'* && "$webui_card" == *'http://localhost:3000'* \
    && "$webui_card" == *'http://your-ip:3000'* ]] \
    || { echo '[FAIL] Selected Mac WebUI did not keep its chat links' >&2; exit 1; }

echo "[PASS] macOS installer presentation preserves the six-phase plain-output contract"