106 lines
2.4 KiB
Batchfile
106 lines
2.4 KiB
Batchfile
@echo off
|
|
REM OC Bot - Smart Update Script (Windows)
|
|
REM Usage: update.bat
|
|
REM Pulls latest code and applies only necessary changes
|
|
REM Coded by Ball Studios 🎨
|
|
|
|
setlocal enabledelayedexpansion
|
|
|
|
echo =========================================
|
|
echo OC Bot - Smart Update Script
|
|
echo Coded by Ball Studios 🎨
|
|
echo =========================================
|
|
echo.
|
|
|
|
REM Check if this is a git repository
|
|
if not exist ".git" (
|
|
echo ❌ This is not a Git repository!
|
|
echo Please clone from GitHub first
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo 📦 Checking for updates...
|
|
echo.
|
|
|
|
REM Fetch latest changes from GitHub
|
|
echo 🔄 Fetching latest code from GitHub...
|
|
git fetch origin
|
|
if errorlevel 1 (
|
|
echo ❌ Git fetch failed!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
echo ✅ Fetched latest changes
|
|
echo.
|
|
|
|
REM Check if there are updates available
|
|
for /f %%i in ('git rev-parse HEAD') do set LOCAL=%%i
|
|
for /f %%i in ('git rev-parse origin/main') do set REMOTE=%%i
|
|
|
|
if "!LOCAL!"=="!REMOTE!" (
|
|
echo ✅ Already up to date!
|
|
) else (
|
|
echo 📥 Pulling latest changes...
|
|
git pull origin main
|
|
if errorlevel 1 (
|
|
echo ❌ Git pull failed!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
echo ✅ Code updated
|
|
)
|
|
|
|
echo.
|
|
|
|
REM Check if virtual environment exists
|
|
if not exist "venv" (
|
|
echo 📦 Creating virtual environment...
|
|
python3 -m venv venv
|
|
if errorlevel 1 (
|
|
echo ❌ Failed to create virtual environment!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
echo ✅ Virtual environment created
|
|
)
|
|
|
|
REM Activate virtual environment
|
|
echo 🔧 Activating virtual environment...
|
|
call venv\Scripts\activate.bat
|
|
echo ✅ Virtual environment activated
|
|
echo.
|
|
|
|
REM Upgrade pip
|
|
echo 📦 Upgrading pip...
|
|
python -m pip install --upgrade pip >nul 2>&1
|
|
echo ✅ Pip upgraded
|
|
echo.
|
|
|
|
REM Update requirements
|
|
echo 📦 Installing/updating dependencies...
|
|
pip install --upgrade -r requirements.txt
|
|
if errorlevel 1 (
|
|
echo ❌ Failed to install dependencies!
|
|
pause
|
|
exit /b 1
|
|
)
|
|
echo ✅ Dependencies updated
|
|
echo.
|
|
|
|
echo =========================================
|
|
echo ✅ Update Complete!
|
|
echo =========================================
|
|
echo.
|
|
echo 📝 Summary:
|
|
echo - Code pulled from GitHub
|
|
echo - Dependencies updated
|
|
echo.
|
|
echo ⚠️ If database errors occur, recreate it:
|
|
echo DROP DATABASE rp_bot;
|
|
echo CREATE DATABASE rp_bot;
|
|
echo.
|
|
echo ⚙️ Next: Restart the bot to apply updates
|
|
echo.
|
|
pause
|