/
quickOpenVPNconf.sh
executable file
·51 lines (38 loc) · 1.18 KB
/
quickOpenVPNconf.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
#!/bin/env bash
############################################################################
# script to quickly copy VPN files into /etc/openvpn and enable systemd
# service; to avoid NetworkManager shortcoming w/autoconnect
# and Gnome-keyring.
############################################################################
# Enable debugging
set -vx
USAGE="Usage: `basename $0` <dirWithVPNconfFiles>"
# Test for parameters
if [[ -z $1 ]]
then
echo $USAGE
exit 1;
fi
# clientfile=$1/*.ovpn
syswideconfig=/etc/openvpn
[[ -d $syswideconfig ]] || echo "Is openvpn installed on your system?" # check openvpn installed
clientdir="$1"
cp -r $clientdir/* $syswideconfig
# conffile=$syswideconfig/*.ovpn
conffile=$syswideconfig/*.conf
# servicefile=echo "`cut -d/ -f4 $conffile |cut -f1`"
servicefile=`ls -a /etc/openvpn/*.conf |cut -d/ -f4 |cut -d. -f1`
# ss22=echo "$servicefile"
# for f in `find $syswideconfig -iname '*.conf' -o -iname '*.ovpn' -type f`
# do
# echo $f
# servicename="openvpn@$ss22'.service"
servicename="openvpn@$servicefile.service"
sleep 1
/bin/sysctemctl enable $servicename
# done
# if [[ -f $conffile ]]
# then
# systemctl enable openvpn@$servicefile.service
# fi
exit