krallen-skills/forgejo-instance-setup/scripts/bootstrap-tea.sh

52 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
# bootstrap-tea.sh — Install tea CLI and configure git for Forgejo
# Usage: ./bootstrap-tea.sh
set -euo pipefail
INSTANCE="${1:-}"
TOKEN="${2:-}"
echo "=== Installing tea CLI ==="
VERSION=$(curl -s https://dl.gitea.com/tea/ | grep -oP 'href="\K[\d.]+(?=/")' | sort -V | tail -1)
echo "Latest version: $VERSION"
if [ -w /usr/local/bin ]; then
TARGET=/usr/local/bin/tea
else
TARGET="$HOME/.local/bin/tea"
mkdir -p "$HOME/.local/bin"
echo "Installing to $TARGET (no sudo)"
fi
curl -sL -o "$TARGET" "https://dl.gitea.com/tea/$VERSION/tea-${VERSION}-linux-amd64"
chmod +x "$TARGET"
echo "tea installed: $(tea --version)"
echo ""
echo "=== Git Config ==="
git config --global user.name "Hector Bot"
git config --global user.email "hector-bot@botreasury"
git config --global init.defaultBranch main
echo "Git configured."
if [ -n "$INSTANCE" ] && [ -n "$TOKEN" ]; then
echo ""
echo "=== Creating tea config ==="
mkdir -p "$HOME/.config/tea"
cat > "$HOME/.config/tea/config.yml" <<EOF
logins:
- name: forgejo
url: https://$INSTANCE
token: $TOKEN
default: true
ssh_host: $INSTANCE
user: hector-bot
created: $(date +%s)
EOF
echo "Config written. Testing..."
tea whoami || echo "Connection failed — check token and instance URL"
fi
echo ""
echo "=== Done ==="