Add non obligatoric configuration file.

Add posibility to give project name in order to name website basedirectory.
Some minor changes.
This commit is contained in:
Christoph 2017-03-07 04:43:33 +01:00
parent 9472a46bea
commit c74c424481
3 changed files with 450 additions and 265 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/BAK/*
/conf/*.conf

View File

@ -0,0 +1,57 @@
## ===================================================================
## - Configuration File for "create_vhost_php.sh" Script
## ===================================================================
# ----------
# - Note:
# -
# - - Presens of this configuration file is not required.
# -
# - - Settings here overwrites the script defaults
# -
# - - Settings here can be overwritten by commandline parameters.
# ----------
# - Place phpinfo file into documentroot directory
# -
# - Defaults to 'true'
# -
#CREATE_PHPINFO_FILE=
# - Use Projectname instead of main-domain.tld as wensites base directory
# -
# - Defaults to 'false'
# -
#USE_PROJECT_NAME=
# - Where to store apache log files
# -
# - Only usefull, if you all logfiles are stored in a common logfile-directory.
# -
# - Example:
# - COMMON_LOGFILE_DIR="/var/log/apache2"
# -
#COMMON_LOGFILE_DIR=""
# - Where to store vhost configuration files
# -
# - Example:
#- VHOST_BASE_DIR="/usr/local/apache2/conf/vhosts/0"
# -
#VHOST_BASE_DIR=""
# - Directory, where all the website's base directoties are stored.
# -
# - If not set, script tries to determine it.
# -
# - Example:
#- WEBSITES_ROOT_DIR="/var/www/html/projekte"
# -
#WEBSITES_ROOT_DIR=""
# - Create Symlink for Website's Base Directory
# -
# - Defaults to 'false'
# -
#CREATE_SYMLINK_WEB_BASE_DIR=

View File

@ -1,10 +1,13 @@
#!/usr/bin/env bash
#_COMMON_FCGID_CONFIG_PATH=/var/www/html/projekte/_FCGI_DEFAULT
__CUSTOM_IPV4_LOG=ipv4_requests.log
__CUSTOM_IPV6_LOG=ipv6_requests.log
function usage() {
log_file="$(mktemp)"
## ---
## --- Some functions
## ---
usage() {
echo
[ -n "$1" ] && echo -e "Error: $1\n"
@ -27,37 +30,130 @@ cat<<EOF
Prints this help.
-C
Don't create \"phpinfo\"-file. The defaualt is to create
Don't create "phpinfo"-file. The defaualt is to create
file phpinfo.php.
-p <path to fcgi configuration directory>
Only used if type is fcgi (\"-t FCGID\"). If given, a common
-l <common-logfile-dir>
If set, logfiles for the new site will go there.
-n <project-name>
If set, project name will be used as name of the websites
base directory. Otherwise <domain>.<tld> or <sub-domain>.<domain>.<tld>
will be used.
-p <path-to-common-fcgi-configuration-directory>
Only used if type is fcgi ("-t FCGID"). If given, a common
existing configuration directory will be used for FCGI configurations.
if not given, a site-specific configuration directory will be
created.
-t <type>
One of \"PHP-FPM\", \"FCGID\" or \"MOD_PHP\"
One of "PHP-FPM", "FCGID" or "MOD_PHP"
If not give, the site url will be requested.
-S <unix socket for php-fpm>
Only used if type is php-fpm (\"-t PHP-FPM\").
Only used if type is php-fpm ("-t PHP-FPM").
-q
Don't print summary before starting creation the vhost entry
is set
-u <site url>
-u <site-url>
i.e. www.oopen.de
If not give, the site url will be requested.
-V <path-to-apache-vhost-dir>
If set, vhost configuration will be stored there.
-v <php-major-version>
i.e 5.6
If not give, the PHP version will be requested.
EOF
exit 1
}
## - Determine the installed different PHP major versions
## -
# - Check if a given array (parameter 2) contains a given string (parameter 1)
# -
containsElement () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
# - Remove leading/trailling whitespaces
# -
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo "$*\\c" 1>&2
else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
}
fatal(){
echo ""
if [ "X$*" != "X" ]; then
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*"
echo ""
fi
echo -e "\t\033[31m\033[1mExiting installation now..\033[m"
echo ""
rm -f $log_file
exit 1
}
info (){
echo ""
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
}
warn (){
echo ""
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
echo ""
}
error (){
echo ""
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*"
echo ""
}
echo_ok() {
echo -e "\033[85G[ \033[32mok\033[m ]"
## echo -e " [ ok ]"
}
echo_failed(){
echo -e "\033[85G[ \033[1;31mfailed\033[m ]"
## echo -e " [ failed ]"
}
echo_skipped() {
echo -e "\033[85G[ \033[30m\033[1mskipped\033[m ]"
}
## ---
## --- END: functions
## ---
# ---
# - Try to determin some server settings
# ---
_base_webserver_info_needed=false
_pass_apache_base_dir=false
_pass_web_user=false
_pass_server_admin=false
# - Determine the installed different PHP major versions
# -
__major_php_verisons=""
_php_installation_dirs=`find /usr/local -mindepth 1 -maxdepth 1 -type l -name "*php-*" -print | sort`
for dir in $_php_installation_dirs ; do
@ -66,80 +162,14 @@ for dir in $_php_installation_dirs ; do
done
_major_php_verisons=`echo "$__major_php_verisons" | sed 's/^ *//'`
## - Defaults
## -
_suEXEC=false
_auto=""
create_phpinfo_file=true
site_url=""
_type=""
_COMMON_FCGID_CONFIG_PATH=""
_UNIX_FPM_SOCKET=""
major_php_verison=""
_print_summary=true
_create_symlink_web_base_dir=false
_symlink_web_base_dir=""
while getopts aChp:sS:t:u:v: opt ; do
case $opt in
a) _auto="auto" ;;
C) create_phpinfo_file="false" ;;
h) usage ;;
p) if [ -n "$OPTARG" -a -d "$OPTARG" ]; then
_COMMON_FCGID_CONFIG_PATH=$OPTARG
fi
;;
q) _print_summary=false ;;
S) if [ -n "$OPTARG" -a -S "$OPTARG" ]; then
unix_socket=$OPTARG
connection="unix_socket"
_connection_msg="Unix Socket"
fi
;;
t) if [ "$OPTARG" = "PHP-FPM" -o "$OPTARG" = "FCGID" -o "$OPTARG" = "MOD_PHP" ]; then
_type=$OPTARG
fi
;;
u) site_url=$OPTARG ;;
v)
for _version in $_major_php_verisons ; do
if [ "$OPTARG" = "$_version" ]; then
major_php_verison=$OPTARG
fi
done
;;
\?) usage
esac
done
#echo
#echo "_auto..............: $_auto"
#echo "site_url...........: $site_url"
#echo "_type..............: $_type"
#echo "fcgi_common_path...: $_COMMON_FCGID_CONFIG_PATH"
#echo "unix_socket........: $unix_socket"
#echo "major_php_verison..: $major_php_verison"
#echo "_print_summary.....: $_print_summary"
#echo
#__ipv4="83.223.86.164"
#__ipv6="2a01:30:1fff:a::164"
# - Determin IP Addresses
# -
__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`"
## - Needed for PHP-FPM environment
## -
## - Default values
## -
_tcp_host=127.0.0.1
_tcp_port=9000
## - Determin httpd binary
## -
# - Determin httpd binary
# -
_httpd_binary="`which httpd`"
if [ -z "$_httpd_binary" ]; then
_httpd_binary="`ps -C httpd -f | grep -e \"^root\" | awk '{print$8}'`"
@ -150,10 +180,8 @@ if [ -z "$_httpd_binary" ]; then
fi
fi
_base_webserver_info_needed=false
## - Determin websever user
## -
_pass_web_user=false
# - Determin websever user/group
# -
web_user="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
web_group="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
if [ -z "$web_user" -o -z "$web_group" ]; then
@ -162,10 +190,8 @@ else
_pass_web_user=true
fi
## - Determin ServerRoot Directory
## -
_pass_apache_base_dir=false
# - Determin ServerRoot Directory
# -
apache_base_dir=`$_httpd_binary -t -D DUMP_RUN_CFG | grep ServerRoot | awk '{print$2}' | tr -d '"'`
if [ "`realpath /usr/local/apache2`" = "$apache_base_dir" ]; then
apache_base_dir="/usr/local/apache2"
@ -184,10 +210,8 @@ else
_pass_apache_base_dir=true
fi
## - Determin (default) ServerAdmin E-Mail Address"
## -
_pass_server_admin=false
# - Determin (default) ServerAdmin E-Mail Address"
# -
if [ -f "${apache_base_dir}/conf/httpd.conf" ]; then
server_admin="`cat ${apache_base_dir}/conf/httpd.conf | grep ServerAdmin | grep -v -e \"^\s*#\" | awk '{print$2}'`"
fi
@ -197,82 +221,119 @@ else
_pass_server_admin=true
fi
## - Determine the installed different PHP major versions
## -
#__major_php_verisons=""
#_php_installation_dirs=`find /usr/local -mindepth 1 -maxdepth 1 -type l -name "*php-*" -print | sort`
#for dir in $_php_installation_dirs ; do
# _major_version="${dir##*-}"
# __major_php_verisons="$__major_php_verisons $_major_version"
#done
#_major_php_verisons=`echo "$__major_php_verisons" | sed 's/^ *//'`
# ---
# - Set Default Values
# ----
# - Needed for PHP-FPM environment
# -
_tcp_host=127.0.0.1
_tcp_port=9000
__CUSTOM_IPV4_LOG=ipv4_requests.log
__CUSTOM_IPV6_LOG=ipv6_requests.log
_suEXEC=false
_auto=""
site_url=""
_type=""
_COMMON_FCGID_CONFIG_PATH=""
major_php_verison=""
_print_summary=true
_symlink_web_base_dir=""
CREATE_PHPINFO_FILE=true
USE_PROJECT_NAME=false
PROJECT_NAME=""
COMMON_LOGFILE_DIR=""
VHOST_DIR=""
WEBSITES_ROOT_DIR=""
CREATE_SYMLINK_WEB_BASE_DIR=false
# ---
# - Read Configuration File (if exists)
# -
# - Note: previously Default Settings will be overwriten
# ---
## --- Some functions
## ---
script_base_dir="$(realpath $(dirname $0))"
conf_file="${script_base_dir}/conf/create_vhost_php.conf"
## Check if a given array (parameter 2) contains a given string (parameter 1)
containsElement () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo "$*\\c" 1>&2
echo ""
echononl "\tInclude Configuration file.."
if [[ ! -f $conf_file ]]; then
echo_skipped
else
source $conf_file > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo -e -n "$*" 1>&2
echo_failed
error "$(cat $log_file)"
fi
rm /tmp/shprompt$$
}
fatal(){
echo ""
if [ "X$*" != "X" ]; then
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*"
echo ""
fi
echo -e "\t\033[31m\033[1mExiting installation now..\033[m"
echo ""
exit 1
}
info (){
echo ""
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
}
warn (){
echo ""
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
echo ""
}
fi
error (){
echo ""
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*"
echo ""
}
# ---
# - Read in Commandline arguments
# -
# - Note: previously Settings (also those from configuration file) will be overwriten
# ---
while getopts aChl:n:p:sS:t:u:V:v: opt ; do
case $opt in
a) _auto="auto" ;;
C) CREATE_PHPINFO_FILE="false" ;;
h) usage ;;
l) COMMON_LOGFILE_DIR="$OPTARG"
;;
n) USE_PROJECT_NAME=true
PROJECT_NAME="$OPTARG"
;;
p) if [ -n "$OPTARG" -a -d "$OPTARG" ]; then
_COMMON_FCGID_CONFIG_PATH=$OPTARG
fi
;;
q) _print_summary=false ;;
S) if [ -n "$OPTARG" -a -S "$OPTARG" ]; then
unix_socket=$OPTARG
connection="unix_socket"
_connection_msg="Unix Socket"
fi
;;
t) if [ "$OPTARG" = "PHP-FPM" -o "$OPTARG" = "FCGID" -o "$OPTARG" = "MOD_PHP" ]; then
_type=$OPTARG
fi
;;
u) site_url=$OPTARG ;;
V) VHOST_BASE_DIR="$OPTARG"
;;
v)
for _version in $_major_php_verisons ; do
if [ "$OPTARG" = "$_version" ]; then
major_php_verison=$OPTARG
fi
done
;;
\?) usage
esac
done
echo
echo "_auto..............: $_auto"
echo "site_url...........: $site_url"
echo "_type..............: $_type"
echo "COMMON_LOGFILE_DIR.: $COMMON_LOGFILE_DIR"
echo "PROJECT_NAME.......: $PROJECT_NAME"
echo "fcgi_common_path...: $_COMMON_FCGID_CONFIG_PATH"
echo "unix_socket........: $unix_socket"
echo "major_php_verison..: $major_php_verison"
echo "_print_summary.....: $_print_summary"
echo
echo_ok() {
echo -e "\033[85G[ \033[32mok\033[m ]"
## echo -e " [ ok ]"
}
echo_failed(){
echo -e "\033[85G[ \033[1;31mfailed\033[m ]"
## echo -e " [ failed ]"
}
echo_skipped() {
echo -e "\033[85G[ \033[33m\033[1mskipped\033[m ]"
}
## ---
## --- END: functions
## --------------------------------------------------
@ -302,6 +363,23 @@ else
echo "Create Configuration for site \"$site_url\".."
fi
if $USE_PROJECT_NAME && [[ -z "$PROJECT_NAME" ]]; then
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Insert Project Name."
echo ""
echo ""
PROJECT_NAME=
echononl "Project Name: "
read PROJECT_NAME
while [[ -z "$(trim $PROJECT_NAME)" ]] ; do
echo -e "\n\t\033[33m\033[1mEingabe erforderlich.\033[m\n"
echononl "Project Name: "
read PROJECT_NAME
done
fi
echo ""
echo -e "\033[32m--\033[m"
echo ""
@ -519,13 +597,17 @@ if [ -z "$_existing_vhost_config_file" ]; then
_DOMAIN=$_HOST
fi
if [ -d "/var/www/html/projekte" ]; then
__server_website_root_dir="/var/www/html/projekte"
elif [ -d "/var/www" ]; then
__server_website_root_dir="/var/www"
if [[ -n "$(trim $WEBSITES_ROOT_DIR)" ]]; then
_server_website_root_dir="$WEBSITES_ROOT_DIR"
else
if [ -d "/var/www/html/projekte" ]; then
__server_website_root_dir="/var/www/html/projekte"
elif [ -d "/var/www" ]; then
__server_website_root_dir="/var/www"
fi
fi
#clear
echo ""
if [ "$_HOST" = "www" ]; then
echo -e "\033[21G\033[32mCreate vhost configuration \"${_DOMAIN}.${_TDL}.conf.$_new_extension\"\033[m"
@ -536,29 +618,35 @@ if [ -z "$_existing_vhost_config_file" ]; then
echo -e "\033[21GInsert needed Information for VHost Configuration.."
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Servers root directory for websites (i.e. /var/www).."
echo ""
echo ""
_server_website_root_dir=
while [ "X$_server_website_root_dir" = "X" ] ; do
echononl "Root Directory for websites [$__server_website_root_dir]: "
read _doc_root
if [ "X$_server_website_root_dir" = "X" ]; then
_server_website_root_dir=$__server_website_root_dir
fi
if [ -n "$_server_website_root_dir" -a ! -d "$_server_website_root_dir" ]; then
echo -e "\n\t\033[1;33mDirectory \"$_server_website_root_dir\" does not exist.\n\tTry again..\033[m\n"
_server_website_root_dir=""
fi
done
if [[ -z "$_server_website_root_dir" ]]; then
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Servers root directory for websites (i.e. /var/www).."
echo ""
echo ""
_server_website_root_dir=
while [ "X$_server_website_root_dir" = "X" ] ; do
echononl "Root Directory for websites [$__server_website_root_dir]: "
read _doc_root
if [ "X$_server_website_root_dir" = "X" ]; then
_server_website_root_dir=$__server_website_root_dir
fi
if [ -n "$_server_website_root_dir" -a ! -d "$_server_website_root_dir" ]; then
echo -e "\n\t\033[1;33mDirectory \"$_server_website_root_dir\" does not exist.\n\tTry again..\033[m\n"
_server_website_root_dir=""
fi
done
fi
if [ "$_HOST" = "www" ]; then
__web_base_dir=${_server_website_root_dir}/${_DOMAIN}.$_TDL
if $USE_PROJECT_NAME ; then
__web_base_dir=${_server_website_root_dir}/$PROJECT_NAME
else
__web_base_dir=${_server_website_root_dir}/${site_url}
if [ "$_HOST" = "www" ]; then
__web_base_dir=${_server_website_root_dir}/${_DOMAIN}.$_TDL
else
__web_base_dir=${_server_website_root_dir}/${site_url}
fi
fi
_server_name=$site_url
@ -589,37 +677,40 @@ if [ -z "$_existing_vhost_config_file" ]; then
__document_root=${_web_base_dir}/htdocs
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "It is possible to create a symlink for \"`basename $_web_base_dir`\". You can do"
echo "that here bygiving a name for the symlink."
echo ""
echo -e "Type \"\033[33mNone\033[m\" if no symlink is wanted."
echo ""
echo ""
if $CREATE_SYMLINK_WEB_BASE_DIR ; then
__symlink_web_base_dir=`basename $_web_base_dir | cut -d '.' -f 1`
if [[ "$__symlink_web_base_dir" != "$(basename $_web_base_dir)" ]] ; then
__symlink_web_base_dir=`basename $_web_base_dir | cut -d '.' -f 1`
echononl "Create Symlink for `basename $_web_base_dir`? [$__symlink_web_base_dir]: "
read _symlink_web_base_dir
if [ "X$_symlink_web_base_dir" = "Xnone" -o "X$_symlink_web_base_dir" = "XNone" ]; then
_create_symlink_web_base_dir=false
else
_create_symlink_web_base_dir=true
fi
if [ "X$_symlink_web_base_dir" = "X" ]; then
_symlink_web_base_dir=$__symlink_web_base_dir
fi
if [ "$_symlink_web_base_dir" = "`basename $_web_base_dir`" ]; then
warn "Given name for symlink is equal to `basename $_web_base_dir`.\n\t No symlink will be created.."
_create_symlink_web_base_dir=false
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "It is possible to create a symlink for \"`basename $_web_base_dir`\". You can do"
echo "that here bygiving a name for the symlink."
echo ""
echo -e "Type \"\033[33mNone\033[m\" if no symlink is wanted."
echo ""
echo ""
echononl "Create Symlink for `basename $_web_base_dir`? [$__symlink_web_base_dir]: "
read _symlink_web_base_dir
if [ "X$_symlink_web_base_dir" = "Xnone" -o "X$_symlink_web_base_dir" = "XNone" ]; then
CREATE_SYMLINK_WEB_BASE_DIR=false
else
CREATE_SYMLINK_WEB_BASE_DIR=true
fi
if [ "X$_symlink_web_base_dir" = "X" ]; then
_symlink_web_base_dir=$__symlink_web_base_dir
fi
if [ "$_symlink_web_base_dir" = "`basename $_web_base_dir`" ]; then
warn "Given name for symlink is equal to `basename $_web_base_dir`.\n\t No symlink will be created.."
CREATE_SYMLINK_WEB_BASE_DIR=false
fi
else
CREATE_SYMLINK_WEB_BASE_DIR=false
fi
fi
__log_dir=${_web_base_dir}/logs
__vhost_base_dir=${apache_base_dir}/conf/vhosts
echo ""
echo -e "\033[32m--\033[m"
echo ""
@ -640,21 +731,30 @@ if [ -z "$_existing_vhost_config_file" ]; then
done
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Insert Directory where logfiles should stay.."
echo ""
echo ""
_log_dir=
while [ "X$_log_dir" = "X" ] ; do
echononl "Log Directory [$__log_dir]: "
read _log_dir
if [ "X$_log_dir" = "X" ]; then
_log_dir=$__log_dir
fi
done
if [[ -n "$(trim $COMMON_LOGFILE_DIR)" ]]; then
_log_dir="$COMMON_LOGFILE_DIR"
else
__log_dir=${_web_base_dir}/logs
fi
if [[ -z "$_log_dir" ]]; then
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Insert Directory where logfiles should stay.."
echo ""
echo ""
_log_dir=
while [ "X$_log_dir" = "X" ] ; do
echononl "Log Directory [$__log_dir]: "
read _log_dir
if [ "X$_log_dir" = "X" ]; then
_log_dir=$__log_dir
fi
done
fi
if [ "$_HOST" = "www" ]; then
_combined_custom_log="$_log_dir/${_DOMAIN}-access.log"
_error_log="$_log_dir/${_DOMAIN}-error.log"
@ -715,25 +815,34 @@ if [ -z "$_existing_vhost_config_file" ]; then
fi
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Insert Directory where the vhost configuration file should stay.."
echo ""
echo ""
_vhost_base_dir=
while [ "X$_vhost_base_dir" = "X" ] ; do
echononl "VHost Base Directory [$__vhost_base_dir]: "
read _vhost_base_dir
if [ "X$_vhost_base_dir" = "X" ]; then
_vhost_base_dir=$__vhost_base_dir
fi
if [ ! -d "$_vhost_base_dir" ];then
echo -e "\n\t\033[1;33mDirectory \"${_vhost_base_dir}\" not found! Try again..\033[m\n"
_vhost_base_dir=""
fi
done
if [[ -n "$(trim $VHOST_BASE_DIR)" ]]; then
_vhost_base_dir="$VHOST_BASE_DIR"
else
__vhost_base_dir=${apache_base_dir}/conf/vhosts
fi
if [[ -z "$_vhost_base_dir" ]]; then
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Insert Directory where the vhost configuration file should stay.."
echo ""
echo ""
_vhost_base_dir=
while [ "X$_vhost_base_dir" = "X" ] ; do
echononl "VHost Base Directory [$__vhost_base_dir]: "
read _vhost_base_dir
if [ "X$_vhost_base_dir" = "X" ]; then
_vhost_base_dir=$__vhost_base_dir
fi
if [ ! -d "$_vhost_base_dir" ];then
echo -e "\n\t\033[1;33mDirectory \"${_vhost_base_dir}\" not found! Try again..\033[m\n"
_vhost_base_dir=""
fi
done
fi
if [ "$_HOST" = "www" ]; then
_new_vhost_config_file=${_vhost_base_dir}/${_DOMAIN}.${_TDL}.conf.$_new_extension
else
@ -1567,6 +1676,10 @@ if $_print_summary ; then
echo -e "\033[21G\033[32mCreate environment for site \033[m$site_url\033[32m :\033[m"
echo ""
if [[ -n "$PROJECT_NAME" ]]; then
echo ""
echo -e "Project Name......................: \033[1m$PROJECT_NAME\033[m"
fi
echo ""
echo -e "PHP environment...................: \033[33m\033[1m${_type_msg}\033[m"
if [ "$_type" = "FCGID" ]; then
@ -1622,7 +1735,7 @@ if $_print_summary ; then
echo "ServerAlias(es)...................: ${_server_aliases_arr[@]}"
echo ""
echo "Base Directory for site...........: $_web_base_dir"
if $_create_symlink_web_base_dir ; then
if $CREATE_SYMLINK_WEB_BASE_DIR ; then
echo "Symlink for Base Directory........: `dirname $_web_base_dir`/$_symlink_web_base_dir"
fi
echo "Document Root Directory...........: $_doc_root"
@ -1764,24 +1877,21 @@ else
echo_skipped
fi
echononl "\tCreate \"DocumentRoot\" directory.."
if [ ! -d "$_doc_root" ]; then
mkdir $_doc_root
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot create document root directory \"$_doc_root\"."
fatal
fi
echononl "\tChange owner of Web Base directory \"$_web_base_dir\".."
if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_web_base_dir
else
echo_skipped
chown -R ${web_user}:${web_group} $_web_base_dir
fi
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot change owner of web base directory \"$_web_base_dir\""
fatal
fi
if $_create_symlink_web_base_dir ; then
if $CREATE_SYMLINK_WEB_BASE_DIR ; then
echononl "\tCreate Symlink $_symlink_web_base_dir --> `basename $_web_base_dir`"
if [ -h "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then
echo_skipped
@ -1800,6 +1910,22 @@ if $_create_symlink_web_base_dir ; then
fi
echononl "\tCreate \"DocumentRoot\" directory.."
if [ ! -d "$_doc_root" ]; then
mkdir $_doc_root
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot create document root directory \"$_doc_root\"."
fatal
fi
else
echo_skipped
fi
echononl "\tChange owner of \"DocumentRoot\" directory.."
if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_doc_root
@ -2825,7 +2951,7 @@ else
fi
echononl "\tCreate \"phpinfo.php\" file.."
if $create_phpinfo_file ; then
if $CREATE_PHPINFO_FILE ; then
if [ ! -f "${_doc_root}/phpinfo.php" ]; then
cat <<EOF > ${_doc_root}/phpinfo.php
<html>
@ -2882,6 +3008,7 @@ if $_syntax_ok ; then
fi
rm -f $log_file
echo
echo
exit 0