/ setup.sh
setup.sh
1 #!/usr/bin/env bash 2 3 # 333 Method Automation - NixOS Setup Script 4 5 set -e # Exit on error 6 7 echo "🚀 Setting up 333 Method Automation..." 8 echo "" 9 10 # Check if we're in a nix-shell 11 if [ -z "$IN_NIX_SHELL" ]; then 12 echo "❌ Not in nix-shell! Please run: nix-shell" 13 echo "" 14 echo "Then run this script again from within the nix-shell." 15 exit 1 16 fi 17 18 echo "✅ Running in nix-shell" 19 echo "" 20 21 # Step 1: Create .env if it doesn't exist 22 if [ ! -f .env ]; then 23 echo "📝 Creating .env file from template..." 24 cp .env.example .env 25 echo "⚠️ Please edit .env and add your API keys:" 26 echo " - ZENROWS_API_KEY (required for POC)" 27 echo " - OPENROUTER_API_KEY (required for POC)" 28 echo "" 29 30 # Ask if they want to edit now 31 read -p "Edit .env now? (y/n) " -n 1 -r 32 echo 33 if [[ $REPLY =~ ^[Yy]$ ]]; then 34 ${EDITOR:-nano} .env 35 fi 36 else 37 echo "✅ .env file already exists" 38 fi 39 40 echo "" 41 42 # Step 2: Install npm dependencies 43 if [ ! -d node_modules ]; then 44 echo "📦 Installing npm dependencies..." 45 npm install 46 else 47 echo "✅ node_modules already exists (run 'npm install' to update)" 48 fi 49 50 echo "" 51 52 # Step 3: Create db directory if needed 53 mkdir -p db 54 55 # Step 4: Initialize database 56 if [ ! -f db/sites.db ]; then 57 echo "🗄️ Initializing database..." 58 npm run init-db 59 else 60 echo "✅ Database already exists at db/sites.db" 61 echo " (Remove it and re-run this script to reinitialize)" 62 fi 63 64 echo "" 65 echo "✅ Setup complete!" 66 echo "" 67 echo "📖 Next steps:" 68 echo "" 69 echo "1. Ensure your API keys are set in .env" 70 echo " - ZENROWS_API_KEY" 71 echo " - OPENROUTER_API_KEY" 72 echo "" 73 echo "2. Test with 10 sites:" 74 echo " npm run poc \"plumber seattle\" 10" 75 echo "" 76 echo "3. Full POC run (1000 sites):" 77 echo " npm run poc \"plumber seattle\" 1000" 78 echo "" 79 echo "4. View database:" 80 echo " - DBeaver: Open db/sites.db" 81 echo ""