Update: init-project to use SSH remotes for VPS

- Changed remote format: HTTP → SSH (git@host:org/repo.git)
- Better for VPS deployments (key-based auth)
- Check for SSH key and warn if missing
- Provide setup instructions in init output
- Agents still copied to .claude/agents/
This commit is contained in:
root
2025-11-23 22:10:12 +00:00
parent 150f67c9b9
commit 6637bb49e7

View File

@@ -7,7 +7,7 @@
# This script:
# - Creates a new project directory
# - Initializes git repository
# - Configures Gitea remote automatically
# - Configures Gitea SSH remote automatically
# - Copies agents to .claude/agents/ for Claude Code
# - Sets up git user info
@@ -22,9 +22,9 @@ if [[ ! "$PROJECT_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
exit 1
fi
GITEA_URL="http://100.120.125.113:3000"
GITEA_HOST="100.120.125.113"
GITEA_ORG="pdm"
REPO_URL="$GITEA_URL/$GITEA_ORG/$PROJECT_NAME.git"
REPO_URL="git@$GITEA_HOST:$GITEA_ORG/$PROJECT_NAME.git"
AGENTS_SOURCE="$HOME/.homelab-agents/agents"
# Check if directory already exists
@@ -33,6 +33,15 @@ if [[ -d "$PROJECT_NAME" ]]; then
exit 1
fi
# Check for SSH key (needed for git push to work)
if [[ ! -f "$HOME/.ssh/id_ed25519" ]] && [[ ! -f "$HOME/.ssh/id_rsa" ]]; then
echo "⚠️ Warning: No SSH key found"
echo " For git push to work, you need to:"
echo " 1. Generate SSH key: ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519"
echo " 2. Add to Gitea: http://100.120.125.113:3000 → Settings → SSH Keys"
echo ""
fi
echo "📁 Creating project directory: $PROJECT_NAME"
mkdir -p "$PROJECT_NAME"
cd "$PROJECT_NAME"
@@ -43,7 +52,7 @@ git config user.name "Homelab Automation"
git config user.email "automation@homelab"
git branch -M main
echo "🔗 Configuring Gitea remote..."
echo "🔗 Configuring Gitea SSH remote..."
git remote add origin "$REPO_URL"
echo "📚 Setting up Claude Code agents..."
@@ -75,4 +84,4 @@ echo "🚀 Next steps:"
echo " 1. Start working in this directory"
echo " 2. Create files and make changes"
echo " 3. When done, use the summary agent: .claude/agents/sysadmin-session-closer.md"
echo " 4. Agent will automatically commit and push to Gitea"
echo " 4. Agent will automatically commit and push to Gitea (via SSH)"