-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
42 lines (35 loc) · 1.02 KB
/
docker-entrypoint.sh
File metadata and controls
42 lines (35 loc) · 1.02 KB
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
#!/bin/sh
set -eu
if [ "$#" -eq 0 ]; then
set -- /usr/local/bin/wg -c /config/config.yaml
elif [ "${1#-}" != "$1" ]; then
set -- /usr/local/bin/wg "$@"
fi
if [ "${1:-}" = "/usr/local/bin/wg" ]; then
need_config=1
config_path=/config/config.yaml
prev=
for arg in "$@"; do
case "$arg" in
-g|-pg|-h)
need_config=0
;;
esac
if [ "$prev" = "-c" ]; then
config_path="$arg"
fi
prev="$arg"
done
if [ "$need_config" -eq 1 ] && [ ! -c /dev/net/tun ]; then
echo "WireGold requires /dev/net/tun inside the container." >&2
echo "Run with: --device /dev/net/tun --cap-add NET_ADMIN" >&2
echo "If Network is icmp or ip, add --cap-add NET_RAW as well." >&2
exit 1
fi
if [ "$need_config" -eq 1 ] && [ ! -f "$config_path" ]; then
echo "WireGold config not found: $config_path" >&2
echo "Mount your config into /config or override -c." >&2
exit 1
fi
fi
exec "$@"