forked from iic-jku/IIC-OSIC-TOOLS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_x.bat
48 lines (38 loc) · 1.8 KB
/
start_x.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
@echo off
SETLOCAL
SET DEFAULT_DESIGNS=%USERPROFILE%\eda\designs
IF DEFINED DRY_RUN (
echo This is a dry run, all commands will be printed to the shell ^(Commands printed but not executed are marked with ^$^)!
SET ECHO_IF_DRY_RUN=ECHO $
)
IF "%DESIGNS%"=="" (
SET DESIGNS=%DEFAULT_DESIGNS%
)
echo Using/creating designs directory: %DESIGNS%
if not exist "%DESIGNS%" %ECHO_IF_DRY_RUN% mkdir "%DESIGNS%"
IF "%DOCKER_USER%"=="" SET DOCKER_USER=hpretl
IF "%DOCKER_IMAGE%"=="" SET DOCKER_IMAGE=iic-osic-tools
IF "%DOCKER_TAG%"=="" SET DOCKER_TAG=latest
IF "%CONTAINER_USER%"=="" SET CONTAINER_USER=1000
IF "%CONTAINER_GROUP%"=="" SET CONTAINER_GROUP=1000
IF "%CONTAINER_NAME%"=="" SET CONTAINER_NAME=iic-osic-tools_xserver
IF "%DISP%"=="" SET DISP=host.docker.internal:0
where /q xhost
IF ERRORLEVEL 1 (
ECHO xhost is not detected / not in PATH. Please verify X-server access control!
) ELSE (
ECHO Using xhost to enable localhost access to the X-server.
%ECHO_IF_DRY_RUN% xhost +localhost
)
docker container inspect %CONTAINER_NAME% 2>&1 | find "Status" | find /i "running"
IF NOT ERRORLEVEL 1 (
ECHO Container is running! Stop with \"docker stop %CONTAINER_NAME%\" and remove with \"docker rm %CONTAINER_NAME%\" if required.
) ELSE (
docker container inspect %CONTAINER_NAME% 2>&1 | find "Status" | find /i "exited"
IF NOT ERRORLEVEL 1 (
echo Container %CONTAINER_NAME% exists. Restart with \"docker start %CONTAINER_NAME%\" or remove with \"docker rm %CONTAINER_NAME%\" if required.
) ELSE (
echo Container does not exist, creating %CONTAINER_NAME% ...
%ECHO_IF_DRY_RUN% docker run -d --user %CONTAINER_USER%:%CONTAINER_GROUP% -e DISPLAY=%DISP% -e LIBGL_ALWAYS_INDIRECT=1 -v "%DESIGNS%":/foss/designs --name %CONTAINER_NAME% %DOCKER_USER%/%DOCKER_IMAGE%:%DOCKER_TAG%
)
)