Skip to content

Commit 2b19881

Browse files
committed
Improve options o run.sh, able to pass a configuration, e.g. ./run.sh -d 20 -c demo1
1 parent 3a9e7a2 commit 2b19881

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

.github/workflows/docker-image.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ jobs:
2323
run: |
2424
docker -v
2525
docker images
26-
- name: Run the Docker image
26+
- name: Run the Docker image with the falling cube
27+
run: |
28+
./run.sh -d 20 -c demo1
29+
- name: Run the Docker image with a worm
2730
run: |
2831
./run.sh
2932
- name: Info on generated files

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ output/C2*
44
/output/siminfo.py
55
/output/wor*
66
/output/Sibernetic_*
7+
/output/test*
8+
/output/box
9+
/output/swim*

run.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
#!/bin/bash
22

3+
version=$(<VERSION) # Read version of Dockerfile from file VERSION
4+
5+
36
#from: https://unix.stackexchange.com/a/129401
4-
while getopts ":d:p:" opt; do
5-
case $opt in
7+
while getopts ":d:c:" opt; do
8+
case "${opt}" in
69
d) duration="$OPTARG"
710
;;
8-
p) p_out="$OPTARG"
11+
c) configuration="$OPTARG"
912
;;
10-
\?) echo "Invalid option -$OPTARG" >&2
13+
*) echo "Usage: $0 [-d duration] [-c configuration]" >&2
14+
exit 1
1115
;;
1216
esac
1317
done
1418

1519
OW_OUT_DIR=/home/ow/shared
1620
HOST_OUT_DIR=$PWD
1721

18-
version=$(<VERSION) # Read version of Dockerfile from file VERSION
1922

2023
xhost +
2124

@@ -26,10 +29,24 @@ else #Duration is set, use it.
2629
DURATION_PART="-e DURATION=$duration"
2730
fi
2831

32+
echo 888
33+
if [ -z "$configuration" ]
34+
then #configuration is not set, don't use it
35+
CONFIGURATION_PART=""
36+
else #Configuration is set, use it.
37+
CONFIGURATION_PART="-e CONFIGURATION=$configuration"
38+
fi
39+
40+
echo 77
41+
42+
echo "Running Docker container for OpenWorm v${version}, configuration: ${configuration}, duration: ${duration}"
43+
44+
2945
docker run -d \
3046
--name openworm_$version \
3147
--device=/dev/dri:/dev/dri \
3248
-e DISPLAY=$DISPLAY \
49+
$CONFIGURATION_PART \
3350
$DURATION_PART \
3451
-e OW_OUT_DIR=$OW_OUT_DIR \
3552
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \

0 commit comments

Comments
 (0)