File tree Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Expand file tree Collapse file tree 2 files changed +63
-1
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ usage() {
51
51
echo " -a Authenticate packets with HMAC using the given message digest algorithm (auth)."
52
52
echo " -z Enable comp-lzo compression."
53
53
echo " -2 Enable two factor authentication using Google Authenticator."
54
+ echo " -f Set the fragment directive."
54
55
}
55
56
56
57
if [ " $DEBUG " == " 1" ]; then
@@ -80,7 +81,7 @@ OVPN_AUTH=''
80
81
[ -r " $OVPN_ENV " ] && source " $OVPN_ENV "
81
82
82
83
# Parse arguments
83
- while getopts " :a:C:T:r:s:du:cp:n:DNm :tz2" opt; do
84
+ while getopts " :a:C:T:r:s:du:cp:n:DNmf :tz2" opt; do
84
85
case $opt in
85
86
a)
86
87
OVPN_AUTH=" $OPTARG "
@@ -130,6 +131,9 @@ while getopts ":a:C:T:r:s:du:cp:n:DNm:tz2" opt; do
130
131
2)
131
132
OVPN_OTP_AUTH=1
132
133
;;
134
+ f)
135
+ OVPN_FRAGMENT=$OPTARG
136
+ ;;
133
137
\? )
134
138
set +x
135
139
echo " Invalid option: -$OPTARG " >&2
@@ -177,6 +181,7 @@ export OVPN_CLIENT_TO_CLIENT OVPN_PUSH OVPN_NAT OVPN_DNS OVPN_MTU OVPN_DEVICE
177
181
export OVPN_TLS_CIPHER OVPN_CIPHER OVPN_AUTH
178
182
export OVPN_COMP_LZO
179
183
export OVPN_OTP_AUTH
184
+ export OVPN_FRAGMENT
180
185
181
186
# Preserve config
182
187
if [ -f " $OVPN_ENV " ]; then
223
228
[ -n " $OVPN_CLIENT_TO_CLIENT " ] && echo " client-to-client" >> " $conf "
224
229
[ -n " $OVPN_COMP_LZO " ] && echo " comp-lzo" >> " $conf "
225
230
231
+ [ -n " $OVPN_FRAGMENT " ] && echo " fragment $OVPN_FRAGMENT " >> " $conf "
232
+
226
233
[ " $OVPN_DNS " == " 1" ] && for i in " ${OVPN_DNS_SERVERS[@]} " ; do
227
234
echo " push dhcp-option DNS $i " >> " $conf "
228
235
done
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ OVPN_DATA=opvn-data
4
+
5
+ IMG=kylemanna/openvpn
6
+
7
+ # Function to fail
8
+ abort () { cat <<< " $@" 1>&2 ; exit 1; }
9
+
10
+ #
11
+ # Create a docker container with the config data
12
+ #
13
+ sudo docker run --name $OVPN_DATA -v /etc/openvpn busybox
14
+
15
+ #
16
+ # Generate openvpn.config file
17
+ #
18
+ SERV_IP=$( ip -4 -o addr show scope global | awk ' {print $4}' | sed -e ' s:/.*::' | head -n1)
19
+ sudo docker run --volumes-from $OVPN_DATA --rm $IMG ovpn_genconfig -u udp://$SERV_IP -f 1400
20
+
21
+ #
22
+ # grep for config lines from openvpn.conf
23
+ # add more tests for more configs as required
24
+ #
25
+
26
+ # 1. verb config
27
+ CONFIG_REQUIRED_VERB=" verb 3"
28
+ CONFIG_MATCH_VERB=$( sudo docker run --rm -it --volumes-from $OVPN_DATA busybox grep verb /etc/openvpn/openvpn.conf)
29
+
30
+ # 2. fragment config
31
+ CONFIG_REQUIRED_FRAGMENT=" fragment 1400"
32
+ CONFIG_MATCH_FRAGMENT=$( sudo docker run --rm -it --volumes-from $OVPN_DATA busybox grep fragment /etc/openvpn/openvpn.conf)
33
+
34
+ #
35
+ # Clean up
36
+ #
37
+ # sudo docker rm -f $OVPN_DATA
38
+
39
+ #
40
+ # Tests
41
+ #
42
+
43
+ if [[ $CONFIG_MATCH_VERB =~ $CONFIG_REQUIRED_VERB ]]
44
+ then
45
+ echo " ==> Config match found: $CONFIG_REQUIRED_VERB == $CONFIG_MATCH_VERB "
46
+ else
47
+ abort " ==> Config match not found: $CONFIG_REQUIRED_VERB != $CONFIG_MATCH_VERB "
48
+ fi
49
+
50
+ if [[ $CONFIG_MATCH_FRAGMENT =~ $CONFIG_REQUIRED_FRAGMENT ]]
51
+ then
52
+ echo " ==> Config match found: $CONFIG_REQUIRED_FRAGMENT == $CONFIG_MATCH_FRAGMENT "
53
+ else
54
+ abort " ==> Config match not found: $CONFIG_REQUIRED_FRAGMENT != $CONFIG_MATCH_FRAGMENT "
55
+ fi
You can’t perform that action at this time.
0 commit comments