Add init-project script for easy project initialization
- Automatically creates project directory - Initializes git repo with correct config - Configures Gitea remote automatically - Prevents asking for remote URL (fixes agent behavior) - Usage: init-project <project-name>
This commit is contained in:
60
scripts/init-project.sh
Executable file
60
scripts/init-project.sh
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
# Initialize a new VPS project with automatic Gitea remote configuration
|
||||
#
|
||||
# Usage: init-project <project-name>
|
||||
# Example: init-project my-app
|
||||
#
|
||||
# This script:
|
||||
# - Creates a new project directory
|
||||
# - Initializes git repository
|
||||
# - Configures Gitea remote automatically
|
||||
# - Sets up git user info
|
||||
|
||||
set -e
|
||||
|
||||
PROJECT_NAME="${1:?Error: Project name required. Usage: init-project <project-name>}"
|
||||
|
||||
# Verify valid project name
|
||||
if [[ ! "$PROJECT_NAME" =~ ^[a-zA-Z0-9._-]+$ ]]; then
|
||||
echo "❌ Invalid project name: $PROJECT_NAME"
|
||||
echo " Use only alphanumeric characters, dots, hyphens, and underscores"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GITEA_URL="http://100.120.125.113:3000"
|
||||
GITEA_ORG="pdm"
|
||||
REPO_URL="$GITEA_URL/$GITEA_ORG/$PROJECT_NAME.git"
|
||||
|
||||
# Check if directory already exists
|
||||
if [[ -d "$PROJECT_NAME" ]]; then
|
||||
echo "❌ Directory already exists: $PROJECT_NAME"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📁 Creating project directory: $PROJECT_NAME"
|
||||
mkdir -p "$PROJECT_NAME"
|
||||
cd "$PROJECT_NAME"
|
||||
|
||||
echo "🔧 Initializing git repository..."
|
||||
git init
|
||||
git config user.name "Homelab Automation"
|
||||
git config user.email "automation@homelab"
|
||||
git branch -M main
|
||||
|
||||
echo "🔗 Configuring Gitea remote..."
|
||||
git remote add origin "$REPO_URL"
|
||||
|
||||
echo ""
|
||||
echo "✅ Project initialized successfully!"
|
||||
echo ""
|
||||
echo "📋 Project Details:"
|
||||
echo " Name: $PROJECT_NAME"
|
||||
echo " Directory: $(pwd)"
|
||||
echo " Remote: $REPO_URL"
|
||||
echo " Branch: main"
|
||||
echo ""
|
||||
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: ~/.homelab-agents/agents/sysadmin-session-closer.md"
|
||||
echo " 4. Agent will automatically commit and push to Gitea"
|
||||
Reference in New Issue
Block a user