git-sigil/gitfield-radicle
Mark Randall Havens bb60ad27f4 updated radicle
2025-05-31 01:25:49 -05:00

100 lines
3.6 KiB
Bash
Executable file

#!/bin/bash
set -euo pipefail
# ── Configuration ────────────────────────────────────────────────
REPO_NAME="git-sigil"
REMOTE_LABEL="radicle"
WORKING_DIR="$(pwd)"
METADATA_FILE=".radicle-link.md"
SCRIPT_VERSION="v1.0"
# ── Step 1: Detect Environment ───────────────────────────────────
USER_NAME="$(whoami)"
HOST_NAME="$(hostname)"
OS_INFO="$(uname -a)"
IS_WSL=$(grep -i microsoft /proc/version &>/dev/null && echo "Yes" || echo "No")
IS_DOCKER=$(grep -qa 'docker' /proc/1/cgroup && echo "Yes" || echo "No")
ARCHITECTURE="$(uname -m)"
IP_ADDR=$(hostname -I | awk '{print $1}')
MAC_ADDR=$(ip link | awk '/ether/ {print $2}' | head -n 1)
UPTIME="$(uptime -p | sed 's/up //')"
CPU_MODEL=$(lscpu | grep 'Model name' | sed 's/Model name:[ \t]*//')
TOTAL_RAM=$(free -g | awk '/^Mem:/ {print $2}')
# ── Step 2: Initialize & Push ────────────────────────────────────
rad init --name "$REPO_NAME" --description "Radicle link for $REPO_NAME"
rad push
PROJECT_ID=$(rad self | grep "Project ID" | awk '{print $NF}')
PEER_ID=$(rad self | grep "Peer ID" | awk '{print $NF}')
COMMIT_SHA=$(git rev-parse HEAD)
TREE_SHA=$(git rev-parse HEAD^{tree})
TIMESTAMP=$(date -Is)
# ── Step 3: Add Custom Seed Node ─────────────────────────────────
rad node config set seeds "[\"kairos-seed.thefoldwithin.earth:8776\"]"
# ── Step 4: Form Gateway URLs ────────────────────────────────────
GARDEN_URL="https://app.radicle.xyz/nodes/seed.radicle.garden/rad:${PROJECT_ID}"
KAIROS_URL="https://app.radicle.xyz/nodes/kairos-seed.thefoldwithin.earth/rad:${PROJECT_ID}"
RAW_URL="https://app.radicle.network/rad:${PROJECT_ID}"
# ── Step 5: Write Metadata ───────────────────────────────────────
cat > "$METADATA_FILE" <<EOF
# 🔗 Radicle Project Link Metadata
- **Repo Name**: \`$REPO_NAME\`
- **Peer ID**: \`$PEER_ID\`
- **Project ID**: \`$PROJECT_ID\`
- **Local Path**: \`$WORKING_DIR\`
- **Remote Label**: \`$REMOTE_LABEL\`
- **Default Branch**: \`master\`
- **Script Version**: \`$SCRIPT_VERSION\`
---
## 🌐 Gateway Access URLs
- Garden 🌱: [$GARDEN_URL]($GARDEN_URL)
- Kairos 🌀: [$KAIROS_URL]($KAIROS_URL)
- Raw 🔧: [$RAW_URL]($RAW_URL)
---
## 📦 Commit Metadata
- **Commit SHA**: \`$COMMIT_SHA\`
- **Tree SHA**: \`$TREE_SHA\`
- **Timestamp**: \`$TIMESTAMP\`
---
## 💻 Platform Metadata
- **User**: \`$USER_NAME\`
- **Hostname**: \`$HOST_NAME\`
- **Architecture**: \`$ARCHITECTURE\`
- **IP Address**: \`$IP_ADDR\`
- **MAC Address**: \`$MAC_ADDR\`
- **Uptime**: \`$UPTIME\`
- **CPU**: \`$CPU_MODEL\`
- **RAM (GB)**: \`$TOTAL_RAM\`
- **Running in Docker**: \`$IS_DOCKER\`
- **Running in WSL**: \`$IS_WSL\`
- **OS Info**: \`$OS_INFO\`
---
_Auto-generated by \`gitfield-radicle\` on $TIMESTAMP._
EOF
# ── Step 6: Output for Human Use ─────────────────────────────────
echo -e "\n✅ Radicle push complete for \033[1m$REPO_NAME\033[0m"
echo -e "🌱 Garden URL: \033[4m$GARDEN_URL\033[0m"
echo -e "🌀 Kairos URL: \033[4m$KAIROS_URL\033[0m"
echo -e "🔧 Raw Gateway: \033[4m$RAW_URL\033[0m"
echo -e "\n🧬 Metadata stored in: $METADATA_FILE"
echo -e "📁 Project ID: $PROJECT_ID"
echo -e "👤 Peer ID: $PEER_ID"
echo -e "🕒 Timestamp: $TIMESTAMP\n"