fix(infra): 6 bugs in setup.sh — jfrog sed, apt source, token fallback, log file

This commit is contained in:
saravanakumardb1 2026-03-24 11:02:16 -07:00
parent 6abf13d983
commit ddd2db848e

View File

@ -91,7 +91,7 @@ phase1_system() {
# Install essentials # Install essentials
apt-get install -y -qq \ apt-get install -y -qq \
ca-certificates curl gnupg lsb-release git jq unzip ca-certificates curl gnupg lsb-release git jq unzip iproute2
# ── Docker ───────────────────────────────────────────────────────── # ── Docker ─────────────────────────────────────────────────────────
if ! command -v docker &>/dev/null; then if ! command -v docker &>/dev/null; then
@ -101,8 +101,7 @@ phase1_system() {
| gpg --dearmor -o /etc/apt/keyrings/docker.gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg chmod a+r /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \ echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
> /etc/apt/sources.list.d/docker.list > /etc/apt/sources.list.d/docker.list
apt-get update -qq apt-get update -qq
@ -250,7 +249,7 @@ phase2_gitea() {
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"name":"vm-deploy","scopes":["write:package","read:package","write:organization","read:organization"]}') -d '{"name":"vm-deploy","scopes":["write:package","read:package","write:organization","read:organization"]}')
GITEA_NPM_TOKEN=$(echo "$token_response" | jq -r '.sha1') GITEA_NPM_TOKEN=$(echo "$token_response" | jq -r '.sha1 // .token')
if [ -z "$GITEA_NPM_TOKEN" ] || [ "$GITEA_NPM_TOKEN" = "null" ]; then if [ -z "$GITEA_NPM_TOKEN" ] || [ "$GITEA_NPM_TOKEN" = "null" ]; then
fail "Failed to create Gitea API token. Response: $token_response" fail "Failed to create Gitea API token. Response: $token_response"
fi fi
@ -299,12 +298,12 @@ phase3_clone() {
for df in "${INSTALL_DIR}"/*/backend/Dockerfile "${INSTALL_DIR}"/*/web/Dockerfile "${INSTALL_DIR}"/learning_multimodal_memory_agents/mindlyst-native/web/Dockerfile "${INSTALL_DIR}"/learning_voice_ai_agent/user-dashboard-web/Dockerfile; do for df in "${INSTALL_DIR}"/*/backend/Dockerfile "${INSTALL_DIR}"/*/web/Dockerfile "${INSTALL_DIR}"/learning_multimodal_memory_agents/mindlyst-native/web/Dockerfile "${INSTALL_DIR}"/learning_voice_ai_agent/user-dashboard-web/Dockerfile; do
[ -f "$df" ] || continue [ -f "$df" ] || continue
if grep -q 'cso\.proxy\.att\.com' "$df" 2>/dev/null; then if grep -q 'cso\.proxy\.att\.com' "$df" 2>/dev/null; then
# Remove proxy ENV lines and jfrog registry reference
sed -i \ sed -i \
-e '/HTTP_PROXY=http:\/\/cso\.proxy/d' \ -e '/HTTP_PROXY=http:\/\/cso\.proxy/d' \
-e '/HTTPS_PROXY=http:\/\/cso\.proxy/d' \ -e '/HTTPS_PROXY=http:\/\/cso\.proxy/d' \
-e '/NO_PROXY=/d' \ -e '/NO_PROXY=/d' \
-e 's|npm config set registry https://jfrog-pkg-proxy[^ ]* && ||' \ -e '/jfrog-pkg-proxy.*\\$/d' \
-e 's| && npm config set registry https://jfrog-pkg-proxy[^ ]*||' \
"$df" "$df"
patched=$((patched + 1)) patched=$((patched + 1))
fi fi
@ -602,12 +601,17 @@ HEALTH
# MAIN # MAIN
# ═══════════════════════════════════════════════════════════════════════ # ═══════════════════════════════════════════════════════════════════════
main() { main() {
# Tee all output to a log file so SSH disconnection doesn't lose context
mkdir -p "$INSTALL_DIR"
exec > >(tee -a "${INSTALL_DIR}/setup.log") 2>&1
echo "" echo ""
echo "╔═══════════════════════════════════════════════════════════════╗" echo "╔═══════════════════════════════════════════════════════════════╗"
echo "║ ByteLyst Single-VM Deployment (raw Ubuntu) ║" echo "║ ByteLyst Single-VM Deployment (raw Ubuntu) ║"
echo "║ 27 services · 10 products · Ollama · Gitea · 1 VM ║" echo "║ 27 services · 10 products · Ollama · Gitea · 1 VM ║"
echo "╚═══════════════════════════════════════════════════════════════╝" echo "╚═══════════════════════════════════════════════════════════════╝"
echo "" echo ""
log "Log file: ${INSTALL_DIR}/setup.log"
[ "$(id -u)" -eq 0 ] || fail "This script must be run as root (sudo)." [ "$(id -u)" -eq 0 ] || fail "This script must be run as root (sudo)."