/
wiredtreeVPN-install
executable file
·56 lines (41 loc) · 1.58 KB
/
wiredtreeVPN-install
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/env bash
############################################################################
# WiredTree VPN install script with systemd support
############################################################################
# set debugging on
set -vx
USAGE="Usage: `basename $0` <dirWithVPNclientConf>\n\t Please specify the Directory where your VPN files are located."
if [[ -z $1 ]]
then
echo $USAGE
exit 1
fi
# Check root privs w/readonly variable
if [ "$EUID" -ne 0 ]
then echo "Please run as root!"
exit 1
fi
syswideconfig=/etc/openvpn
[[ -d $syswideconfig ]] || echo "Is openvpn installed on your system?" # check openvpn installed
# let's try to get the correct username, as this will be the prefix for name of client.conf file.
# It will also need to be set/changed within an option INSIDE the conf.file.
echo "Please enter your username: "
read NAME
echo "Thanks, $NAME. Here we go..."
clientdir="$1"
# clientdir="$1 | `sed 's;/$;;'`"
# cp \-r "$clientdir/*.{crt,csr,key,conf}" "$syswideconfig"
cp \-r $clientdir/*{crt,csr,key,conf} "$syswideconfig"
# TODO: update script with CORRECT vpn-client.conf file, reflecting username, etc.
# sed '/^cert/d' wiredtree.conf > wiredtree.conf2
# sed '/^key/d' wiredtree.conf > wiredtree.conf2
# sed 's/
# add infra hosts to hosts file
cat $clientdir/hosts >> /etc/hosts
# Add the default route w/out breaking old default
ip r add 0.0.0.0 via 172.18.254.1 dev tap0
[[ -z "/etc/systemd/system/wiredtreeVPN.service" ]] || cp wiredtreeVPN.service /etc/systemd/system
systemctl enable wiredtreeVPN.service
sleep 1
systemctl restart wiredtreeVPN.service
exit