Support for multiple search domains.

This commit is contained in:
Christoph 2018-07-25 12:15:18 +02:00
parent 8f2df2215b
commit 30bbd05071
2 changed files with 27 additions and 18 deletions

View File

@ -13,4 +13,4 @@ DEFAULT_KEY_EMAIL='support@oopen.de'
DEFAULT_KEY_OU="Network Services" DEFAULT_KEY_OU="Network Services"
DEFAULT_KEY_ORG="O.OPEN" DEFAULT_KEY_ORG="O.OPEN"
DEFAULT_SERVER_CIPHER="" DEFAULT_SERVER_CIPHER="AES-256-CBC"

View File

@ -603,26 +603,32 @@ echo -e "\033[32m--\033[m"
echo "" echo ""
echo "" echo ""
echo "Default Domain to push from OpenVPN server to the client." echo "Search Domain(s) to push from OpenVPN server to the client."
echo ""
echo " - multiple domains are possible: use blank separated list of search domains"
echo "" echo ""
echo -e "Type \"\033[33mNone\033[m\" if no default domain should be pushed." echo -e "Type \"\033[33mNone\033[m\" if no default domain should be pushed."
echo "" echo ""
DEFAULT_DOMAIN="" SEARCH_DOMAINS=""
echononl "Default Domain to push to clients: " echononl "Default Domain to push to clients: "
while [[ "X$DEFAULT_DOMAIN" = "X" ]]; do while [[ "X$SEARCH_DOMAINS" = "X" ]]; do
read DEFAULT_DOMAIN read SEARCH_DOMAINS
if [[ "X$DEFAULT_DOMAIN" = "X" ]]; then if [[ "X$SEARCH_DOMAINS" = "X" ]]; then
echo -e "\n\t\033[33m\033[1mWrong Entry!\033[m\n" echo -e "\n\t\033[33m\033[1mWrong Entry!\033[m\n"
echononl "Default Domain to pusch to clients" echononl "Search Domain(s) to pusch to clients"
continue continue
else else
_to_lower_default_domain="$(trim ${DEFAULT_DOMAIN,,})" _to_lower_search_domains="$(trim ${SEARCH_DOMAINS,,})"
if [[ "$_to_lower_default_domain" = "none" ]]; then if [[ "$_to_lower_search_domains" = "none" ]]; then
DEFAULT_DOMAIN="" SEARCH_DOMAINS=""
break; break;
fi fi
fi fi
done done
declare -a SEARCH_DOMAINS_ARR=()
for _domain in ${SEARCH_DOMAINS} ; do
SEARCH_DOMAINS_ARR+=("$_domain")
done
echo "" echo ""
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
@ -726,8 +732,8 @@ if [[ -n "$DNS_SERVER" ]]; then
else else
echo -e "\tDNS Server (push from server).......: \033[33mNone\033[m" echo -e "\tDNS Server (push from server).......: \033[33mNone\033[m"
fi fi
if [[ -n "$DEFAULT_DOMAIN" ]]; then if [[ ${#SEARCH_DOMAINS_ARR[@]} -gt 0 ]]; then
echo -e "\tDefault Domain (push from server)...: $DEFAULT_DOMAIN" echo -e "\tDefault Domain (push from server)...: ${SEARCH_DOMAINS_ARR[@]}"
else else
echo -e "\tDefault Domain (push from server)...: \033[33mNone\033[m" echo -e "\tDefault Domain (push from server)...: \033[33mNone\033[m"
fi fi
@ -886,14 +892,14 @@ DNS_SERVER="none"
EOF EOF
fi fi
if [[ -n "$DEFAULT_DOMAIN" ]] ; then if [[ ${#SEARCH_DOMAINS_ARR[@]} -gt 0 ]] ; then
cat << EOF >> $_openvpn_name_conf_file 2> $log_file cat << EOF >> $_openvpn_name_conf_file 2> $log_file
DEFAULT_DOMAIN="$DEFAULT_DOMAIN" SEARCH_DOMAINS="${SEARCH_DOMAINS_ARR[@]}"
EOF EOF
else else
cat << EOF >> $_openvpn_name_conf_file 2> $log_file cat << EOF >> $_openvpn_name_conf_file 2> $log_file
DEFAULT_DOMAIN="none" SEARCH_DOMAINS="none"
EOF EOF
fi fi
@ -1709,10 +1715,13 @@ if [[ -n "$DNS_SERVER" ]]; then
push "dhcp-option DNS ${DNS_SERVER}" push "dhcp-option DNS ${DNS_SERVER}"
EOF EOF
fi fi
if [[ -n "$DEFAULT_DOMAIN" ]]; then
if [[ ${#SEARCH_DOMAINS_ARR[@]} -gt 0 ]]; then
for _domain in ${SEARCH_DOMAINS_ARR[@]} ; do
cat <<EOF >> ${_server_conf_file} 2>> "$log_file" cat <<EOF >> ${_server_conf_file} 2>> "$log_file"
push "dhcp-option DOMAIN ${DEFAULT_DOMAIN}" push "dhcp-option DOMAIN ${_domain}"
EOF EOF
done
fi fi
cat <<EOF >> ${_server_conf_file} 2>> "$log_file" cat <<EOF >> ${_server_conf_file} 2>> "$log_file"