-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·36 lines (29 loc) · 994 Bytes
/
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
#!/bin/ash
exitOnError(){
# $1 must be set to $?
status=$1
message=$2
[ "$message" != "" ] || message="Error!"
if [ $status != 0 ]; then
printf "$message (status $status)\n"
exit $status
fi
}
cat "/etc/openvpn/pia/$REGION.ovpn" &> /dev/null
exitOnError $? "/etc/openvpn/pia/$REGION.ovpn is not accessible"
CONNECTIONSTRING=$(grep -i "/etc/openvpn/pia/$REGION.ovpn" -e 'privacy.network')
exitOnError $?
PORT=$(echo $CONNECTIONSTRING | cut -d' ' -f3)
if [ "$PORT" = "" ]; then
printf "Port not found in /etc/openvpn/pia/$REGION.ovpn\n"
exit 1
fi
PIADOMAIN=$(echo $CONNECTIONSTRING | cut -d' ' -f2)
if [ "$PIADOMAIN" = "" ]; then
printf "Domain not found in /etc/openvpn/pia/$REGION.ovpn\n"
exit 1
fi
echo "using remote ${PIADOMAIN} ${PORT}"
echo "remote ${PIADOMAIN} ${PORT}" > /etc/openvpn/pia/remote.conf
[[ -d /config ]] || mkdir /config
openvpn --config /etc/openvpn/pia/proto.conf --config /etc/openvpn/pia/pia.conf --config /etc/openvpn/pia/remote.conf