-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.ps1
40 lines (33 loc) · 1.44 KB
/
run.ps1
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
# RED='\033[0;31m'
# NC='\033[0m'
function help {
Write-Output "Usage:"
Write-Output "Run using prebuild docker image:"
Write-Output " ./run.sh source_dir out_dir"
Write-Output "Manually build the docker image and run it:"
Write-Output " ./run.sh -b source_dir out_dir"
exit 0
}
function check_path {
param ([string]$path, [string]$number)
if (-not (Test-Path -Path $path -PathType Container )) { Write-Output "${RED}The $number argument is not a directory${NC}"; help }
if (-not ([System.IO.Path]::IsPathRooted($path))) {Write-Output "${RED}The $number argument is not an absolute path${NC}"; help }
}
# if (-not [ ! -x "$(command -v docker)" ]; Write-Output "${RED}Could not find docker, make sure that you have docker installed${NC}" && exit 0
function has_tools {
docker images | Select-String "time-analysis-tools" | measure-object -line
}
if (($args[0] -match "-b") -and ($args.Count -eq 3)) {
check_path $args[1] "second"
check_path $args[2] "third"
if (has_tools -eq 0) {
Write-Output "No built image found for time-analysis-tools. Building..."
docker build -t time-analysis-tools -f Dockerfile .}
docker run --rm -it -v ${2}:/root/source -v ${3}:/root/out time-analysis-tools
}
elseif ($args.Count -eq 2 ){
check_path $args[0] "first"
check_path $args[1] "second"
docker run --rm -it -v ${1}:/root/source -v ${2}:/root/out eskehoy/ct-analysis-tools:latest
}
else {help}