Compare commits

...

2 Commits

Author SHA1 Message Date
gitprov a4b034d4b4 Removing python dependcy on host 2026-04-11 13:35:35 +02:00
gitprov 4460bee57b Adding better ordering and support for the clone behaviour 2026-04-11 13:22:26 +02:00
+86 -35
View File
@@ -4,8 +4,8 @@
# Run once after cloning. Handles everything that can be automated:
# - Ollama install + model pulls
# - SSH key generation (tunnel key + Gitea key)
# - gutasktool clone + install
# - Docker containers
# - gutasktool clone (into agent-zero-data, mounted into the agent0 container)
# - Docker containers (gutasktool installed inside agent0 container)
#
# After this script: add two SSH keys (printed at the end), then open
# https://agent0.glitch.university and enter your API keys in Settings.
@@ -14,7 +14,7 @@ set -euo pipefail
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
OS="$(uname -s)"
GUTASK_DIR="${HOME}/gutasktool"
GUTASK_DIR="${REPO_DIR}/agent-zero-data/gutasktool"
GITEA_HOST="ramanujan.glitch.university"
GITEA_PORT=2222
VPS_HOST="glitch.university"
@@ -35,19 +35,23 @@ command -v ssh-keygen >/dev/null 2>&1 || { echo "ssh-keygen not found."; exit 1
command -v ssh-keyscan >/dev/null 2>&1 || { echo "ssh-keyscan not found."; exit 1; }
docker compose version >/dev/null 2>&1 || { echo "docker compose not found."; exit 1; }
if ! command -v python3 >/dev/null 2>&1; then
echo "python3 not found. Install Python 3.9+ first."
exit 1
fi
PY_VERSION=$(python3 -c "import sys; print(sys.version_info.minor)")
if [[ "$PY_VERSION" -lt 9 ]]; then
echo "Python 3.9+ required (found 3.${PY_VERSION})."
exit 1
fi
info "Prerequisites OK"
# ── Credentials (collected upfront before any private repo clones) ─────────────
section "Credentials"
echo ""
prompt "Enter CONTENT_API_KEY for glitch.university (find it in the VPS .env): "
read -r -s CONTENT_API_KEY
echo ""
echo ""
prompt "Enter Gitea personal access token (needs repo read access — create at https://${GITEA_HOST}/user/settings/applications): "
read -r -s GITEA_TOKEN_BOOTSTRAP
echo ""
info "Credentials collected"
# ── Ollama ────────────────────────────────────────────────────────────────────
section "Ollama"
@@ -80,22 +84,66 @@ else
fi
fi
# Returns 0 if model is already pulled, 1 if not
model_installed() {
ollama list 2>/dev/null | awk 'NR>1 {print $1}' | grep -qx "$1"
}
pull_model() {
local model="$1"
if model_installed "$model"; then
info "Already downloaded: $model"
else
info "Pulling $model..."
ollama pull "$model"
fi
}
echo ""
echo " Default models to pull (you can skip any):"
echo " [1] qwen2.5-coder:7b (~5 GB) fast coding model"
echo " [2] qwen2.5-coder:32b (~20 GB) — strong coding model"
echo " [3] qwen2.5:72b (~45 GB) — general reasoning"
echo " [4] deepseek-r1:70b (~43 GB) — chain-of-thought"
echo " ── Coding ──────────────────────────────────────"
echo " [1] qwen2.5-coder:7b ~5 GB fast, good for quick tasks"
echo " [2] qwen2.5-coder:32b ~20 GB strong coding (recommended)"
echo " [3] qwen2.5-coder:72b ~45 GB best coding quality"
echo " [4] deepseek-coder-v2:16b ~9 GB strong alternative"
echo ""
prompt "Which models to pull? (e.g. 1 2 or Enter to skip all): "
echo " ── General ─────────────────────────────────────"
echo " [5] llama3.1:8b ~5 GB fast general-purpose"
echo " [6] llama3.1:70b ~40 GB strong general-purpose"
echo " [7] mistral:7b ~4 GB fast, widely used"
echo " [8] mixtral:8x7b ~26 GB MoE, strong at instruction following"
echo " [9] gemma2:9b ~6 GB Google, good at reasoning"
echo " [10] gemma2:27b ~16 GB Google, stronger"
echo " [11] qwen2.5:72b ~45 GB strong general + multilingual"
echo ""
echo " ── Reasoning ───────────────────────────────────"
echo " [12] deepseek-r1:7b ~5 GB chain-of-thought, fast"
echo " [13] deepseek-r1:32b ~20 GB chain-of-thought, strong"
echo " [14] deepseek-r1:70b ~43 GB chain-of-thought, best"
echo ""
prompt "Which models to pull? (e.g. 1 3 7 or 'all' or Enter to skip): "
read -r MODEL_CHOICES
# Expand 'all' to full list
if [[ "$MODEL_CHOICES" == "all" ]]; then
MODEL_CHOICES="1 2 3 4 5 6 7 8 9 10 11 12 13 14"
fi
for choice in $MODEL_CHOICES; do
case "$choice" in
1) info "Pulling qwen2.5-coder:7b..."; ollama pull qwen2.5-coder:7b ;;
2) info "Pulling qwen2.5-coder:32b..."; ollama pull qwen2.5-coder:32b ;;
3) info "Pulling qwen2.5:72b..."; ollama pull qwen2.5:72b ;;
4) info "Pulling deepseek-r1:70b..."; ollama pull deepseek-r1:70b ;;
1) pull_model "qwen2.5-coder:7b" ;;
2) pull_model "qwen2.5-coder:32b" ;;
3) pull_model "qwen2.5-coder:72b" ;;
4) pull_model "deepseek-coder-v2:16b" ;;
5) pull_model "llama3.1:8b" ;;
6) pull_model "llama3.1:70b" ;;
7) pull_model "mistral:7b" ;;
8) pull_model "mixtral:8x7b" ;;
9) pull_model "gemma2:9b" ;;
10) pull_model "gemma2:27b" ;;
11) pull_model "qwen2.5:72b" ;;
12) pull_model "deepseek-r1:7b" ;;
13) pull_model "deepseek-r1:32b" ;;
14) pull_model "deepseek-r1:70b" ;;
esac
done
@@ -122,12 +170,18 @@ mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
if [[ -f "$GITEA_KEY" ]]; then
info "Gitea key already exists"
info "Gitea key already exists (local only — verify it is registered on the server)"
else
ssh-keygen -t ed25519 -f "$GITEA_KEY" -C "gunnar@$(hostname)" -N ""
info "Gitea key generated at ${GITEA_KEY}"
fi
echo ""
echo " This public key must be registered at https://${GITEA_HOST} → Settings → SSH Keys:"
echo ""
echo " $(cat "${GITEA_KEY}.pub")"
echo ""
# Add Gitea to known_hosts to avoid interactive prompt during git operations
if ! ssh-keygen -F "[${GITEA_HOST}]:${GITEA_PORT}" -f "${HOME}/.ssh/known_hosts" >/dev/null 2>&1; then
ssh-keyscan -p "$GITEA_PORT" "$GITEA_HOST" >> "${HOME}/.ssh/known_hosts" 2>/dev/null || true
@@ -149,26 +203,20 @@ fi
# ── gutasktool ────────────────────────────────────────────────────────────────
section "gutasktool"
mkdir -p "${REPO_DIR}/agent-zero-data"
if [[ -d "$GUTASK_DIR" ]]; then
info "gutasktool already at ${GUTASK_DIR}"
else
info "Cloning gutasktool..."
git clone "ssh://git@${GITEA_HOST}:${GITEA_PORT}/glitch-university/gutasktool.git" "$GUTASK_DIR" \
|| git clone "https://${GITEA_HOST}/glitch-university/gutasktool.git" "$GUTASK_DIR"
|| git clone "https://oauth2:${GITEA_TOKEN_BOOTSTRAP}@${GITEA_HOST}/glitch-university/gutasktool.git" "$GUTASK_DIR"
fi
info "Installing gutasktool..."
(cd "$GUTASK_DIR" && pip3 install -e . --quiet)
info "gutask installed ($(gutask --version 2>/dev/null || echo 'ok'))"
if [[ ! -f "${GUTASK_DIR}/.env" ]]; then
echo ""
prompt "Enter CONTENT_API_KEY for glitch.university (find it in the VPS .env): "
read -r -s API_KEY
echo ""
cat > "${GUTASK_DIR}/.env" << EOF
API_URL=https://glitch.university
CONTENT_API_KEY=${API_KEY}
CONTENT_API_KEY=${CONTENT_API_KEY}
GITEA_URL=https://${GITEA_HOST}
GITEA_OWNER=glitch-university
# AGENT_ID, AGENT_NAME, AGENT_PASSWORD, and GITEA_TOKEN are per-agent.
@@ -189,6 +237,9 @@ docker compose build --quiet
info "Starting containers..."
docker compose up -d
info "Installing gutasktool inside agent0 container..."
docker exec agent0 pip install -e /a0/usr/gutasktool --quiet
echo ""
docker compose ps