-
Notifications
You must be signed in to change notification settings - Fork 84
/
Copy pathchange_vpn.sh
executable file
·56 lines (49 loc) · 1.98 KB
/
change_vpn.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
#!/bin/bash
# Check that script was run not as root or with sudo
if [ "$EUID" -eq 0 ]
then echo "Please do not run this script as root or using sudo"
exit
fi
# set -x
# Stop the current running DelugeVPN container
docker stop delugevpn > /dev/null 2>&1
# Clear current VPN from the .env
sed '/^VPN_REMOTE/d' < .env > tmp.env
mv tmp.env .env
# Create menu - Select and Move the PIA VPN files
echo "The following PIA Servers are avialable that support port-forwarding (for DelugeVPN); Please select one:"
PS3="Use a number to select a Server File or 'c' to cancel: "
# List the ovpn files
select filename in ovpn/*.ovpn
do
# leave the loop if the user says 'c'
if [[ "$REPLY" == c ]]; then break; fi
# complain if no file was selected, and loop to ask again
if [[ "$filename" == "" ]]
then
echo "'$REPLY' is not a valid number"
continue
fi
# now we can use the selected file
echo "$filename selected"
# remove any existing ovpn, crt & pem files in the deluge config/ovpn
rm delugevpn/config/openvpn/*.ovpn > /dev/null 2>&1
rm delugevpn/config/openvpn/*.crt > /dev/null 2>&1
rm delugevpn/config/openvpn/*.pem > /dev/null 2>&1
# copy the selected ovpn file to deluge config/ovpn
cp "$filename" delugevpn/config/openvpn/ > /dev/null 2>&1
vpnremote=$(grep "remote" "$filename" | cut -d ' ' -f2 | head -1)
# Adjust for the PIA OpenVPN ciphers fallback
echo "cipher aes-256-gcm" >> delugevpn/config/openvpn/*.ovpn
# echo "ncp-disable" >> delugevpn/config/openvpn/*.ovpn -- possibly not needed anymore
# it'll ask for another unless we leave the loop
break
done
# TODO - Add a default server selection if none selected ..
cp ovpn/*.crt delugevpn/config/openvpn/ > /dev/null 2>&1
cp ovpn/*.pem delugevpn/config/openvpn/ > /dev/null 2>&1
# Add New VPN Endpoint to the .env anf .env.txt
echo "VPN_REMOTE=$vpnremote" >> .env
sed '/^PIA/d' < .env > homer/env.txt
# Restart the DelugeVPN Container
docker start delugevpn > /dev/null 2>&1