#!/bin/bash # Quick Environment Setup Script for Linux/Mac # Usage: source setup_env.sh or . setup_env.sh echo "IITM LLM Quiz Solver - Environment Setup" echo "========================================" echo "" # Check if variables are already set if [ -n "$QUIZ_SECRET" ]; then echo "✓ QUIZ_SECRET is already set" else echo "QUIZ_SECRET is not set" read -p "Enter your QUIZ_SECRET (or press Enter to generate one): " secret if [ -z "$secret" ]; then # Generate a random secret secret=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))" 2>/dev/null || openssl rand -base64 24) echo "Generated secret: $secret" fi export QUIZ_SECRET="$secret" echo "✓ QUIZ_SECRET set for this session" fi if [ -n "$OPENAI_API_KEY" ]; then echo "✓ OPENAI_API_KEY is already set" else echo "OPENAI_API_KEY is not set (optional)" read -p "Enter your OPENAI_API_KEY (or press Enter to skip): " key if [ -n "$key" ]; then export OPENAI_API_KEY="$key" echo "✓ OPENAI_API_KEY set for this session" fi fi echo "" echo "Environment variables configured!" echo "" echo "To make these permanent, add to ~/.bashrc or ~/.zshrc:" echo "export QUIZ_SECRET=\"$QUIZ_SECRET\"" if [ -n "$OPENAI_API_KEY" ]; then echo "export OPENAI_API_KEY=\"$OPENAI_API_KEY\"" fi echo "" echo "To start the server, run:" echo "python -m app.main"