Spaces:
Sleeping
Sleeping
| @echo off | |
| REM MongoDB & Redis Integration - Setup Script for Windows | |
| setlocal enabledelayedexpansion | |
| echo ============================================== | |
| echo MongoDB ^& Redis Integration - Setup Helper | |
| echo ============================================== | |
| echo. | |
| REM Check if .env exists | |
| if exist .env ( | |
| echo WARNING: .env file already exists! | |
| set /p "overwrite=Do you want to overwrite it? (y/N): " | |
| if /i not "!overwrite!"=="y" ( | |
| echo Setup cancelled. | |
| exit /b 1 | |
| ) | |
| ) | |
| REM Copy template | |
| echo Creating .env file from template... | |
| copy .env.example .env >nul | |
| echo. | |
| echo -------------------------------------------------- | |
| echo MongoDB Configuration | |
| echo -------------------------------------------------- | |
| echo Choose MongoDB option: | |
| echo 1^) MongoDB Atlas (cloud^) | |
| echo 2^) Local MongoDB | |
| echo 3^) Skip (configure manually later^) | |
| set /p "mongo_choice=Enter choice (1-3): " | |
| if "%mongo_choice%"=="1" ( | |
| echo. | |
| echo MongoDB Atlas Setup: | |
| echo 1. Go to https://www.mongodb.com/cloud/atlas | |
| echo 2. Create a free cluster | |
| echo 3. Create a database user | |
| echo 4. Whitelist your IP | |
| echo 5. Get your connection string | |
| echo. | |
| set /p "mongo_uri=Enter MongoDB Atlas URI: " | |
| REM Update .env file | |
| powershell -Command "(Get-Content .env) -replace 'MONGO_URI=', 'MONGO_URI=!mongo_uri!' | Set-Content .env" | |
| ) | |
| if "%mongo_choice%"=="2" ( | |
| echo. | |
| set /p "mongo_host=Enter MongoDB host (default: localhost): " | |
| if "!mongo_host!"=="" set "mongo_host=localhost" | |
| set /p "mongo_port=Enter MongoDB port (default: 27017): " | |
| if "!mongo_port!"=="" set "mongo_port=27017" | |
| set /p "mongo_db=Enter database name (default: absa-insights): " | |
| if "!mongo_db!"=="" set "mongo_db=absa-insights" | |
| set "mongo_uri=mongodb://!mongo_host!:!mongo_port!/!mongo_db!" | |
| powershell -Command "(Get-Content .env) -replace 'MONGO_URI=', 'MONGO_URI=!mongo_uri!' | Set-Content .env" | |
| ) | |
| if "%mongo_choice%"=="3" ( | |
| echo Skipping MongoDB configuration | |
| ) | |
| echo. | |
| echo -------------------------------------------------- | |
| echo Redis Configuration | |
| echo -------------------------------------------------- | |
| echo Choose Redis option: | |
| echo 1^) Redis Cloud (cloud^) | |
| echo 2^) Local Redis | |
| echo 3^) Skip (configure manually later^) | |
| set /p "redis_choice=Enter choice (1-3): " | |
| if "%redis_choice%"=="1" ( | |
| echo. | |
| echo Redis Cloud Setup: | |
| echo 1. Go to https://redis.com/try-free/ | |
| echo 2. Create a free database | |
| echo 3. Get connection details | |
| echo. | |
| set /p "redis_host=Enter Redis host: " | |
| set /p "redis_port=Enter Redis port: " | |
| set /p "redis_password=Enter Redis password: " | |
| powershell -Command "(Get-Content .env) -replace 'REDIS_HOST=localhost', 'REDIS_HOST=!redis_host!' | Set-Content .env" | |
| powershell -Command "(Get-Content .env) -replace 'REDIS_PORT=6379', 'REDIS_PORT=!redis_port!' | Set-Content .env" | |
| powershell -Command "(Get-Content .env) -replace 'REDIS_PASSWORD=', 'REDIS_PASSWORD=!redis_password!' | Set-Content .env" | |
| ) | |
| if "%redis_choice%"=="2" ( | |
| echo. | |
| set /p "redis_host=Enter Redis host (default: localhost): " | |
| if "!redis_host!"=="" set "redis_host=localhost" | |
| set /p "redis_port=Enter Redis port (default: 6379): " | |
| if "!redis_port!"=="" set "redis_port=6379" | |
| powershell -Command "(Get-Content .env) -replace 'REDIS_HOST=localhost', 'REDIS_HOST=!redis_host!' | Set-Content .env" | |
| powershell -Command "(Get-Content .env) -replace 'REDIS_PORT=6379', 'REDIS_PORT=!redis_port!' | Set-Content .env" | |
| echo No password set for local Redis | |
| ) | |
| if "%redis_choice%"=="3" ( | |
| echo Skipping Redis configuration | |
| ) | |
| echo. | |
| echo -------------------------------------------------- | |
| echo Admin Token | |
| echo -------------------------------------------------- | |
| set /p "gen_token=Generate random admin token? (Y/n): " | |
| if /i not "!gen_token!"=="n" ( | |
| REM Generate random token using PowerShell | |
| for /f %%i in ('powershell -Command "[System.Web.Security.Membership]::GeneratePassword(64,16)"') do set "admin_token=%%i" | |
| powershell -Command "(Get-Content .env) -replace 'ADMIN_TOKEN=', 'ADMIN_TOKEN=!admin_token!' | Set-Content .env" | |
| echo Admin token generated and saved to .env | |
| ) else ( | |
| echo Skipping admin token generation | |
| ) | |
| echo. | |
| echo -------------------------------------------------- | |
| echo IPinfo Token | |
| echo -------------------------------------------------- | |
| echo Get your free token from: https://ipinfo.io/signup | |
| set /p "ipinfo_token=Enter IPinfo token (or press Enter to skip): " | |
| if not "!ipinfo_token!"=="" ( | |
| powershell -Command "(Get-Content .env) -replace 'IPINFO_TOKEN=', 'IPINFO_TOKEN=!ipinfo_token!' | Set-Content .env" | |
| echo IPinfo token saved | |
| ) else ( | |
| echo Skipping IPinfo token | |
| ) | |
| echo. | |
| echo -------------------------------------------------- | |
| echo HuggingFace Token (Optional^) | |
| echo -------------------------------------------------- | |
| set /p "hf_token=Enter HuggingFace token (or press Enter to skip): " | |
| if not "!hf_token!"=="" ( | |
| powershell -Command "(Get-Content .env) -replace 'HF_TOKEN=', 'HF_TOKEN=!hf_token!' | Set-Content .env" | |
| echo HuggingFace token saved | |
| ) else ( | |
| echo Skipping HuggingFace token | |
| ) | |
| echo. | |
| echo ============================================== | |
| echo Setup Complete! | |
| echo ============================================== | |
| echo. | |
| echo Configuration saved to: .env | |
| echo. | |
| echo Next steps: | |
| echo 1. Review .env and make any adjustments | |
| echo 2. Install dependencies: pip install -r requirements-backend.txt | |
| echo 3. Start the backend: python api_server.py | |
| echo 4. Test health: curl http://localhost:7860/health | |
| echo. | |
| echo Documentation: | |
| echo - Quick Start: QUICK_START.md | |
| echo - Full Docs: MONGODB_REDIS_IMPLEMENTATION.md | |
| echo - Admin Dashboard: streamlit run admin_dashboard.py | |
| echo. | |
| echo ============================================== | |
| echo. | |
| set /p "install_deps=Install dependencies now? (Y/n): " | |
| if /i not "!install_deps!"=="n" ( | |
| echo. | |
| echo Installing dependencies... | |
| pip install -r requirements-backend.txt | |
| echo Dependencies installed! | |
| ) else ( | |
| echo Skipping dependency installation | |
| echo Remember to run: pip install -r requirements-backend.txt | |
| ) | |
| echo. | |
| echo All done! You're ready to go! | |
| echo. | |
| pause | |