#!/bin/bash # Foxhunt Runpod Configuration Validator # Checks terraform.tfvars for common issues before deployment set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' ERRORS=0 WARNINGS=0 log_error() { echo -e "${RED}[ERROR]${NC} $1" ((ERRORS++)) } log_warning() { echo -e "${YELLOW}[WARNING]${NC} $1" ((WARNINGS++)) } log_success() { echo -e "${GREEN}[OK]${NC} $1" } log_info() { echo -e "${BLUE}[INFO]${NC} $1" } echo "===========================================" echo "Foxhunt Runpod Configuration Validator" echo "===========================================" echo "" # Check if terraform.tfvars exists if [ ! -f "terraform.tfvars" ]; then log_error "terraform.tfvars not found!" echo "" echo "Create it from the template:" echo " cp terraform.tfvars.example terraform.tfvars" echo " vim terraform.tfvars" exit 1 fi log_success "terraform.tfvars found" # Function to check if value is placeholder is_placeholder() { [[ "$1" == *" /dev/null; then log_success "OpenTofu is installed ($(tofu version | head -1))" elif command -v terraform &> /dev/null; then log_success "Terraform is installed ($(terraform version | head -1))" else log_error "Neither OpenTofu nor Terraform is installed" echo " Install OpenTofu: https://opentofu.org/docs/intro/install/" echo " OR Terraform: https://www.terraform.io/downloads" fi # Cost estimate echo "" echo "===========================================" echo "Estimated Monthly Cost (24/7 operation)" echo "===========================================" if [[ "$GPU_TYPE" == *"V100"* ]]; then echo "Pod (Tesla V100): \$316.80/month" elif [[ "$GPU_TYPE" == *"4090"* ]]; then echo "Pod (RTX 4090): \$496.80/month" else echo "Pod: Unknown (check Runpod pricing)" fi if [ -n "$VOLUME_SIZE" ]; then VOLUME_COST=$(echo "scale=2; $VOLUME_SIZE * 0.10" | bc) echo "Volume (${VOLUME_SIZE} GB): \$$VOLUME_COST/month" fi echo "===========================================" # Final summary echo "" if [ $ERRORS -gt 0 ]; then log_error "Found $ERRORS error(s). Fix them before deployment." exit 1 elif [ $WARNINGS -gt 0 ]; then log_warning "Found $WARNINGS warning(s). Review them before deployment." echo "" echo "To proceed anyway:" echo " ./deploy.sh plan # preview changes" echo " ./deploy.sh apply # deploy to Runpod" exit 0 else log_success "Configuration looks good!" echo "" echo "Next steps:" echo " ./deploy.sh init # initialize Terraform (first time only)" echo " ./deploy.sh plan # preview changes" echo " ./deploy.sh apply # deploy to Runpod" fi