Add openvpn.conf gerneration -f fragment directive option

This commit is contained in:
Rudi Starcevic
2016-04-06 15:06:02 +08:00
parent ed51116fb6
commit 74bfad0aac
2 changed files with 64 additions and 1 deletions

View File

@ -51,6 +51,7 @@ usage() {
echo " -a Authenticate packets with HMAC using the given message digest algorithm (auth)."
echo " -z Enable comp-lzo compression."
echo " -2 Enable two factor authentication using Google Authenticator."
echo " -f Set the fragment directive."
}
if [ "$DEBUG" == "1" ]; then
@ -80,7 +81,7 @@ OVPN_AUTH=''
[ -r "$OVPN_ENV" ] && source "$OVPN_ENV"
# Parse arguments
while getopts ":a:C:T:r:s:du:cp:n:DNm:tz2" opt; do
while getopts ":a:C:T:r:s:du:cp:n:DNmf:tz2" opt; do
case $opt in
a)
OVPN_AUTH="$OPTARG"
@ -130,6 +131,9 @@ while getopts ":a:C:T:r:s:du:cp:n:DNm:tz2" opt; do
2)
OVPN_OTP_AUTH=1
;;
f)
OVPN_FRAGMENT=$OPTARG
;;
\?)
set +x
echo "Invalid option: -$OPTARG" >&2
@ -177,6 +181,7 @@ export OVPN_CLIENT_TO_CLIENT OVPN_PUSH OVPN_NAT OVPN_DNS OVPN_MTU OVPN_DEVICE
export OVPN_TLS_CIPHER OVPN_CIPHER OVPN_AUTH
export OVPN_COMP_LZO
export OVPN_OTP_AUTH
export OVPN_FRAGMENT
# Preserve config
if [ -f "$OVPN_ENV" ]; then
@ -223,6 +228,8 @@ EOF
[ -n "$OVPN_CLIENT_TO_CLIENT" ] && echo "client-to-client" >> "$conf"
[ -n "$OVPN_COMP_LZO" ] && echo "comp-lzo" >> "$conf"
[ -n "$OVPN_FRAGMENT" ] && echo "fragment $OVPN_FRAGMENT" >> "$conf"
[ "$OVPN_DNS" == "1" ] && for i in "${OVPN_DNS_SERVERS[@]}"; do
echo "push dhcp-option DNS $i" >> "$conf"
done