cscsj/gemini-business2api
0
1@echo off
2REM Gemini Business2API Deployment Script for Windows
3REM This script automates the initial deployment process
4
5setlocal enabledelayedexpansion
6
7echo ==========================================
8echo Gemini Business2API Deployment Script
9echo ==========================================
10echo.
11
12REM Check if git is installed
13where git >nul 2>nul
14if %errorlevel% neq 0 (
15 echo [ERROR] Git is not installed. Please install git first.
16 exit /b 1
17)
18
19REM Check if python is installed
20where python >nul 2>nul
21if %errorlevel% neq 0 (
22 echo [ERROR] Python is not installed. Please install Python 3.11+ first.
23 exit /b 1
24)
25
26REM Check if npm is installed
27where npm >nul 2>nul
28if %errorlevel% neq 0 (
29 echo [ERROR] npm is not installed. Please install Node.js and npm first.
30 exit /b 1
31)
32
33REM Step 1: Build frontend
34echo [STEP] Step 1: Building frontend...
35if exist "frontend" (
36 cd frontend
37 echo [INFO] Installing frontend dependencies...
38 call npm install
39 if %errorlevel% neq 0 (
40 echo [ERROR] Failed to install frontend dependencies
41 exit /b 1
42 )
43
44 echo [INFO] Building frontend...
45 call npm run build
46 if %errorlevel% neq 0 (
47 echo [ERROR] Failed to build frontend
48 exit /b 1
49 )
50
51 echo [SUCCESS] Frontend built successfully
52 cd ..
53) else (
54 echo [ERROR] Frontend directory not found. Are you in the project root?
55 exit /b 1
56)
57
58REM Step 2: Create virtual environment
59echo [STEP] Step 2: Setting up Python virtual environment...
60if exist ".venv" (
61 echo [INFO] Virtual environment already exists, skipping creation
62) else (
63 echo [INFO] Creating virtual environment...
64 python -m venv .venv
65 if %errorlevel% neq 0 (
66 echo [ERROR] Failed to create virtual environment
67 exit /b 1
68 )
69 echo [SUCCESS] Virtual environment created
70)
71
72REM Activate virtual environment
73echo [INFO] Activating virtual environment...
74call .venv\Scripts\activate.bat
75
76REM Step 3: Install Python dependencies
77echo [STEP] Step 3: Installing Python dependencies...
78python -m pip install --upgrade pip
79python -m pip install -r requirements.txt
80if %errorlevel% neq 0 (
81 echo [ERROR] Failed to install Python dependencies
82 exit /b 1
83)
84echo [SUCCESS] Python dependencies installed
85
86REM Step 4: Setup .env file
87echo [STEP] Step 4: Setting up configuration...
88if exist ".env" (
89 echo [INFO] .env file already exists, skipping
90) else (
91 if exist ".env.example" (
92 copy /Y ".env.example" ".env" >nul
93 echo [SUCCESS] .env file created from .env.example
94 ) else (
95 echo [ERROR] .env.example not found
96 exit /b 1
97 )
98)
99
100REM Step 5: Show completion message
101echo.
102echo ==========================================
103echo [SUCCESS] Deployment completed successfully!
104echo ==========================================
105echo.
106echo [INFO] Next steps:
107echo.
108echo 1. Edit .env file and set your ADMIN_KEY:
109echo notepad .env
110echo.
111echo 2. Start the service:
112echo python main.py
113echo.
114echo 3. Access the admin panel:
115echo http://localhost:7860/
116echo.
117echo [INFO] Optional: To activate virtual environment later, run:
118echo .venv\Scripts\activate.bat
119echo.
120
121endlocal
122 