|
@echo off
|
|
|
|
:: Define variables
|
|
set IMAGE_NAME=SaprotHubImage.tar
|
|
set CONTAINER_NAME=SaprotHubLocal
|
|
set PORT=12315
|
|
set DIRECTORY_PATH=/root/SaprotHub/local_server
|
|
set IMAGE_TAG=saprothub_image
|
|
|
|
:: Check if Docker is installed
|
|
where docker >nul 2>nul
|
|
if %errorlevel% neq 0 (
|
|
echo Docker is not installed. Please install Docker Desktop first.
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
:waitForDocker
|
|
echo Checking if Docker is ready...
|
|
docker info >nul 2>nul
|
|
if %errorlevel% neq 0 (
|
|
echo Docker is not running. Please start Docker Desktop.
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
:: Check if Docker image exists
|
|
echo Checking if Docker image exists...
|
|
docker images | findstr %IMAGE_TAG% >nul
|
|
if errorlevel 1 (
|
|
echo The image does not exist, importing the image...
|
|
docker load -i %IMAGE_NAME%
|
|
if errorlevel 1 (
|
|
echo Failed to import Docker image.
|
|
pause
|
|
exit /b
|
|
)
|
|
) else (
|
|
echo The image already exists.
|
|
)
|
|
|
|
:: Check if Docker container exists
|
|
echo Checking if Docker container exists...
|
|
docker ps -a | findstr %CONTAINER_NAME% >nul
|
|
if errorlevel 1 (
|
|
echo The container does not exist, creating and starting the container...
|
|
docker run -d --name %CONTAINER_NAME% -p %PORT%:12315 %IMAGE_TAG% /bin/bash -c "while true; do sleep 1000; done"
|
|
if errorlevel 1 (
|
|
echo Failed to create and start Docker container.
|
|
pause
|
|
exit /b
|
|
)
|
|
) else (
|
|
echo The container already exists, starting the container...
|
|
docker start %CONTAINER_NAME%
|
|
if errorlevel 1 (
|
|
echo Failed to start Docker container.
|
|
pause
|
|
exit /b
|
|
)
|
|
)
|
|
|
|
:: Enter the Docker container and start a bash shell
|
|
echo Entering the Docker container and starting bash shell...
|
|
docker exec -it %CONTAINER_NAME% /bin/bash
|
|
if errorlevel 1 (
|
|
echo Failed to start bash shell inside the Docker container.
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
echo Now inside the Docker container. Run the following commands manually:
|
|
echo chmod +x %DIRECTORY_PATH%/run.sh
|
|
echo cd %DIRECTORY_PATH%
|
|
echo ./run.sh
|
|
pause
|
|
|