#!/bin/bash # Configuration script for Edge GitOps set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' echo -e "${BLUE}=== Edge GitOps Configuration ===${NC}" echo "" # Function to update configuration files update_config() { local file=$1 local key=$2 local value=$3 if [ -f "$file" ]; then sed -i "s|$key|$value|g" "$file" echo -e "${GREEN}✓ Updated $file${NC}" else echo -e "${RED}✗ File not found: $file${NC}" fi } # Get Gitea URL echo -e "${YELLOW}Enter your Gitea repository URL:${NC}" read -p "URL (default: ssh://git@gitea.example.com/edge-gitops/edge-gitops.git): " GITEA_URL GITEA_URL=${GITEA_URL:-ssh://git@gitea.example.com/edge-gitops/edge-gitops.git} # Get branch name echo -e "${YELLOW}Enter your branch name:${NC}" read -p "Branch (default: main): " GITEA_BRANCH GITEA_BRANCH=${GITEA_BRANCH:-main} # Get cluster name echo -e "${YELLOW}Enter your cluster name:${NC}" read -p "Cluster name (default: k3s-dgx): " CLUSTER_NAME CLUSTER_NAME=${CLUSTER_NAME:-k3s-dgx} echo "" echo -e "${BLUE}Configuration Summary:${NC}" echo " Gitea URL: $GITEA_URL" echo " Branch: $GITEA_BRANCH" echo " Cluster: $CLUSTER_NAME" echo "" read -p "Apply these settings? (y/n) " -n 1 -r echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Aborting..." exit 0 fi # Update configuration files echo -e "${YELLOW}Updating configuration files...${NC}" update_config "clusters/k3s-dgx/flux-system/gotk-sync.yaml" \ "ssh://git@gitea.example.com/edge-gitops/edge-gitops.git" \ "$GITEA_URL" update_config "clusters/k3s-dgx/flux-system/gotk-sync.yaml" \ "branch: main" \ "branch: $GITEA_BRANCH" # Create environment file cat > .env << EOF GITEA_URL=$GITEA_URL GITEA_BRANCH=$GITEA_BRANCH CLUSTER_NAME=$CLUSTER_NAME EOF echo -e "${GREEN}✓ Created .env file${NC}" echo "" echo -e "${GREEN}=== Configuration Complete ===${NC}" echo "" echo "Next steps:" echo "1. Review the changes: git diff" echo "2. Commit the changes: git add . && git commit -m 'Configure GitOps settings'" echo "3. Push to repository: git push origin $GITEA_BRANCH" echo "4. Run bootstrap: ./bootstrap.sh" echo ""