diff --git a/scripts/init-project.sh b/scripts/init-project.sh new file mode 100755 index 0000000..d1d20ec --- /dev/null +++ b/scripts/init-project.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Initialize a new VPS project with automatic Gitea remote configuration +# +# Usage: init-project +# 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 }" + +# 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" \ No newline at end of file