#!/bin/bash set -e REMOTE_HOST="ramanujan.glitch.university" COMPONENTS_DIR="$(cd "$(dirname "$0")" && pwd)" PUSH=false [[ "$1" == "--push" ]] && PUSH=true REMOTE_BASE="ssh://git@${REMOTE_HOST}/git/repos" for dir in "$COMPONENTS_DIR"/*/; do name=$(basename "$dir") [[ "$name" == "skills" ]] && continue echo "── $name" cd "$dir" if [ ! -d ".git" ]; then git init -q git add -A git commit -q -m "Initial commit" 2>/dev/null || true echo " initialised" fi REMOTE_URL="https://${REMOTE_HOST}/${name}.git" if git remote get-url origin &>/dev/null; then git remote set-url origin "$REMOTE_URL" echo " remote updated" else git remote add origin "$REMOTE_URL" echo " remote added" fi if $PUSH; then if ssh git@"$REMOTE_HOST" create-repo "${name}.git" 2>/dev/null; then echo " remote repo ensured" else echo " remote repo may already exist" fi if git push -u origin main -q 2>/dev/null || git push -u origin master:main -q 2>/dev/null; then echo " pushed" else echo " push failed" fi fi cd "$COMPONENTS_DIR" done echo "" if $PUSH; then echo "Done." else echo "Remotes configured. Run with --push to push all, or push individually." fi