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/* /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 #!/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 echo
[ -n "$1" ] && echo -e "Error: $1\n" [ -n "$1" ] && echo -e "Error: $1\n"
@ -27,37 +30,130 @@ cat<<EOF
Prints this help. Prints this help.
-C -C
Don't create \"phpinfo\"-file. The defaualt is to create Don't create "phpinfo"-file. The defaualt is to create
file phpinfo.php. file phpinfo.php.
-p <path to fcgi configuration directory> -l <common-logfile-dir>
Only used if type is fcgi (\"-t FCGID\"). If given, a common 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. existing configuration directory will be used for FCGI configurations.
if not given, a site-specific configuration directory will be if not given, a site-specific configuration directory will be
created. created.
-t <type> -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. If not give, the site url will be requested.
-S <unix socket for php-fpm> -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 -q
Don't print summary before starting creation the vhost entry Don't print summary before starting creation the vhost entry
is set is set
-u <site url> -u <site-url>
i.e. www.oopen.de i.e. www.oopen.de
If not give, the site url will be requested. 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 EOF
exit 1 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="" __major_php_verisons=""
_php_installation_dirs=`find /usr/local -mindepth 1 -maxdepth 1 -type l -name "*php-*" -print | sort` _php_installation_dirs=`find /usr/local -mindepth 1 -maxdepth 1 -type l -name "*php-*" -print | sort`
for dir in $_php_installation_dirs ; do for dir in $_php_installation_dirs ; do
@ -66,80 +162,14 @@ for dir in $_php_installation_dirs ; do
done done
_major_php_verisons=`echo "$__major_php_verisons" | sed 's/^ *//'` _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`" __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`" __ipv6="`ifconfig | grep -e \"^\s*inet6-Adresse\" | awk '{print$2}' | grep -v -e \"^::1/\" | grep -v -e \"^fe80\" | cut -d\"/\" -f1 | sort | head -1`"
# - Determin httpd binary
## - Needed for PHP-FPM environment # -
## -
## - Default values
## -
_tcp_host=127.0.0.1
_tcp_port=9000
## - Determin httpd binary
## -
_httpd_binary="`which httpd`" _httpd_binary="`which httpd`"
if [ -z "$_httpd_binary" ]; then if [ -z "$_httpd_binary" ]; then
_httpd_binary="`ps -C httpd -f | grep -e \"^root\" | awk '{print$8}'`" _httpd_binary="`ps -C httpd -f | grep -e \"^root\" | awk '{print$8}'`"
@ -150,10 +180,8 @@ if [ -z "$_httpd_binary" ]; then
fi fi
fi fi
_base_webserver_info_needed=false # - Determin websever user/group
## - Determin websever user # -
## -
_pass_web_user=false
web_user="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" 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 '"'`" 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 if [ -z "$web_user" -o -z "$web_group" ]; then
@ -162,10 +190,8 @@ else
_pass_web_user=true _pass_web_user=true
fi fi
# - Determin ServerRoot Directory
## - Determin ServerRoot Directory # -
## -
_pass_apache_base_dir=false
apache_base_dir=`$_httpd_binary -t -D DUMP_RUN_CFG | grep ServerRoot | awk '{print$2}' | tr -d '"'` 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 if [ "`realpath /usr/local/apache2`" = "$apache_base_dir" ]; then
apache_base_dir="/usr/local/apache2" apache_base_dir="/usr/local/apache2"
@ -184,10 +210,8 @@ else
_pass_apache_base_dir=true _pass_apache_base_dir=true
fi fi
# - Determin (default) ServerAdmin E-Mail Address"
## - Determin (default) ServerAdmin E-Mail Address" # -
## -
_pass_server_admin=false
if [ -f "${apache_base_dir}/conf/httpd.conf" ]; then 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}'`" server_admin="`cat ${apache_base_dir}/conf/httpd.conf | grep ServerAdmin | grep -v -e \"^\s*#\" | awk '{print$2}'`"
fi fi
@ -197,82 +221,119 @@ else
_pass_server_admin=true _pass_server_admin=true
fi fi
## - Determine the installed different PHP major versions
## - # ---
#__major_php_verisons="" # - Set Default Values
#_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##*-}" # - Needed for PHP-FPM environment
# __major_php_verisons="$__major_php_verisons $_major_version" # -
#done
#_major_php_verisons=`echo "$__major_php_verisons" | sed 's/^ *//'` _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) echo ""
containsElement () { echononl "\tInclude Configuration file.."
local e if [[ ! -f $conf_file ]]; then
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done echo_skipped
return 1 else
} source $conf_file > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echononl(){ echo_ok
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo "$*\\c" 1>&2
else else
echo -e -n "$*" 1>&2 echo_failed
error "$(cat $log_file)"
fi fi
rm /tmp/shprompt$$ fi
}
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 ""
}
error (){ # ---
echo "" # - Read in Commandline arguments
echo -e "\t[ \033[31m\033[1mError\033[m ]: $*" # -
echo "" # - 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\".." echo "Create Configuration for site \"$site_url\".."
fi 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 ""
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
echo "" echo ""
@ -519,13 +597,17 @@ if [ -z "$_existing_vhost_config_file" ]; then
_DOMAIN=$_HOST _DOMAIN=$_HOST
fi fi
if [ -d "/var/www/html/projekte" ]; then if [[ -n "$(trim $WEBSITES_ROOT_DIR)" ]]; then
__server_website_root_dir="/var/www/html/projekte" _server_website_root_dir="$WEBSITES_ROOT_DIR"
elif [ -d "/var/www" ]; then else
__server_website_root_dir="/var/www" 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 fi
#clear
echo "" echo ""
if [ "$_HOST" = "www" ]; then if [ "$_HOST" = "www" ]; then
echo -e "\033[21G\033[32mCreate vhost configuration \"${_DOMAIN}.${_TDL}.conf.$_new_extension\"\033[m" 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 -e "\033[21GInsert needed Information for VHost Configuration.."
echo "" echo ""
echo "" if [[ -z "$_server_website_root_dir" ]]; then
echo -e "\033[32m--\033[m" echo ""
echo "" echo -e "\033[32m--\033[m"
echo "Servers root directory for websites (i.e. /var/www).." echo ""
echo "" echo "Servers root directory for websites (i.e. /var/www).."
echo "" echo ""
_server_website_root_dir= echo ""
while [ "X$_server_website_root_dir" = "X" ] ; do _server_website_root_dir=
echononl "Root Directory for websites [$__server_website_root_dir]: " while [ "X$_server_website_root_dir" = "X" ] ; do
read _doc_root echononl "Root Directory for websites [$__server_website_root_dir]: "
if [ "X$_server_website_root_dir" = "X" ]; then read _doc_root
_server_website_root_dir=$__server_website_root_dir if [ "X$_server_website_root_dir" = "X" ]; then
fi _server_website_root_dir=$__server_website_root_dir
if [ -n "$_server_website_root_dir" -a ! -d "$_server_website_root_dir" ]; then fi
echo -e "\n\t\033[1;33mDirectory \"$_server_website_root_dir\" does not exist.\n\tTry again..\033[m\n" if [ -n "$_server_website_root_dir" -a ! -d "$_server_website_root_dir" ]; then
_server_website_root_dir="" echo -e "\n\t\033[1;33mDirectory \"$_server_website_root_dir\" does not exist.\n\tTry again..\033[m\n"
fi _server_website_root_dir=""
done fi
done
fi
if [ "$_HOST" = "www" ]; then if $USE_PROJECT_NAME ; then
__web_base_dir=${_server_website_root_dir}/${_DOMAIN}.$_TDL __web_base_dir=${_server_website_root_dir}/$PROJECT_NAME
else 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 fi
_server_name=$site_url _server_name=$site_url
@ -589,37 +677,40 @@ if [ -z "$_existing_vhost_config_file" ]; then
__document_root=${_web_base_dir}/htdocs __document_root=${_web_base_dir}/htdocs
echo "" if $CREATE_SYMLINK_WEB_BASE_DIR ; then
echo -e "\033[32m--\033[m" __symlink_web_base_dir=`basename $_web_base_dir | cut -d '.' -f 1`
echo "" if [[ "$__symlink_web_base_dir" != "$(basename $_web_base_dir)" ]] ; then
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 ""
__symlink_web_base_dir=`basename $_web_base_dir | cut -d '.' -f 1` echo ""
echononl "Create Symlink for `basename $_web_base_dir`? [$__symlink_web_base_dir]: " echo -e "\033[32m--\033[m"
read _symlink_web_base_dir echo ""
if [ "X$_symlink_web_base_dir" = "Xnone" -o "X$_symlink_web_base_dir" = "XNone" ]; then echo "It is possible to create a symlink for \"`basename $_web_base_dir`\". You can do"
_create_symlink_web_base_dir=false echo "that here bygiving a name for the symlink."
else echo ""
_create_symlink_web_base_dir=true echo -e "Type \"\033[33mNone\033[m\" if no symlink is wanted."
fi echo ""
if [ "X$_symlink_web_base_dir" = "X" ]; then echo ""
_symlink_web_base_dir=$__symlink_web_base_dir
fi echononl "Create Symlink for `basename $_web_base_dir`? [$__symlink_web_base_dir]: "
if [ "$_symlink_web_base_dir" = "`basename $_web_base_dir`" ]; then read _symlink_web_base_dir
warn "Given name for symlink is equal to `basename $_web_base_dir`.\n\t No symlink will be created.." if [ "X$_symlink_web_base_dir" = "Xnone" -o "X$_symlink_web_base_dir" = "XNone" ]; then
_create_symlink_web_base_dir=false 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 fi
__log_dir=${_web_base_dir}/logs
__vhost_base_dir=${apache_base_dir}/conf/vhosts
echo "" echo ""
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
echo "" echo ""
@ -640,21 +731,30 @@ if [ -z "$_existing_vhost_config_file" ]; then
done done
echo "" if [[ -n "$(trim $COMMON_LOGFILE_DIR)" ]]; then
echo "" _log_dir="$COMMON_LOGFILE_DIR"
echo -e "\033[32m--\033[m" else
echo "" __log_dir=${_web_base_dir}/logs
echo "Insert Directory where logfiles should stay.." fi
echo ""
echo "" if [[ -z "$_log_dir" ]]; then
_log_dir= echo ""
while [ "X$_log_dir" = "X" ] ; do echo ""
echononl "Log Directory [$__log_dir]: " echo -e "\033[32m--\033[m"
read _log_dir echo ""
if [ "X$_log_dir" = "X" ]; then echo "Insert Directory where logfiles should stay.."
_log_dir=$__log_dir echo ""
fi echo ""
done _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 if [ "$_HOST" = "www" ]; then
_combined_custom_log="$_log_dir/${_DOMAIN}-access.log" _combined_custom_log="$_log_dir/${_DOMAIN}-access.log"
_error_log="$_log_dir/${_DOMAIN}-error.log" _error_log="$_log_dir/${_DOMAIN}-error.log"
@ -715,25 +815,34 @@ if [ -z "$_existing_vhost_config_file" ]; then
fi fi
echo "" if [[ -n "$(trim $VHOST_BASE_DIR)" ]]; then
echo "" _vhost_base_dir="$VHOST_BASE_DIR"
echo -e "\033[32m--\033[m" else
echo "" __vhost_base_dir=${apache_base_dir}/conf/vhosts
echo "Insert Directory where the vhost configuration file should stay.." fi
echo ""
echo "" if [[ -z "$_vhost_base_dir" ]]; then
_vhost_base_dir= echo ""
while [ "X$_vhost_base_dir" = "X" ] ; do echo ""
echononl "VHost Base Directory [$__vhost_base_dir]: " echo -e "\033[32m--\033[m"
read _vhost_base_dir echo ""
if [ "X$_vhost_base_dir" = "X" ]; then echo "Insert Directory where the vhost configuration file should stay.."
_vhost_base_dir=$__vhost_base_dir echo ""
fi echo ""
if [ ! -d "$_vhost_base_dir" ];then _vhost_base_dir=
echo -e "\n\t\033[1;33mDirectory \"${_vhost_base_dir}\" not found! Try again..\033[m\n" while [ "X$_vhost_base_dir" = "X" ] ; do
_vhost_base_dir="" echononl "VHost Base Directory [$__vhost_base_dir]: "
fi read _vhost_base_dir
done 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 if [ "$_HOST" = "www" ]; then
_new_vhost_config_file=${_vhost_base_dir}/${_DOMAIN}.${_TDL}.conf.$_new_extension _new_vhost_config_file=${_vhost_base_dir}/${_DOMAIN}.${_TDL}.conf.$_new_extension
else 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 -e "\033[21G\033[32mCreate environment for site \033[m$site_url\033[32m :\033[m"
echo "" echo ""
if [[ -n "$PROJECT_NAME" ]]; then
echo ""
echo -e "Project Name......................: \033[1m$PROJECT_NAME\033[m"
fi
echo "" echo ""
echo -e "PHP environment...................: \033[33m\033[1m${_type_msg}\033[m" echo -e "PHP environment...................: \033[33m\033[1m${_type_msg}\033[m"
if [ "$_type" = "FCGID" ]; then if [ "$_type" = "FCGID" ]; then
@ -1622,7 +1735,7 @@ if $_print_summary ; then
echo "ServerAlias(es)...................: ${_server_aliases_arr[@]}" echo "ServerAlias(es)...................: ${_server_aliases_arr[@]}"
echo "" echo ""
echo "Base Directory for site...........: $_web_base_dir" 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" echo "Symlink for Base Directory........: `dirname $_web_base_dir`/$_symlink_web_base_dir"
fi fi
echo "Document Root Directory...........: $_doc_root" echo "Document Root Directory...........: $_doc_root"
@ -1764,24 +1877,21 @@ else
echo_skipped echo_skipped
fi fi
echononl "\tChange owner of Web Base directory \"$_web_base_dir\".."
echononl "\tCreate \"DocumentRoot\" directory.." if $_suEXEC ; then
if [ ! -d "$_doc_root" ]; then chown -R ${suEXEC_user}:$suEXEC_group $_web_base_dir
mkdir $_doc_root
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot create document root directory \"$_doc_root\"."
fatal
fi
else 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 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`" echononl "\tCreate Symlink $_symlink_web_base_dir --> `basename $_web_base_dir`"
if [ -h "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then if [ -h "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then
echo_skipped echo_skipped
@ -1800,6 +1910,22 @@ if $_create_symlink_web_base_dir ; then
fi 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.." echononl "\tChange owner of \"DocumentRoot\" directory.."
if $_suEXEC ; then if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_doc_root chown -R ${suEXEC_user}:$suEXEC_group $_doc_root
@ -2825,7 +2951,7 @@ else
fi fi
echononl "\tCreate \"phpinfo.php\" file.." echononl "\tCreate \"phpinfo.php\" file.."
if $create_phpinfo_file ; then if $CREATE_PHPINFO_FILE ; then
if [ ! -f "${_doc_root}/phpinfo.php" ]; then if [ ! -f "${_doc_root}/phpinfo.php" ]; then
cat <<EOF > ${_doc_root}/phpinfo.php cat <<EOF > ${_doc_root}/phpinfo.php
<html> <html>
@ -2882,6 +3008,7 @@ if $_syntax_ok ; then
fi fi
rm -f $log_file
echo echo
echo echo
exit 0 exit 0