-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgo.sh
executable file
·86 lines (70 loc) · 1.63 KB
/
go.sh
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
#!/usr/bin/env bash
tag=moana:$USER
xauth=/tmp/.docker.xauth.$USER
data=/mnt/seenas2/data/moana
out=$PWD/out
port=8861
registry=accona.eecs.utk.edu:5000
name=moana_service
global=1
build() {
docker build -t $tag .
}
run() {
mkdir -p $out
docker run \
-it --rm \
--net=host \
-v $data:$data \
-v $out:/out \
$tag "$@"
}
push() {
docker tag $tag $registry/$tag
docker push $registry/$tag
}
create() {
docker service create \
--name $name \
-p $port:$port \
${global:+--mode global} \
--mount type=bind,src=$data,dst=$data \
--mount type=bind,src=$out,dst=/out \
$registry/$tag python3.7 -u server.py --port $port "$@"
}
destroy() {
docker service rm $name
}
scale() {
docker service scale $name=${1?:need a number}
}
logs() {
docker service logs $name "$@"
}
inspect() {
# Thanks https://stackoverflow.com/q/48235040
rm -f $xauth
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $xauth nmerge -
docker run -it --rm --entrypoint bash -v $PWD:$PWD -v $data:$data -w $PWD -e DISPLAY -v /etc/group:/etc/group:ro -v $xauth:$xauth -e XAUTHORITY=$xauth -v /etc/passwd:/etc/passwd:ro -v /etc/shadow:/etc/shadow:ro -v /etc/sudoers.d:/etc/sudoers.d:ro -v /tmp/.X11-unix:/tmp/.X11-unix:rw --ipc=host --net=host $tag "$@"
}
extract() {
tar xf moana-ospray-demo.tgz -C _ --strip-components 2
}
checkout() {
local f
f=${1?:Need file}
if ! [ -e "$f" ]; then
printf 'File should exist\n' >&2
return 1
fi
if ! [ "${f%%/*}" = _ ]; then
printf 'File should be in _ directory\n' >&2
return 1
fi
mkdir -p new
tar cf - -C _ "${f#*/}" | tar xf - -C new
}
server.py() {
run python3.7 -u server.py --port $port "$@"
}
"$@"