-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.bat
87 lines (72 loc) · 1.6 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
@echo off
setlocal
echo -------------------------------------------------------
if "%1" equ "build" (
SET task=build
) else (
if "%1" equ "deploy" (
SET task=deploy
) else (
echo Unknown task
)
)
echo Task: %task%
SHIFT
:arg-loop
if "%1" equ "" goto arg-done
if "%1" equ "--workingdir" goto arg-workingdir
if "%1" equ "--device" goto arg-device
if "%1" equ "--srcpath" goto arg-srcpath
SHIFT
GOTO :arg-loop
:arg-workingdir
SHIFT
SET workingdir=%1
GOTO :arg-continue
:arg-device
SHIFT
SET device=%1
GOTO :arg-continue
:arg-srcpath
SHIFT
SET srcpath=%1
GOTO :arg-continue
:arg-continue
SHIFT
goto :arg-loop
:arg-done
echo Device: %device%
if defined srcpath echo Source path: %srcpath%
if %device% equ edison (
SET imagename=zhijzhao/edison
) else (
if %device% equ raspberrypi (
SET imagename=zhijzhao/raspberrypi
) else (
echo unknown device
)
)
echo Image name: %imagename%
SET srcpathparam=
if %task% equ deploy (
if exist %srcpath%\* (
SET workingdir=%srcpath%
SET srcpathparam=--srcdockerpath /source/*
) else (
SET workingdir=%srcpath%\..
for %%F in ("%srcpath%") do (
SET srcpathparam=--srcdockerpath /source/%%~nxF
)
)
)
echo Working directory: %workingdir%
echo -------------------------------------------------------
echo Pulling docker image...
docker pull %imagename%
echo -------------------------------------------------------
if %task% equ deploy (
echo Deploying to device via docker container...
) else (
echo Building code inside docker container...
)
docker run --rm -i -v %workingdir%:/source %imagename% /index.sh %task% %srcpathparam% %*