-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker-entrypoint.sh
executable file
·47 lines (39 loc) · 1.19 KB
/
docker-entrypoint.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
#!/bin/bash
set -e
usage() {
echo "docker run italovalcy/mininet [options]"
echo " -h, --help display help information"
echo " /path/program ARG1 .. ARGn execute the specified local program"
echo " URL ARG1 .. ARGn download script from URL and execute it"
echo " --ARG1 .. --ARGn execute mininet with these arguments"
}
launch() {
# If first argument is a URL then download the script and execute it passing
# it the rest of the arguments
if [[ $1 =~ ^(file|http|https|ftp|ftps):// ]]; then
curl -s -o ./script $1
chmod 755 ./script
shift
exec ./script $@
# If first argument is an absolute file path then execute that file passing
# it the rest of the arguments
elif [[ $1 =~ ^/ ]]; then
exec $@
# If first argument looks like an argument then execute mininet with all the
# arguments
elif [[ $1 =~ ^- ]]; then
tmux new-sess -d -s mn mn $@
sleep infinity
# Unknown argument
else
usage
fi
}
if [ $# -eq 0 ] || [ $1 = "-h" -o $1 = "--help" ]; then
usage
exit 0
fi
# Start the Open Virtual Switch Service
service openvswitch-switch start
ovs-vsctl set-manager ptcp:6640
launch $@