Fixing batch script for windows
This commit is contained in:
parent
05e3fb5cbf
commit
794df76f94
|
@ -10,28 +10,14 @@ docker --version >nul 2>&1
|
||||||
if %errorlevel% neq 0 (
|
if %errorlevel% neq 0 (
|
||||||
echo Docker is not installed. Please install Docker to proceed. Exiting.
|
echo Docker is not installed. Please install Docker to proceed. Exiting.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
) else (
|
|
||||||
echo Docker is already installed. Attempting to start Docker service...
|
|
||||||
net start com.docker.service >nul 2>&1
|
|
||||||
if %errorlevel% neq 0 (
|
|
||||||
echo Docker service is already running or failed to start. Moving on.
|
|
||||||
) else (
|
|
||||||
echo Docker service started successfully.
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
exit /b 0
|
|
||||||
|
|
||||||
REM Function to install Go
|
REM Function to install Go
|
||||||
:install_go
|
:install_go
|
||||||
where go >nul 2>&1
|
where go >nul 2>&1
|
||||||
if %errorlevel% == 0 (
|
if %errorlevel% == 0 (
|
||||||
echo golang is already installed and in PATH. Moving on.
|
echo golang is already installed and in PATH. Moving on.
|
||||||
exit /b 0
|
goto building_rfswift
|
||||||
)
|
|
||||||
|
|
||||||
if exist "C:\Go\bin\go.exe" (
|
|
||||||
echo golang is already installed in C:\Go\bin. Moving on.
|
|
||||||
exit /b 0
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if not exist thirdparty mkdir thirdparty
|
if not exist thirdparty mkdir thirdparty
|
||||||
|
@ -55,7 +41,7 @@ setx PATH "%PATH%;C:\Go\bin"
|
||||||
cd ..
|
cd ..
|
||||||
rmdir /s /q thirdparty
|
rmdir /s /q thirdparty
|
||||||
echo Go installed successfully.
|
echo Go installed successfully.
|
||||||
exit /b 0
|
goto building_rfswift
|
||||||
|
|
||||||
REM Function to build RF Switch Go Project
|
REM Function to build RF Switch Go Project
|
||||||
:building_rfswift
|
:building_rfswift
|
||||||
|
@ -64,17 +50,6 @@ go build .
|
||||||
move rfswift.exe ..\..\
|
move rfswift.exe ..\..\
|
||||||
cd ..\..
|
cd ..\..
|
||||||
echo RF Switch Go Project built successfully.
|
echo RF Switch Go Project built successfully.
|
||||||
exit /b 0
|
|
||||||
|
|
||||||
REM Main script execution
|
|
||||||
echo Checking Docker installation and activation
|
|
||||||
call :check_docker
|
|
||||||
|
|
||||||
echo Installing Go
|
|
||||||
call :install_go
|
|
||||||
|
|
||||||
echo Building RF Switch Go Project
|
|
||||||
call :building_rfswift
|
|
||||||
|
|
||||||
REM Prompt the user if they want to build a Docker container, pull an image, or exit
|
REM Prompt the user if they want to build a Docker container, pull an image, or exit
|
||||||
echo Do you want to build a Docker container, pull an existing image, or exit?
|
echo Do you want to build a Docker container, pull an existing image, or exit?
|
||||||
|
@ -89,19 +64,19 @@ if "%option%" == "1" (
|
||||||
set "DEFAULT_DOCKERFILE=Dockerfile"
|
set "DEFAULT_DOCKERFILE=Dockerfile"
|
||||||
|
|
||||||
REM Prompt the user for input with default values
|
REM Prompt the user for input with default values
|
||||||
set /p imagename="Enter image tag value (default: %DEFAULT_IMAGE%): "
|
set /p imagename="Enter image tag value (default: !DEFAULT_IMAGE!): "
|
||||||
set /p dockerfile="Enter value for Dockerfile to use (default: %DEFAULT_DOCKERFILE%): "
|
set /p dockerfile="Enter value for Dockerfile to use (default: !DEFAULT_DOCKERFILE!): "
|
||||||
|
|
||||||
REM Use default values if variables are empty
|
REM Use default values if variables are empty
|
||||||
if "!imagename!" == "" set "imagename=%DEFAULT_IMAGE%"
|
if "!imagename!" == "" set "imagename=!DEFAULT_IMAGE!"
|
||||||
if "!dockerfile!" == "" set "dockerfile=%DEFAULT_DOCKERFILE%"
|
if "!dockerfile!" == "" set "dockerfile=!DEFAULT_DOCKERFILE!"
|
||||||
|
|
||||||
echo Building the Docker container
|
echo Building the Docker container
|
||||||
docker build . -t !imagename! -f !dockerfile!
|
docker build . -t !imagename! -f !dockerfile!
|
||||||
) else if "%option%" == "2" (
|
) else if "%option%" == "2" (
|
||||||
set "DEFAULT_PULL_IMAGE=penthertz/rfswift:latest"
|
set "DEFAULT_PULL_IMAGE=penthertz/rfswift:latest"
|
||||||
set /p pull_image="Enter the image tag to pull (default: %DEFAULT_PULL_IMAGE%): "
|
set /p pull_image="Enter the image tag to pull (default: !DEFAULT_PULL_IMAGE!): "
|
||||||
if "!pull_image!" == "" set "pull_image=%DEFAULT_PULL_IMAGE%"
|
if "!pull_image!" == "" set "pull_image=!DEFAULT_PULL_IMAGE!"
|
||||||
|
|
||||||
echo Pulling the Docker image
|
echo Pulling the Docker image
|
||||||
docker pull !pull_image!
|
docker pull !pull_image!
|
||||||
|
|
Loading…
Reference in New Issue