File size: 3,451 Bytes
bca5f6b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8f7bac2
bca5f6b
 
 
 
 
 
 
 
0829899
 
 
 
 
 
 
 
 
 
 
 
955c7b7
 
 
 
 
bca5f6b
955c7b7
bca5f6b
 
 
397ffab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5ed4ed6
397ffab
5ed4ed6
bca5f6b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
set -euo pipefail

DATA_DIR="/data"
PERSIST=0

# /data'nin gercekten baglanmis bir Storage Bucket olup olmadigini anlamak icin
# device id'sini kok dosya sistemiyle karsilastiriyoruz. Sadece "dizin var mi"
# kontrolu yaniltici olur: bucket bagli degilse bile mkdir ile ayni isimde
# gecici (restart'ta silinen) bir dizin olusabilir.
if [ -d "$DATA_DIR" ]; then
  root_dev="$(stat -c %d / 2>/dev/null || echo root)"
  data_dev="$(stat -c %d "$DATA_DIR" 2>/dev/null || echo data)"
  if [ "$root_dev" != "$data_dev" ]; then
    PERSIST=1
  fi
fi

if [ "$PERSIST" = "1" ]; then
  export HOME="$DATA_DIR/home"
  export WORKSPACE_ROOT="$DATA_DIR/workspace"
  mkdir -p "$HOME" "$WORKSPACE_ROOT"
  echo "[entrypoint] Storage Bucket algilandi -> kalicilik AKTIF (HOME=$HOME)"
else
  export HOME="${HOME:-/home/node}"
  export WORKSPACE_ROOT="$HOME/workspace"
  mkdir -p "$WORKSPACE_ROOT"
  echo "[entrypoint] UYARI: /data baglanmis bir Storage Bucket degil (ya da hic bagli degil)."
  echo "[entrypoint] Kalicilik KAPALI: container yeniden basladiginda (uyku/redeploy) TUM oturum verisi ve giris bilgisi silinecek."
fi

mkdir -p "$HOME/.claude"

# Calisirken kurulan programlar (npm install -g, uv tool install) ve MCP
# sunuculari HOME altina gider: bucket bagliyken kalici olan tek yer orasi;
# /tmp ve sistem klasorleri her yeniden baslatmada imajdaki haline doner.
# Terminal (login kabugu) ayni ayari /etc/profile.d/agentweb.sh'ten alir.
case ":$PATH:" in
  *":$HOME/.local/bin:"*) ;;
  *) export PATH="$HOME/.local/bin:$PATH" ;;
esac
export NPM_CONFIG_PREFIX="$HOME/.local"
export AGENTWEB_PERSISTENT="$PERSIST"
mkdir -p "$HOME/.local/bin" "$HOME/mcp-servers"

if ! grep -q "Agent Web terminali" "$HOME/.bashrc" 2>/dev/null; then
  # Eski surumun karsilama satirini temizle (kalici HOME'da iki kez gorunmesin).
  if [ -f "$HOME/.bashrc" ]; then
    sed -i '/Claude Code Web hazir/d' "$HOME/.bashrc"
  fi
  cat >> "$HOME/.bashrc" <<'EOF'
echo "Agent Web terminali. Claude Code'u baslatmak icin: claude"
EOF
fi

# Roblox Studio (Vinegar) destegi kaldirildi: eski surumun kalici HOME'da
# biraktigi veriyi (Wine/Studio dosyalari ve Roblox giris yedegi dahil) sil.
for old in \
  "$HOME/.config/agentweb/roblox" \
  "$HOME/.config/vinegar" \
  "$HOME/.local/share/agentweb-roblox" \
  "$HOME/.robloxstudio-mcp" \
  "$HOME/.local/state/robloxstudio-mcp"; do
  if [ -e "$old" ]; then
    rm -rf -- "$old" && echo "[entrypoint] Eski Roblox verisi silindi: $old"
  fi
done
rmdir "$HOME/.config/agentweb" 2>/dev/null || true

# git, github.com icin GitHub MCP ile ayni token'i kullansin (GH_TOKEN /
# GITHUB_TOKEN secret'i ya da `gh auth login`). Kendi ayarin varsa dokunulmaz.
helper="!/app/scripts/git-credential-github"
current_helpers="$(git config --global --get-all credential.https://github.com.helper 2>/dev/null || true)"
if [ -z "$current_helpers" ]; then
  git config --global credential.https://github.com.helper "$helper" \
    || echo "[entrypoint] UYARI: git icin GitHub kimlik yardimcisi ayarlanamadi."
fi

# MCP sunuculari (Playwright tarayici, Agent Web araclari, GitHub) her oturumda
# ayni ayarlarla: ~/.claude.json icinde kullanici kapsamli tanim. rtk: Bash
# ciktilarini kisaltan hook. Hata verirlerse uygulama yine acilir.
node /app/scripts/setup-mcp.js || echo "[entrypoint] UYARI: MCP varsayilanlari uygulanamadi."
node /app/scripts/setup-rtk.js || echo "[entrypoint] UYARI: rtk ayarlanamadi."

exec node /app/server/index.js