-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdocker.sh
58 lines (51 loc) · 1.21 KB
/
docker.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
CONTAINER_NUM=1
timestamp() {
date +%Y-%m-%d_%H-%M-%S
}
run_container() {
docker container rm "hornfuzz$1"
log_dir="logs$1"
log="$log_dir/`timestamp`.txt"
last_log="$log_dir/`ls $log_dir | tail -1`"
if [[ $last_log == "$log_dir/" ]]; then
last_log=$log
fi
touch "$log"
docker run -it \
-v "$PWD/$last_log":/last_logfile \
-v "$PWD/$log":/logfile \
-v "$PWD/hornfuzz-workdir$1":/output \
--cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
--name "hornfuzz$1" \
--network hornfuzz-net \
hornfuzz
chmod 707 -R "hornfuzz-workdir$1"
}
if [[ "$@" =~ "--create-net" ]]; then
docker network create hornfuzz-net
fi
if [[ "$@" =~ "--build-img" ]]; then
docker build . -t hornfuzz --build-arg arg=$i
fi
for i in `eval echo {1..$CONTAINER_NUM}`; do
if [[ "$@" =~ "--clear-last" ]]; then
rm -rf "logs$i" "hornfuzz-workdir$i"
mkdir "logs$i"
fi
run_container $i
done
while true
do
for i in `eval echo {1..24}`; do
sleep 1h
for i in `eval echo {1..$CONTAINER_NUM}`; do
status=`docker inspect -f "{{.State.Status}}" "hornfuzz$i"`
if [[ $status = "exited" ]]; then
run_container $i
fi
done
done
for i in `eval echo {1..$CONTAINER_NUM}`; do
docker stop "hornfuzz$i"
done
done