create_vhost.sh: allow multiple ipv6/ipv4 addresses.
This commit is contained in:
parent
44b36432ff
commit
485d47158d
113
create_vhost.sh
113
create_vhost.sh
@ -182,12 +182,28 @@ _major_php_verisons=`echo "$__major_php_verisons" | sed 's/^ *//'`
|
||||
# - Determin IP Addresses
|
||||
# -
|
||||
if ifconfig | grep -i -q -E "inet (address|Adresse):" ; then
|
||||
__ipv4="`ifconfig | grep -e \"^\s*inet Adresse\" | grep -v \"127.0.0.1\" | awk '{print$2}' | cut -d\":\" -f2 | sort | head -1`"
|
||||
__ipv6="`ifconfig | grep -e \"^\s*inet6-Adresse\" | awk '{print$2}' | grep -v -e \"^::1/\" | grep -v -e \"^fe80\" | cut -d\"/\" -f1 | sort | head -1`"
|
||||
#__ipv4="`ifconfig | grep -e \"^\s*inet Adresse\" | grep -v \"127.0.0.1\" | awk '{print$2}' | cut -d\":\" -f2 | sort | head -1`"
|
||||
__ipv4="`ifconfig | grep -E \"^\s*inet [address|Adresse]\" | grep -v \"127.0.0.1\" | awk '{print$2}' | cut -d\":\" -f2 | sort`"
|
||||
#__ipv6="`ifconfig | grep -e \"^\s*inet6-Adresse\" | awk '{print$2}' | grep -v -e \"^::1/\" | grep -v -e \"^fe80\" | cut -d\"/\" -f1 | sort | head -1`"
|
||||
__ipv6="`ifconfig | grep -e \"^\s*inet6-Adresse\" | awk '{print$2}' | grep -v -e \"^::1/\" | grep -v -e \"^fe80\" | cut -d\"/\" -f1 | sort`"
|
||||
else
|
||||
__ipv4="`ifconfig | grep -e \"^\s*inet \" | grep -v \"127.0.0.1\" | awk '{print$2}' | sort | head -1`"
|
||||
__ipv6="`ifconfig | grep -e \"^\s*inet6 \" | awk '{print$2}' | grep -v \"^::1\" | grep -v -e \"^fe80\" | sort | head -1`"
|
||||
#__ipv4="`ifconfig | grep -e \"^\s*inet \" | grep -v \"127.0.0.1\" | awk '{print$2}' | sort | head -1`"
|
||||
__ipv4="`ifconfig | grep -e \"^\s*inet \" | grep -v \"127.0.0.1\" | awk '{print$2}' | sort`"
|
||||
#__ipv6="`ifconfig | grep -e \"^\s*inet6 \" | awk '{print$2}' | grep -v \"^::1\" | grep -v -e \"^fe80\" | sort | head -1`"
|
||||
__ipv6="`ifconfig | grep -e \"^\s*inet6 \" | awk '{print$2}' | grep -v \"^::1\" | grep -v -e \"^fe80\" | sort`"
|
||||
fi
|
||||
for _ip in $__ipv4 ; do
|
||||
_ipv4="$_ipv4 $_ip"
|
||||
done
|
||||
for _ip in $__ipv6 ; do
|
||||
_ipv6="$_ipv6 $_ip"
|
||||
done
|
||||
## - Trim leading whitespaces
|
||||
## -
|
||||
shopt -s extglob
|
||||
__ipv4="${_ipv4##*( )}"
|
||||
__ipv6="${_ipv6##*( )}"
|
||||
shopt -u extglob
|
||||
|
||||
# - Determin httpd binary
|
||||
# -
|
||||
@ -1016,6 +1032,7 @@ if [ -z "$_existing_vhost_config_file" ]; then
|
||||
fi
|
||||
|
||||
done
|
||||
IPv4_FIRST=`echo $_ipv4 | cut -d " " -f1`
|
||||
|
||||
_ipv6=
|
||||
while [ "X$_ipv6" = "X" ]
|
||||
@ -1036,6 +1053,11 @@ if [ -z "$_existing_vhost_config_file" ]; then
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ "$_ipv6" != "disabled" ]; then
|
||||
IPv6_FIRST=`echo $_ipv6 | cut -d " " -f1`
|
||||
else
|
||||
IPv6_FIRST=""
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
@ -2035,6 +2057,37 @@ if $_print_summary ; then
|
||||
[ $OK = "yes" -o $OK = "Yes" ] || fatal Repeat installation with different parameters
|
||||
fi
|
||||
|
||||
|
||||
_default_ipv6=false
|
||||
|
||||
|
||||
if [[ -n "${IPv4_FIRST}" ]]; then
|
||||
_default_ipv4=true
|
||||
fi
|
||||
if [[ -n "${IPv6_FIRST}" ]]; then
|
||||
_default_ipv6=true
|
||||
fi
|
||||
|
||||
_vhost_default_80="<VirtualHost"
|
||||
_vhost_default_443="<VirtualHost"
|
||||
|
||||
if $_default_ipv4 ; then
|
||||
for __ipv4 in $_ipv4; do
|
||||
_vhost_default_80="$_vhost_default_80 $__ipv4:80"
|
||||
_vhost_default_443="$_vhost_default_443 $__ipv4:443"
|
||||
done
|
||||
fi
|
||||
if $_default_ipv6 ; then
|
||||
for __ipv6 in $_ipv6 ; do
|
||||
_vhost_default_80="$_vhost_default_80 [${__ipv6}]:80"
|
||||
_vhost_default_443="$_vhost_default_443 [${__ipv6}]:443"
|
||||
done
|
||||
fi
|
||||
|
||||
_vhost_default_80="$_vhost_default_80>"
|
||||
_vhost_default_443="$_vhost_default_443>"
|
||||
|
||||
|
||||
if [[ "$_type" = "REDIRECT" ]] ; then
|
||||
|
||||
_failed=false
|
||||
@ -2059,7 +2112,7 @@ EOF
|
||||
done
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
<VirtualHost $_ipv4:80 [$_ipv6]:80>
|
||||
$_vhost_default_80
|
||||
|
||||
ServerAdmin $server_admin
|
||||
|
||||
@ -2110,7 +2163,7 @@ EOF
|
||||
if $_https ; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
<VirtualHost $_ipv4:443 [$_ipv6]:443>
|
||||
$_vhost_default_443
|
||||
|
||||
ServerAdmin $server_admin
|
||||
|
||||
@ -2889,19 +2942,21 @@ EOF
|
||||
_failed=true
|
||||
fi
|
||||
done
|
||||
if [ "$_ipv6" != "disabled" ]; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
<VirtualHost $_ipv4:80 [$_ipv6]:80>
|
||||
EOF
|
||||
else
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
<VirtualHost $_ipv4:80>
|
||||
EOF
|
||||
fi
|
||||
#if [ "$_ipv6" != "disabled" ]; then
|
||||
# cat <<EOF >> ${_new_vhost_config_file}
|
||||
#
|
||||
#<VirtualHost $_ipv4:80 [$_ipv6]:80>
|
||||
#EOF
|
||||
#else
|
||||
# cat <<EOF >> ${_new_vhost_config_file}
|
||||
#
|
||||
#<VirtualHost $_ipv4:80>
|
||||
#EOF
|
||||
#fi
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
$_vhost_default_80
|
||||
|
||||
ServerAdmin $server_admin
|
||||
|
||||
ServerName $_server_name
|
||||
@ -2996,20 +3051,22 @@ if [ "$?" != "0" ]; then
|
||||
fi
|
||||
|
||||
if $_https ; then
|
||||
if [ "$_ipv6" != "disabled" ]; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
<VirtualHost $_ipv4:443 [$_ipv6]:443>
|
||||
EOF
|
||||
else
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
<VirtualHost $_ipv4:443>
|
||||
EOF
|
||||
fi
|
||||
# if [ "$_ipv6" != "disabled" ]; then
|
||||
# cat <<EOF >> ${_new_vhost_config_file}
|
||||
#
|
||||
#<VirtualHost $_ipv4:443 [$_ipv6]:443>
|
||||
#EOF
|
||||
# else
|
||||
# cat <<EOF >> ${_new_vhost_config_file}
|
||||
#
|
||||
#<VirtualHost $_ipv4:443>
|
||||
#EOF
|
||||
# fi
|
||||
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
$_vhost_default_443
|
||||
|
||||
ServerAdmin $server_admin
|
||||
|
||||
ServerName $_server_name
|
||||
|
Loading…
Reference in New Issue
Block a user