40 lines
1.7 KiB
Batchfile
40 lines
1.7 KiB
Batchfile
@echo off
|
|
setlocal EnableDelayedExpansion
|
|
title Campus - roll back the last fast deploy
|
|
|
|
REM ============================================================================
|
|
REM Puts back the assembly UploadUpdate.bat replaced (CampusServer.dll.prev).
|
|
REM One deep - it undoes the most recent fast deploy, not a chain of them.
|
|
REM ============================================================================
|
|
|
|
set "ROOT=%~dp0"
|
|
set "VPS=root@50.114.179.17"
|
|
set "REMOTE=/opt/campus"
|
|
|
|
if not exist "%ROOT%Password.txt" (echo [x] Cannot find %ROOT%Password.txt & goto :fail)
|
|
set "PW="
|
|
for /f "usebackq delims=" %%p in ("%ROOT%Password.txt") do if not defined PW set "PW=%%p"
|
|
if not defined PW (echo [x] Password.txt is empty. & goto :fail)
|
|
|
|
echo.
|
|
echo Rolling %VPS% back to the previous CampusServer.dll ...
|
|
echo.
|
|
|
|
plink -batch -pw %PW% %VPS% "set -e; test -f %REMOTE%/CampusServer.dll.prev || { echo 'No CampusServer.dll.prev - nothing to roll back to.'; exit 1; }; systemctl stop campus; mv %REMOTE%/CampusServer.dll %REMOTE%/CampusServer.dll.rolledback; mv %REMOTE%/CampusServer.dll.prev %REMOTE%/CampusServer.dll; systemctl start campus; sleep 12; systemctl is-active --quiet campus || { echo 'SERVICE IS NOT RUNNING'; journalctl -u campus -n 30 --no-pager; exit 1; }; journalctl -u campus --since '-2min' --no-pager | grep -E 'Now listening' | tail -3"
|
|
if errorlevel 1 (echo. & echo [x] Rollback FAILED. & goto :fail)
|
|
|
|
echo.
|
|
echo === ROLLED BACK ============================================================
|
|
echo.
|
|
echo The assembly that was live is kept as CampusServer.dll.rolledback.
|
|
echo.
|
|
endlocal
|
|
exit /b 0
|
|
|
|
:fail
|
|
echo.
|
|
echo === FAILED =================================================================
|
|
echo.
|
|
endlocal
|
|
exit /b 1
|