-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathconfigure-openvpn.sh
executable file
·64 lines (46 loc) · 1.5 KB
/
configure-openvpn.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/bash
set -e
OVPN_CONNECTION=$OVPN_CONNECTION
export OVPN_CONNECTION
OVPN_PROTOCOL=$OVPN_PROTOCOL
export OVPN_PROTOCOL
OVPN_COUNTRY=$OVPN_COUNTRY
export OVPN_COUNTRY
OVPN_CITY=$OVPN_CITY
export OVPN_CITY
if [ -z "$VPN_PROVIDER_HOME" ]; then
echo "ERROR: Need to have VPN_PROVIDER_HOME set to call this script" && exit 1
fi
validate_options () {
if [[ -n "$OVPN_CONNECTION" ]] && [[ $OVPN_CONNECTION =~ (multihop|standard) ]]; then
return 1
elif [[ -n "$OVPN_PROTOCOL" ]] && [[ $OVPN_PROTOCOL =~ (udp|tcp) ]]; then
return 2
fi
return 0
}
# in case the script is executed from another directory
#cd ${0%/*}
cd /etc/openvpn/ovpn
# Delete all files for this provider, except scripts
find /etc/openvpn/ovpn -type f ! -name "*.sh" -delete
# Download and extract wanted bundle into temporary file
echo "creating temp folder"
mkdir /tmp/ovpnxtract/
echo "entering temp folder"
cd /tmp/ovpnxtract/
echo "cloning contrib git"
git clone https://github.com/haugene/vpn-configs-contrib.git
echo "moving content"
mv /tmp/ovpnxtract/vpn-configs-contrib/openvpn/ovpn/* /etc/openvpn/ovpn
echo "deleting temp folder"
rm -rf /tmp/ovpnxtract/
#pattern=$OVPN_CONNECTION.$OVPN_COUNTRY.$OVPN_CITY.$OVPN_PROTOCOL
#OPENVPN_CONFIG=$(ls $pattern | shuf | head -n1)
OPENVPN_CONFIG=$OVPN_CONNECTION.$OVPN_COUNTRY.$OVPN_CITY.$OVPN_PROTOCOL
#if [[ -n "$OPENVPN_CONFIG" ]]; then
# ln -sf OPENVPN_CONFIG "$VPN_PROVIDER_HOME"/default.ovpn
#else
# echo "There is no available config matching provided options!"
# exit 3
#fi