-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·130 lines (103 loc) · 4.39 KB
/
install.sh
File metadata and controls
executable file
·130 lines (103 loc) · 4.39 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
set -euo pipefail
# =============================================================================
# ZeroInc — One-Command Install
# Clones the repo, generates secrets, builds Docker images, and starts services.
# Usage: curl -fsSL https://raw.githubusercontent.com/agentxagi/zero-inc/master/install.sh | bash
# =============================================================================
REPO_URL="${REPO_URL:-https://github.com/agentxagi/zero-inc.git}"
CLONE_DIR="${CLONE_DIR:-zero-inc}"
BRANCH="${BRANCH:-master}"
TIMEOUT="${TIMEOUT:-600}"
info() { printf '\033[1;34m[INFO]\033[0m %s\n' "$*"; }
ok() { printf '\033[1;32m[OK]\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m[WARN]\033[0m %s\n' "$*"; }
fail() { printf '\033[1;31m[ERROR]\033[0m %s\n' "$*"; exit 1; }
# --- Prerequisites -----------------------------------------------------------
for cmd in git docker; do
command -v "$cmd" &>/dev/null || fail "'$cmd' is required but not found. Install it first."
done
docker compose version &>/dev/null || fail "'docker compose' (V2) is required."
if docker info 2>/dev/null | grep -q "rootless\|root"; then
ok "Docker daemon is running."
else
fail "Docker daemon is not running. Start it with: sudo systemctl start docker"
fi
# --- Clone -------------------------------------------------------------------
if [ -d "$CLONE_DIR" ]; then
info "Directory '$CLONE_DIR' already exists — pulling latest."
git -C "$CLONE_DIR" pull --ff-only || warn "Could not pull latest. Using existing checkout."
else
info "Cloning ZeroInc from $REPO_URL (branch: $BRANCH)..."
git clone --branch "$BRANCH" --depth 1 "$REPO_URL" "$CLONE_DIR"
fi
cd "$CLONE_DIR"
ok "Repository ready at $(pwd)"
# --- Generate .env -----------------------------------------------------------
if [ -f .env ]; then
warn ".env already exists — skipping generation. Edit .env to update secrets."
else
info "Generating .env with random secrets..."
AUTH_SECRET="$(openssl rand -base64 32)"
DB_PASSWORD="$(openssl rand -base64 24)"
cat > .env <<EOF
# Auto-generated by install.sh on $(date -u +%Y-%m-%dT%H:%M:%SZ)
# Change these values for production!
BETTER_AUTH_SECRET=${AUTH_SECRET}
POSTGRES_PASSWORD=${DB_PASSWORD}
POSTGRES_USER=zeroinc
POSTGRES_DB=zeroinc
POSTGRES_PORT=5432
PAPERCLIP_PUBLIC_URL=http://localhost:3100
PAPERCLIP_PORT=3100
PAPERCLIP_DEPLOYMENT_MODE=authenticated
PAPERCLIP_DEPLOYMENT_EXPOSURE=private
OPENAI_API_KEY=
ANTHROPIC_API_KEY=
EOF
ok ".env created with generated secrets."
fi
# --- Build -------------------------------------------------------------------
info "Building Docker images (this may take a few minutes)..."
timeout "$TIMEOUT" docker compose build \
|| fail "Docker build failed. Check the output above for errors."
ok "Docker build complete."
# --- Start -------------------------------------------------------------------
info "Starting services..."
docker compose up -d \
|| fail "Failed to start services. Run 'docker compose logs' to diagnose."
# --- Health Check ------------------------------------------------------------
info "Waiting for services to become healthy..."
MAX_WAIT=60
ELAPSED=0
until curl -sf http://localhost:${PAPERCLIP_PORT:-3100}/api/health >/dev/null 2>&1; do
sleep 2
ELAPSED=$((ELAPSED + 2))
if [ "$ELAPSED" -ge "$MAX_WAIT" ]; then
warn "Server did not respond within ${MAX_WAIT}s. Check logs: docker compose logs server"
break
fi
done
if curl -sf http://localhost:${PAPERCLIP_PORT:-3100}/api/health >/dev/null 2>&1; then
ok "ZeroInc is up and healthy."
else
warn "Health check not ready yet. This is normal on first start (DB migration in progress)."
fi
# --- Done --------------------------------------------------------------------
cat <<'SUMMARY'
===========================================================================
ZeroInc is running!
===========================================================================
Dashboard: http://localhost:3100
Next steps:
1. Open the URL above in your browser
2. Create your admin account
3. Add your AI provider API keys in the dashboard
Useful commands:
docker compose logs -f # Follow all logs
docker compose logs -f server # Server logs only
docker compose ps # Check service status
docker compose down # Stop everything
docker compose up -d # Start again
See doc/DEPLOY.md for the full deployment guide.
SUMMARY