-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
executable file
·40 lines (34 loc) · 1.01 KB
/
start.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
#!/bin/bash
CONF_FILE="$(readlink -f $1)"
NAME=vpn-proxy
PORT=1080
ENV_FILE="$(readlink -f .env)"
if [[ ! -f $ENV_FILE ]]; then
echo -e "\e[1;31mError:\e[0;0m .env file does not exists in the path: $ENV_FILE"
echo "💡 Make a copy of .env.example and update the values"
exit 1
fi
if [[ ! $CONF_FILE =~ ^.*\.ovpn$ ]]; then
echo -e "\e[1;31mError:\e[0;0m You must provide the location of *.ovpn file"
echo "💡 ./start.sh /path/to/confFile.ovpn"
exit 1
fi
if [[ ! -f $CONF_FILE ]]; then
echo -e "\e[1;31mError:\e[0;0m File does not exists in the path: $CONF_FILE"
exit 1
fi
if [[ "$(docker images -q $NAME 2>/dev/null)" == "" || $2 == "--build" ]]; then
docker build -t $NAME .
fi
exec docker run \
--name=$NAME \
--rm \
--tty \
--interactive \
--device=/dev/net/tun \
--cap-add=NET_ADMIN \
--publish 127.0.0.1:$PORT:1080 \
--volume "$CONF_FILE:/etc/openvpn/ovpn.conf:ro" \
--sysctl net.ipv6.conf.all.disable_ipv6=0 \
--env-file=$ENV_FILE \
$NAME