#!/bin/bash # Coderaft DEV — bootstrap (servi par install-dev.coderaft.io) set -e echo "" echo " ╔══════════════════════════════════════════╗" echo " ║ CodeRaft Platform — DEV bootstrap ║" echo " ║ beta whitelistée ║" echo " ╚══════════════════════════════════════════╝" echo "" if [ -z "${CODERAFT_DEV_PAT:-}" ]; then if [ -t 0 ]; then read -r -s -p " GitHub PAT (scopes: read:user + read:packages + accès repo coderaft-installer-dev) : " CODERAFT_DEV_PAT echo "" else echo " ✗ stdin non-interactif. Lance avec :" echo " CODERAFT_DEV_PAT=ghp_xxx bash <(curl -fsSL https://install-dev.coderaft.io)" exit 1 fi fi [ -z "$CODERAFT_DEV_PAT" ] && { echo " ✗ Pas de PAT, abandon"; exit 1; } export CODERAFT_DEV_PAT USER_LOGIN=$(curl -sf -H "Authorization: token $CODERAFT_DEV_PAT" -H "Accept: application/vnd.github+json" https://api.github.com/user 2>/dev/null | python3 -c "import sys,json try: d=json.load(sys.stdin); print(d.get('login','')) except: print('')" 2>/dev/null) [ -z "$USER_LOGIN" ] && { echo " ✗ PAT invalide. Contact: contact@coderaft.io"; exit 1; } echo " ✓ PAT valide pour: $USER_LOGIN" HTTP=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $CODERAFT_DEV_PAT" https://api.github.com/repos/LiamJ74/coderaft-installer-dev) if [ "$HTTP" != "200" ]; then echo " ✗ Pas d'accès au repo LiamJ74/coderaft-installer-dev (HTTP $HTTP)." echo " Le PAT doit inclure ce repo dans 'Repository access' (fine-grained)." exit 1 fi echo " ✓ Accès repo coderaft-installer-dev OK" TMP=$(mktemp -d) trap "rm -rf $TMP" EXIT echo " ▶ Téléchargement scripts (tarball)..." curl -sfL -H "Authorization: token $CODERAFT_DEV_PAT" \ "https://api.github.com/repos/LiamJ74/coderaft-installer-dev/tarball/master" \ | tar xz -C "$TMP" --strip-components=1 echo " ✓ Scripts récupérés" cd "$TMP" chmod +x install.sh scripts/*.sh lib/*.sh 2>/dev/null || true echo " ▶ Exécution install.sh" exec bash install.sh