- Add support of 'parked' domain/site.
- Fix error in handling additional custom logfile."
This commit is contained in:
parent
3f96a75f55
commit
5fcf7c5506
@ -968,8 +968,8 @@ cat <<EOF > ${DST_PATH_PHP}/index.php
|
||||
<ul>
|
||||
EOF
|
||||
if [[ $number_websites_53 -gt 0 ]]; then
|
||||
cat <<EOF > ${DST_PATH_PHP}/index.php
|
||||
<li><a href="websites_php_53.php">websites PHP v5.3/a>: $number_websites_53<</li>
|
||||
cat <<EOF >> ${DST_PATH_PHP}/index.php
|
||||
<li><a href="websites_php_53.php">websites PHP v5.3</a>: $number_websites_53</li>
|
||||
EOF
|
||||
fi
|
||||
if [[ $number_websites_54 -gt 0 ]]; then
|
||||
|
278
create_vhost.sh
278
create_vhost.sh
@ -241,8 +241,9 @@ fi
|
||||
_tcp_host=127.0.0.1
|
||||
_tcp_port=9000
|
||||
|
||||
__CUSTOM_IPV4_LOG=ipv4_requests.log
|
||||
__CUSTOM_IPV6_LOG=ipv6_requests.log
|
||||
#__CUSTOM_IPV4_LOG=ipv4_requests.log
|
||||
#__CUSTOM_IPV6_LOG=ipv6_requests.log
|
||||
__CUSTOM_IP_LOG=ip_requests.log
|
||||
|
||||
_suEXEC=false
|
||||
_auto=""
|
||||
@ -259,6 +260,7 @@ USE_PROJECT_NAME=false
|
||||
PROJECT_NAME=""
|
||||
COMMON_LOGFILE_DIR=""
|
||||
REDIRECT_LOGFILE_DIR="/var/log/apache2"
|
||||
PARKED_LOGFILE_DIR="/var/log/apache2"
|
||||
VHOST_DIR=""
|
||||
WEBSITES_ROOT_DIR=""
|
||||
CREATE_SYMLINK_WEB_BASE_DIR=false
|
||||
@ -392,13 +394,13 @@ if $USE_PROJECT_NAME && [[ -z "$PROJECT_NAME" ]]; then
|
||||
done
|
||||
fi
|
||||
if [[ "$PROJECT_NAME" = "PARKED" ]] ; then
|
||||
_type="STATIC"
|
||||
_type="PARKED"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "\033[32m--\033[m"
|
||||
echo ""
|
||||
if [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" -a "$_type" != "STATIC" ];then
|
||||
if [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" -a "$_type" != "STATIC" -a "$_type" != "REDIRECT" -a "$_type" != "PARKED" ];then
|
||||
echo "Select PHP implementation configure for ?"
|
||||
echo ""
|
||||
echo "[1] PHP-FPM (FastCGI Process Manager)"
|
||||
@ -407,9 +409,10 @@ if [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" -a "$
|
||||
echo "[4] suEXEC (using mod_fcgid)"
|
||||
echo "[5] static site (No PHP engine enabled)"
|
||||
echo "[6] only redirect"
|
||||
echo "[7] parke domain/site"
|
||||
echo ""
|
||||
echononl "Your choice: "
|
||||
while [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" -a "$_type" != "STATIC" -a "$_type" != "REDIRECT" ];do
|
||||
while [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" -a "$_type" != "STATIC" -a "$_type" != "REDIRECT" -a "$_type" != "PARKED" ];do
|
||||
read OPTION
|
||||
case $OPTION in
|
||||
1) _type="PHP-FPM"
|
||||
@ -437,8 +440,12 @@ if [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" -a "$
|
||||
_type_msg="only redirect to another site"
|
||||
_new_extension=redirect
|
||||
;;
|
||||
7) _type="PARKED"
|
||||
_type_msg="parke domai/site"
|
||||
_new_extension=parked
|
||||
;;
|
||||
*) echo ""
|
||||
echo -e "\t\033[1;33mFalsche Eingabe ! [ 1 = PHP-FPM ; 2 = mod_fcgid , 3 = mod_php, 4 =suEXEC, 5 = static, 6 = redirect]\033[m"
|
||||
echo -e "\t\033[1;33mFalsche Eingabe ! [ 1 = PHP-FPM ; 2 = mod_fcgid , 3 = mod_php, 4 =suEXEC, 5 = static, 6 = redirect, 7 = parke]\033[m"
|
||||
echo ""
|
||||
echononl "Your choice: "
|
||||
;;
|
||||
@ -466,6 +473,9 @@ else
|
||||
elif [ "$_type" = "REDIRECT" ]; then
|
||||
_type_msg="only redirect to another site"
|
||||
_new_extension=redirect
|
||||
elif [ "$_type" = "PARKED" ]; then
|
||||
_type_msg="only parke domain/site"
|
||||
_new_extension=parked
|
||||
fi
|
||||
|
||||
echo "Configure site \"${site_url}\" - \"$_type_msg\""
|
||||
@ -679,6 +689,10 @@ if [ -z "$_existing_vhost_config_file" ]; then
|
||||
done
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
if [[ "$_type" != "REDIRECT" ]] && [[ "$_type" != "PARKED" ]]; then
|
||||
|
||||
if $USE_PROJECT_NAME ; then
|
||||
__web_base_dir=${_server_website_root_dir}/$PROJECT_NAME
|
||||
else
|
||||
@ -797,86 +811,128 @@ if [ -z "$_existing_vhost_config_file" ]; then
|
||||
fi
|
||||
|
||||
|
||||
_custom_ipv4_log=""
|
||||
_custom_ip_log=""
|
||||
echo
|
||||
if [ -n "$__CUSTOM_IPV4_LOG" ]; then
|
||||
if [ -n "$__CUSTOM_IP_LOG" ]; then
|
||||
echo -e "Additional Logfiles - Type \"\033[33mNone\033[m\" if not present"
|
||||
echononl "\tAdditional Logfile for IPv4 requests [${__CUSTOM_IPV4_LOG}]: "
|
||||
read _custom_ipv4_log
|
||||
if [ "X$_custom_ipv4_log" = "X" ]; then
|
||||
_custom_ipv4_log=$__CUSTOM_IPV4_LOG
|
||||
echononl "\tAdditional Logfile - site independent logging of IP Adresses [${__CUSTOM_IP_LOG}]: "
|
||||
read _custom_ip_log
|
||||
if [ "X$_custom_ip_log" = "X" ]; then
|
||||
_custom_ip_log=$__CUSTOM_IP_LOG
|
||||
fi
|
||||
if [ "X$_custom_ipv4_log" = "XNone" ]; then
|
||||
_custom_ipv4_log=""
|
||||
if [ "X$_custom_ip_log" = "XNone" ]; then
|
||||
_custom_ip_log=""
|
||||
fi
|
||||
else
|
||||
echo "Additional Logfiles - Leave empty if not present"
|
||||
echononl "\tAdditional Logfile for IPv4 requests: "
|
||||
read _custom_ipv4_log
|
||||
read _custom_ip_log
|
||||
fi
|
||||
|
||||
if [ -n "$_custom_ipv4_log" ]; then
|
||||
if [ "`dirname $_custom_ipv4_log`" = "." ]; then
|
||||
_custom_ipv4_log=/var/log/apache2/$_custom_ipv4_log
|
||||
if [ -n "$_custom_ip_log" ]; then
|
||||
if [ "`dirname $_custom_ip_log`" = "." ]; then
|
||||
_custom_ip_log=/var/log/apache2/$_custom_ip_log
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
_custom_ipv6_log=""
|
||||
echo ""
|
||||
if [ -n "$__CUSTOM_IPV6_LOG" ]; then
|
||||
echo -e "Additional Logfiles - Type \"\033[33mNone\033[m\" if not present"
|
||||
echononl "\tAdditional Logfile for IPv6 requests [${__CUSTOM_IPV6_LOG}]: "
|
||||
read _custom_ipv6_log
|
||||
if [ "X$_custom_ipv6_log" = "X" ]; then
|
||||
_custom_ipv6_log=$__CUSTOM_IPV6_LOG
|
||||
fi
|
||||
if [ "X$_custom_ipv6_log" = "XNone" ]; then
|
||||
_custom_ipv6_log=""
|
||||
fi
|
||||
else
|
||||
echo "Additional Logfiles - Leave empty if not present"
|
||||
echononl "\tAdditional Logfile for IPv6 requests : "
|
||||
read _custom_ipv6_log
|
||||
fi
|
||||
|
||||
if [ -n "$_custom_ipv6_log" ]; then
|
||||
#echo "dirname $_custom_ipv6_log: `dirname $_custom_ipv6_log`"
|
||||
if [ "`dirname $_custom_ipv6_log`" = "." ]; then
|
||||
_custom_ipv6_log=/var/log/apache2/$_custom_ipv6_log
|
||||
fi
|
||||
fi
|
||||
|
||||
# _custom_ipv4_log=""
|
||||
# echo
|
||||
# if [ -n "$__CUSTOM_IPV4_LOG" ]; then
|
||||
# echo -e "Additional Logfiles - Type \"\033[33mNone\033[m\" if not present"
|
||||
# echononl "\tAdditional Logfile for IPv4 requests [${__CUSTOM_IPV4_LOG}]: "
|
||||
# read _custom_ipv4_log
|
||||
# if [ "X$_custom_ipv4_log" = "X" ]; then
|
||||
# _custom_ipv4_log=$__CUSTOM_IPV4_LOG
|
||||
# fi
|
||||
# if [ "X$_custom_ipv4_log" = "XNone" ]; then
|
||||
# _custom_ipv4_log=""
|
||||
# fi
|
||||
# else
|
||||
# echo "Additional Logfiles - Leave empty if not present"
|
||||
# echononl "\tAdditional Logfile for IPv4 requests: "
|
||||
# read _custom_ipv4_log
|
||||
# fi
|
||||
#
|
||||
# if [ -n "$_custom_ipv4_log" ]; then
|
||||
# if [ "`dirname $_custom_ipv4_log`" = "." ]; then
|
||||
# _custom_ipv4_log=/var/log/apache2/$_custom_ipv4_log
|
||||
# fi
|
||||
# fi
|
||||
#
|
||||
#
|
||||
# _custom_ipv6_log=""
|
||||
# echo ""
|
||||
# if [ -n "$__CUSTOM_IPV6_LOG" ]; then
|
||||
# echo -e "Additional Logfiles - Type \"\033[33mNone\033[m\" if not present"
|
||||
# echononl "\tAdditional Logfile for IPv6 requests [${__CUSTOM_IPV6_LOG}]: "
|
||||
# read _custom_ipv6_log
|
||||
# if [ "X$_custom_ipv6_log" = "X" ]; then
|
||||
# _custom_ipv6_log=$__CUSTOM_IPV6_LOG
|
||||
# fi
|
||||
# if [ "X$_custom_ipv6_log" = "XNone" ]; then
|
||||
# _custom_ipv6_log=""
|
||||
# fi
|
||||
# else
|
||||
# echo "Additional Logfiles - Leave empty if not present"
|
||||
# echononl "\tAdditional Logfile for IPv6 requests : "
|
||||
# read _custom_ipv6_log
|
||||
# fi
|
||||
#
|
||||
# if [ -n "$_custom_ipv6_log" ]; then
|
||||
# #echo "dirname $_custom_ipv6_log: `dirname $_custom_ipv6_log`"
|
||||
# if [ "`dirname $_custom_ipv6_log`" = "." ]; then
|
||||
# _custom_ipv6_log=/var/log/apache2/$_custom_ipv6_log
|
||||
# fi
|
||||
# fi
|
||||
|
||||
else
|
||||
|
||||
echo "Enter URL to which site \"$site_url\" should be redirected."
|
||||
echo ""
|
||||
echo "Example:"
|
||||
echo " www.oopen.de"
|
||||
echo " www.oopen.de/ordner1/ordner2/"
|
||||
echo " www.oopen.de/ordner1/ordner2/site.html"
|
||||
echo ""
|
||||
echo ""
|
||||
rewrite_url=
|
||||
echononl "Redirect URL: "
|
||||
read rewrite_url
|
||||
while [ "X$rewrite_url" = "X" ] ; do
|
||||
echo -e "\n\t\033[33m\033[1mEingabe erforderlich.\033[m\n"
|
||||
if [[ "$_type" = "REDIRECT" ]] ; then
|
||||
|
||||
echo "Enter URL to which site \"$site_url\" should be redirected."
|
||||
echo ""
|
||||
echo "Example:"
|
||||
echo " www.oopen.de"
|
||||
echo " www.oopen.de/ordner1/ordner2/"
|
||||
echo " www.oopen.de/ordner1/ordner2/site.html"
|
||||
echo ""
|
||||
echo ""
|
||||
rewrite_url=
|
||||
echononl "Redirect URL: "
|
||||
read rewrite_url
|
||||
done
|
||||
while [ "X$rewrite_url" = "X" ] ; do
|
||||
echo -e "\n\t\033[33m\033[1mEingabe erforderlich.\033[m\n"
|
||||
echononl "Redirect URL: "
|
||||
read rewrite_url
|
||||
done
|
||||
|
||||
_log_dir="$REDIRECT_LOGFILE_DIR"
|
||||
|
||||
elif [[ "$_type" = "PARKED" ]]; then
|
||||
|
||||
_web_base_dir=${_server_website_root_dir}/PARKED
|
||||
_doc_root=${_web_base_dir}/htdocs
|
||||
|
||||
_log_dir="$PARKED_LOGFILE_DIR"
|
||||
|
||||
fi
|
||||
|
||||
_log_dir="$REDIRECT_LOGFILE_DIR"
|
||||
_combined_custom_log="$_log_dir/${_DOMAIN}-access.log"
|
||||
_error_log="$_log_dir/${_DOMAIN}-error.log"
|
||||
if [ -n "$__CUSTOM_IPV6_LOG" ]; then
|
||||
_custom_ipv6_log=/var/log/apache2/$__CUSTOM_IPV6_LOG
|
||||
fi
|
||||
if [ -n "$__CUSTOM_IPV4_LOG" ]; then
|
||||
_custom_ipv4_log=/var/log/apache2/$__CUSTOM_IPV4_LOG
|
||||
|
||||
if [ -n "$__CUSTOM_IP_LOG" ]; then
|
||||
_custom_ip_log=/var/log/apache2/$__CUSTOM_IP_LOG
|
||||
fi
|
||||
|
||||
fi # if [[ "$_type" != "REDIRECT" ]] ; then
|
||||
# if [ -n "$__CUSTOM_IPV6_LOG" ]; then
|
||||
# _custom_ipv6_log=/var/log/apache2/$__CUSTOM_IPV6_LOG
|
||||
# fi
|
||||
# if [ -n "$__CUSTOM_IPV4_LOG" ]; then
|
||||
# _custom_ipv4_log=/var/log/apache2/$__CUSTOM_IPV4_LOG
|
||||
# fi
|
||||
|
||||
fi # if [[ "$_type" != "REDIRECT" ]] && [[ "$_type" != "PARKED" ]] ; then
|
||||
|
||||
|
||||
if [[ -n "$(trim $VHOST_BASE_DIR)" ]]; then
|
||||
@ -1160,6 +1216,10 @@ else
|
||||
_custom_ipv6_log=""
|
||||
_custom_ipv6_log_failed=false
|
||||
|
||||
_found_custom_v4_log=false
|
||||
_found_custom_v6_log=false
|
||||
_found_custom_log=false
|
||||
|
||||
_error_log=""
|
||||
_error_log_failed=false
|
||||
|
||||
@ -1246,6 +1306,7 @@ else
|
||||
if echo $line | grep -e "^\s*CustomLog" | grep -i "ipv4" > /dev/null ; then
|
||||
_custom_ipv4_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'`
|
||||
if [ -n "$_custom_ipv4_log_tmp" ];then
|
||||
_found_custom_v4_log=true
|
||||
if [ -z "$_custom_ipv4_log" ]; then
|
||||
_custom_ipv4_log=$_custom_ipv4_log_tmp
|
||||
elif [ "$_custom_ipv4_log" != "$_custom_ipv4_log_tmp" ]; then
|
||||
@ -1259,24 +1320,56 @@ else
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
if $_found_custom_v4_log ; then
|
||||
_custom_ip_log="$(dirname "$_custom_ipv4_log")/ip_request.log"
|
||||
_found_custom_log=true
|
||||
fi
|
||||
|
||||
## - Get additional CustomLog IPv6 requests
|
||||
## -
|
||||
if echo $line | grep -e "^\s*CustomLog" | grep -i "ipv6" > /dev/null ; then
|
||||
_custom_ipv6_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'`
|
||||
if [ -n "$_custom_ipv6_log_tmp" ];then
|
||||
if [ -z "$_custom_ipv6_log" ]; then
|
||||
_custom_ipv6_log=$_custom_ipv6_log_tmp
|
||||
elif [ "$_custom_ipv6_log" != "$_custom_ipv6_log_tmp" ]; then
|
||||
if [ $number_warnings -eq 0 ]; then
|
||||
echo
|
||||
|
||||
if ! $_found_custom_log ; then
|
||||
## - Get additional CustomLog IPv6 requests
|
||||
## -
|
||||
if echo $line | grep -e "^\s*CustomLog" | grep -i "ipv6" > /dev/null ; then
|
||||
_custom_ipv6_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'`
|
||||
if [ -n "$_custom_ipv6_log_tmp" ];then
|
||||
if [ -z "$_custom_ipv6_log" ]; then
|
||||
_custom_ipv6_log=$_custom_ipv6_log_tmp
|
||||
elif [ "$_custom_ipv6_log" != "$_custom_ipv6_log_tmp" ]; then
|
||||
if [ $number_warnings -eq 0 ]; then
|
||||
echo
|
||||
fi
|
||||
warn "Misconfigured CustomLog IPv6 requests"
|
||||
_custom_ipv6_log_failed=true
|
||||
let number_warnings++
|
||||
fi
|
||||
warn "Misconfigured CustomLog IPv6 requests"
|
||||
_custom_ipv6_log_failed=true
|
||||
let number_warnings++
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
if $_found_custom_v6_log ; then
|
||||
_custom_ip_log="$(dirname "$_custom_ipv6_log")/ip_request.log"
|
||||
_found_custom_log=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! $_found_custom_log ; then
|
||||
## - Get additional CustomLog file
|
||||
## -
|
||||
if echo $line | grep -e "^\s*CustomLog" | grep -i "base_request" > /dev/null ; then
|
||||
_custom_ip_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'`
|
||||
if [ -n "$_custom_ip_log_tmp" ];then
|
||||
if [ -z "$_custom_ip_log" ]; then
|
||||
_custom_ip_log=$_custom_ip_log_tmp
|
||||
elif [ "$_custom_ip_log" != "$_custom_ip_log_tmp" ]; then
|
||||
if [ $number_warnings -eq 0 ]; then
|
||||
echo
|
||||
fi
|
||||
warn "Misconfigured CustomLog IP requests"
|
||||
_custom_ip_log_failed=true
|
||||
let number_warnings++
|
||||
fi
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
## - Get ErrorLog
|
||||
@ -1871,12 +1964,15 @@ if $_print_summary ; then
|
||||
echo "Logfile Directory.................: $_log_dir"
|
||||
echo " CustomLog......................: $_combined_custom_log"
|
||||
echo " ErrorLog.......................: $_error_log"
|
||||
if [ -n "$_custom_ipv4_log" ]; then
|
||||
echo " Additional Logfile IPv4........: $_custom_ipv4_log"
|
||||
fi
|
||||
if [ -n "$_custom_ipv6_log" ]; then
|
||||
echo " Additional Logfile IPv6........: $_custom_ipv6_log"
|
||||
if [ -n "$_custom_ip_log" ]; then
|
||||
echo " Additional Logfile ............: $_custom_ip_log"
|
||||
fi
|
||||
# if [ -n "$_custom_ipv4_log" ]; then
|
||||
# echo " Additional Logfile IPv4........: $_custom_ipv4_log"
|
||||
# fi
|
||||
# if [ -n "$_custom_ipv6_log" ]; then
|
||||
# echo " Additional Logfile IPv6........: $_custom_ipv6_log"
|
||||
# fi
|
||||
echo ""
|
||||
echo "VHost Base Directory..............: $_vhost_base_dir"
|
||||
echo "VHost configuration file..........: $_new_vhost_config_file"
|
||||
@ -1941,10 +2037,10 @@ EOF
|
||||
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/
|
||||
RewriteRule (.*) http://${rewrite_url} [R=301,L]
|
||||
EOF
|
||||
if [ -n "$_custom_ipv4_log" ]; then
|
||||
if [ -n "$_custom_ip_log" ]; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
CustomLog $_custom_ipv4_log base_requests
|
||||
CustomLog $_custom_ip_log base_requests
|
||||
EOF
|
||||
if [ "$?" != "0" ]; then
|
||||
_failed=true
|
||||
@ -1995,10 +2091,10 @@ EOF
|
||||
_failed=true
|
||||
fi
|
||||
|
||||
if [ -n "$_custom_ipv4_log" ]; then
|
||||
if [ -n "$_custom_ip_log" ]; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
CustomLog $_custom_ipv4_log base_requests
|
||||
CustomLog $_custom_ip_log base_requests
|
||||
EOF
|
||||
if [ "$?" != "0" ]; then
|
||||
_failed=true
|
||||
@ -2823,10 +2919,10 @@ else
|
||||
EOF
|
||||
fi # if [ "$_type" = "FCGID" ]; then
|
||||
|
||||
if [ -n "$_custom_ipv4_log" ]; then
|
||||
if [ -n "$_custom_ip_log" ]; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
CustomLog $_custom_ipv4_log base_requests
|
||||
CustomLog $_custom_ip_log base_requests
|
||||
EOF
|
||||
fi
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
@ -2937,10 +3033,10 @@ EOF
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ -n "$_custom_ipv4_log" ]; then
|
||||
if [ -n "$_custom_ip_log" ]; then
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
||||
CustomLog $_custom_ipv4_log base_requests
|
||||
CustomLog $_custom_ip_log base_requests
|
||||
EOF
|
||||
fi
|
||||
cat <<EOF >> ${_new_vhost_config_file}
|
||||
|
Loading…
x
Reference in New Issue
Block a user