57 lines
1.9 KiB
Bash
Executable File
57 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# start.sh — start Agent0 and the glitch-tunnel.
|
|
#
|
|
# Run this every time (after reboots, etc.).
|
|
# Run bootstrap.sh once first to set everything up.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
OS="$(uname -s)"
|
|
|
|
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; NC='\033[0m'
|
|
info() { echo -e "${GREEN}✓${NC} $*"; }
|
|
warn() { echo -e "${YELLOW}!${NC} $*"; }
|
|
|
|
cd "$REPO_DIR"
|
|
|
|
# ── Sanity check ──────────────────────────────────────────────────────────────
|
|
if [[ ! -f "${REPO_DIR}/.env" ]]; then
|
|
echo "No .env found. Run bootstrap.sh first."
|
|
exit 1
|
|
fi
|
|
|
|
# ── Ollama ────────────────────────────────────────────────────────────────────
|
|
if [[ "$OS" == "Linux" ]]; then
|
|
if systemctl is-active --quiet ollama 2>/dev/null; then
|
|
info "Ollama already running"
|
|
else
|
|
info "Starting Ollama..."
|
|
sudo systemctl start ollama
|
|
fi
|
|
else
|
|
if curl -sf http://localhost:11434/api/tags >/dev/null 2>&1; then
|
|
info "Ollama already running"
|
|
else
|
|
info "Starting Ollama..."
|
|
ollama serve >/tmp/ollama.log 2>&1 &
|
|
sleep 2
|
|
curl -sf http://localhost:11434/api/tags >/dev/null 2>&1 \
|
|
&& info "Ollama started" \
|
|
|| warn "Ollama didn't respond — check: ollama serve"
|
|
fi
|
|
fi
|
|
|
|
# ── Docker containers ─────────────────────────────────────────────────────────
|
|
info "Starting agent0..."
|
|
docker compose up -d agent0
|
|
|
|
info "Starting glitch-tunnel..."
|
|
docker compose up -d glitch-tunnel
|
|
|
|
echo ""
|
|
docker compose ps
|
|
|
|
echo ""
|
|
info "Agent0 is up. Open https://agent0.glitch.university"
|