/
docker-entrypoint.sh
executable file
·41 lines (34 loc) · 1.11 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
#!/bin/bash
set -e
usage() {
echo "docker run amlight/kytos [options]"
echo " -h, --help display help information"
echo " /path/program ARG1 .. ARGn execute the specfified local program"
echo " --ARG1 .. --ARGn execute kytos with these arguments"
}
if [ "$1" == "-h" -o "$1" == "--help" ]; then
usage
exit 0
fi
# Start the dependency services
test -x /usr/sbin/rsyslogd && service rsyslog start
test -x /usr/sbin/ovs-vswitchd && service openvswitch-switch start
test -x /usr/sbin/nginx && service nginx start
# If first argument looks like an argument then execute mininet with all the
# arguments
if [ $# -eq 0 ] || [[ "$1" =~ ^- ]]; then
echo -n "Starting Kytos controller in a tmux session with args: "
tmux new-session -d -s kytosserver "kytosd -f $@"
echo "done"
echo "Leaving tail -f /dev/null running.."
tail -f /dev/null
# execute only argument
elif [[ "$1" =~ ^/ ]]; then
exec "$@"
# execute argument + kytosd
else
echo -n "Starting Kytos controller in a tmux session: "
tmux new-session -d -s kytosserver "kytosd -f"
echo "done"
exec "$@"
fi