#!/bin/bash # Push to Gitea repository with token authentication set -e GITEA_URL="192.168.68.53:3000" TOKEN="77d13be9a7dbae402cb21c08d9231047a645e050" # Get username and repo name if [ -z "$1" ] || [ -z "$2" ]; then echo "Usage: $0 " echo "" echo "Example: $0 kyle ha-kiosk-dashboard" echo "" echo "This will create/push to:" echo " http://${GITEA_URL}/\$1/\$2.git" exit 1 fi USERNAME="$1" REPO_NAME="$2" REPO_URL="http://${TOKEN}@${GITEA_URL}/${USERNAME}/${REPO_NAME}.git" cd /home/kyle/scripts echo "Setting up Gitea repository..." echo "Repository: ${USERNAME}/${REPO_NAME}" echo "" # Check if git is installed if ! command -v git &> /dev/null; then echo "Installing git..." sudo apt-get update sudo apt-get install -y git fi # Initialize if needed if [ ! -d .git ]; then echo "Initializing git repository..." git init git config user.name "kyle" git config user.email "kyle@localhost" git branch -M main fi # Create .gitignore if needed if [ ! -f .gitignore ]; then cat > .gitignore << 'EOF' # Logs *.log /tmp/ # Backup files *.backup *~ # Python cache __pycache__/ *.pyc *.pyo # OS files .DS_Store Thumbs.db EOF fi # Add all files echo "Adding files..." git add -A # Commit if there are changes if ! git diff --staged --quiet; then echo "Committing changes..." git commit -m "Home Assistant kiosk dashboard setup - Dashboard YAML configurations with card-mod - Browser Mod automation for auto-scrolling - Display rotation and sleep disable scripts - Home Assistant API query scripts - Dashboard launcher scripts - Setup guides and documentation" fi # Remove existing remote if it exists git remote remove origin 2>/dev/null || true # Add remote with token authentication echo "Adding remote repository..." git remote add origin "${REPO_URL}" # Push to repository echo "Pushing to Gitea..." echo "URL: http://${GITEA_URL}/${USERNAME}/${REPO_NAME}" echo "" # Try to push (will create repo if it doesn't exist via API, or just push if it does) git push -u origin main || { echo "" echo "If the repository doesn't exist yet, create it in Gitea first:" echo " 1. Go to: http://${GITEA_URL}" echo " 2. Click 'New Repository'" echo " 3. Name: ${REPO_NAME}" echo " 4. Click 'Create Repository'" echo " 5. Then run this script again" exit 1 } echo "" echo "✓ Successfully pushed to Gitea!" echo "Repository: http://${GITEA_URL}/${USERNAME}/${REPO_NAME}"