-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdocker_entry.sh
More file actions
executable file
·35 lines (27 loc) · 877 Bytes
/
docker_entry.sh
File metadata and controls
executable file
·35 lines (27 loc) · 877 Bytes
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
#!/bin/bash
server=0;
interface=""
# TODO: make no require Bash
# Parse params
_interface=0
args=()
for arg in "$@"; do
# Interface
[ "$arg" == "-i" ] && [ ${_interface} -eq 0 ] && _interface=1 && continue
[ ${_interface} -eq 1 ] && _interface=0 && interface="$arg" && continue
# Is it server?
[ "$arg" == "-l" ] && server=1;
args+=(${arg})
done
if [ ${server} -ne 0 ]; then
# Check if iptables is usable on server
iptables -L &>/dev/null
if [ $? -ne 0 ]; then
echo "You need to start docker in privileged mode and with host networking:" >&2
echo " docker run --net=host --privileged ..." >&2
exit 1
fi
# Enable local routing
[ "$interface" != "" ] && eval "echo -n 1 >/proc/sys/net/ipv4/conf/${interface}/route_localnet"
fi
exec /usr/local/bin/python3 -u -OO /opt/portredirector.py ${args[@]}