Difference between revisions of "SME Site Maker"

From SME Server
Jump to navigationJump to search
Line 14: Line 14:
  
 
----
 
----
<nowiki>#!/bin/bash
 
  
# Author: Normando Hall (PicsOne)
+
Code:
# Version: 1.0
 
# 06/06/2007
 
  
clear
+
#!/bin/bash
echo "========================================================"
+
echo "=                SME Site Maker Script                ="
+
# Author: Normando Hall (PicsOne)
echo "=                                                      ="
+
# Version: 1.0
echo "= This script will configure your SME webserver, and  ="
+
# 06/06/2007
echo "= make the necesary directory to hold your site.      ="
+
echo "=                                                      ="
+
clear
echo "= No express or implied warranties are provided and its="
+
echo "========================================================"
echo "= usage is at your own risk.                          ="
+
echo "=                SME Site Maker Script                ="
echo "=                                                      ="
+
echo "=                                                      ="
echo "= If you feel confortable with the above then press    ="
+
echo "= This script will configure your SME webserver, and  ="
echo "= enter if not press Ctrl+C to abort the configuration ="
+
echo "= make the necesary directory to hold your site.      ="
echo "= script.                                              ="
+
echo "=                                                      ="
echo "=                                                      ="
+
echo "= No express or implied warranties are provided and its="
echo "========================================================"
+
echo "= usage is at your own risk.                          ="
read x
+
echo "=                                                      ="
custom_httpd_dir=/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
+
echo "= If you feel confortable with the above then press    ="
clear
+
echo "= enter if not press Ctrl+C to abort the configuration ="
######################### - Site ROOT - ##################################3
+
echo "= script.                                              ="
f_root=""
+
echo "=                                                      ="
ANSWER=1
+
echo "========================================================"
while [ $ANSWER = 1 ]
+
read x
do
+
custom_httpd_dir=/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
        clear
+
clear
        echo " Please enter a directory name where you put the site files."
+
######################### - Site ROOT - ##################################3
echo " The directory is created under /opt dir."
+
f_root=""
        echo " Example \"mySite\" without \" \". No include end or trailing slash"
+
ANSWER=1
        echo ":"
+
while [ $ANSWER = 1 ]
read files_root
+
do
if [  "$files_root"  != "" ]
+
        clear
then
+
        echo " Please enter a directory name where you put the site files."
f_root=/opt/$files_root
+
echo " The directory is created under /opt dir."
if [ -d $f_root ]
+
        echo " Example \"mySite\" without \" \". No include end or trailing slash"
then
+
        echo ":"
clear
+
read files_root
echo " This directory already exist. If you want to remove and all contents"
+
if [  "$files_root"  != "" ]
echo " hit Y, or N to continue without change"
+
then
echo " (Y/N/Enter)"
+
f_root=/opt/$files_root
        echo ":"
+
if [ -d $f_root ]
read YESNO
+
then
case "$YESNO" in
+
clear
"Y" | "y" )
+
echo " This directory already exist. If you want to remove and all contents"
YESNO=1
+
echo " hit Y, or N to continue without change"
rm -rf $f_root;;
+
echo " (Y/N/Enter)"
"N" | "n" )
+
        echo ":"
YESNO=2;;
+
read YESNO
*)
+
case "$YESNO" in
YESNO=2;;
+
"Y" | "y" )
esac
+
YESNO=1
fi
+
rm -rf $f_root;;
ANSWER=0
+
"N" | "n" )
 +
YESNO=2;;
 +
*)
 +
YESNO=2;;
 +
esac
 +
fi
 +
ANSWER=0
 +
 +
if [ "$YESNO" != "2" ]
 +
then
 +
mkdir -p $f_root
 +
chown root.www $f_root
 +
chmod 644 $f_root
 +
fi
 +
 +
else
 +
clear
 +
        echo
 +
        echo "You have not enter a directory name. Hit enter to try again"
 +
read x
 +
fi
 +
done
 +
#################### -ALIAS - ######################################
 +
clear
 +
a_root=""
 +
ANSWER=1
 +
while [ $ANSWER = 1 ]
 +
do
 +
        clear
 +
        echo
 +
        echo "Please enter an alias name to access your site."
 +
        echo "Example \"wiki\" without \" \". No include end or trailing slash"
 +
        echo ":"
 +
 +
read alias_root
 +
if [  "$alias_root"  != "" ]
 +
then
 +
a_root=/$alias_root
 +
ANSWER=0
 +
else
 +
clear
 +
        echo
 +
        echo "You have not provide an alias name. Hit enter to try again"
 +
read x
 +
fi
 +
done
 +
##################### - SSL - ####################################
 +
clear
 +
f_ssl=""
 +
        clear
 +
        echo
 +
        echo "Do you want to force SSL?"
 +
        echo "This is used to force to secure http (https)"
 +
        echo "(Y/N/Enter)"
 +
        echo ":"
  
if [ "$YESNO" != "2" ]
+
read YESNO
then
+
case "$YESNO" in
mkdir -p $f_root
+
"Y" | "y" )
chown root.www $f_root
+
f_ssl="1";;
chmod 644 $f_root
+
"N" | "n" )
fi
+
f_ssl="0";;
 
+
*)
else
+
f_ssl="0";;
clear
+
esac
        echo
+
############################ - INDEX - ############################################
        echo "You have not enter a directory name. Hit enter to try again"
+
clear
read x
+
f_idx=""
fi
+
        clear
done
+
        echo
#################### -ALIAS - ######################################
+
        echo "Do you want to allow directory index?"
clear
+
        echo "This is used to index a directory if no index.htm/l or index.php file is available"
a_root=""
+
        echo "(Y/N/Enter)"
ANSWER=1
+
        echo ":"
while [ $ANSWER = 1 ]
+
read YESNO
do
+
  case "$YESNO" in
        clear
+
  "Y" | "y" )
        echo
+
f_idx="1";;
        echo "Please enter an alias name to access your site."
+
"N" | "n" )
        echo "Example \"wiki\" without \" \". No include end or trailing slash"
+
f_idx="0";;
        echo ":"
+
*)
 
+
f_idx="0";;
read alias_root
+
esac
if [ "$alias_root!= "" ]
+
#################### - AllowOverride - ######################################
then
+
clear
a_root=/$alias_root
+
f_aov=""
ANSWER=0
+
        clear
else
+
        echo
clear
+
        echo "Do you want to set AllowOverride All?"
        echo
+
        echo "This is used to allow process .htaccess files in your site dir"
        echo "You have not provide an alias name. Hit enter to try again"
+
        echo "(Y/N/Enter)"
read x
+
        echo ":"
fi
+
read YESNO
done
+
case "$YESNO" in
##################### - SSL - ####################################
+
"Y" | "y" )
clear
+
f_aov="1";;
f_ssl=""
+
"N" | "n" )
        clear
+
f_aov="0";;
        echo
+
*)
        echo "Do you want to force SSL?"
+
f_aov="0";;
        echo "This is used to force to secure http (https)"
+
esac
        echo "(Y/N/Enter)"
+
####################### - Includes - ###################################
        echo ":"
+
clear
 
+
f_inc=""
read YESNO
+
        clear
case "$YESNO" in
+
        echo
"Y" | "y" )
+
        echo "Do you want to allow includes?"
f_ssl="1";;
+
        echo "(Y/N/Enter)"
"N" | "n" )
+
        echo ":"
f_ssl="0";;
+
read YESNO
*)
+
case "$YESNO" in
f_ssl="0";;
+
"Y" | "y" )
esac
+
f_inc="1";;
############################ - INDEX - ############################################
+
"N" | "n" )
clear
+
f_inc="0";;
f_idx=""
+
*)
        clear
+
f_inc="0";;
        echo
+
esac
        echo "Do you want to allow directory index?"
+
##################### - PHP - #####################################
        echo "This is used to index a directory if no index.htm/l or index.php file is available"
+
clear
        echo "(Y/N/Enter)"
+
php=""
        echo ":"
+
        clear
read YESNO
+
        echo
case "$YESNO" in
+
        echo "Do you want to execute PHP?"
"Y" | "y" )
+
        echo "(Y/N/Enter)"
f_idx="1";;
+
        echo ":"
"N" | "n" )
+
read YESNO
f_idx="0";;
+
case "$YESNO" in
*)
+
"Y" | "y" )
f_idx="0";;
+
php="1";;
esac
+
"N" | "n" )
#################### - AllowOverride - ######################################
+
php="0";;
clear
+
*)
f_aov=""
+
php="0";;
        clear
+
esac
        echo
+
        echo "Do you want to set AllowOverride All?"
+
if [ "$php" = "1" ]
        echo "This is used to allow process .htaccess files in your site dir"
+
then
        echo "(Y/N/Enter)"
+
        clear
        echo ":"
+
        echo
read YESNO
+
        echo "Do you want to allow_url_fopen?"
case "$YESNO" in
+
        echo "This allow open and access remote files in your php scripts"
"Y" | "y" )
+
        echo "(Y/N/Enter)"
f_aov="1";;
+
        echo ":"
"N" | "n" )
+
read YESNO
f_aov="0";;
+
case "$YESNO" in
*)
+
"Y" | "y" )
f_aov="0";;
+
f_fop="1";;
esac
+
"N" | "n" )
####################### - Includes - ###################################
+
f_fop="0";;
clear
+
*)
f_inc=""
+
f_fop="0";;
        clear
+
esac
        echo
+
        clear
        echo "Do you want to allow includes?"
+
        echo
        echo "(Y/N/Enter)"
+
        echo "If you have eaccelerator, want to enabled?"
        echo ":"
+
        echo "(Y/N/Enter)"
read YESNO
+
        echo ":"
case "$YESNO" in
+
read YESNO
"Y" | "y" )
+
case "$YESNO" in
f_inc="1";;
+
"Y" | "y" )
"N" | "n" )
+
f_eac="1";;
f_inc="0";;
+
"N" | "n" )
*)
+
f_eac="0";;
f_inc="0";;
+
*)
esac
+
f_eac="0";;
##################### - PHP - #####################################
+
esac
clear
+
        clear
php=""
+
        echo
        clear
+
        echo "Do you want to allow register globals?"
        echo
+
        echo "(Y/N/Enter)"
        echo "Do you want to execute PHP?"
+
        echo ":"
        echo "(Y/N/Enter)"
+
read YESNO
        echo ":"
+
case "$YESNO" in
read YESNO
+
"Y" | "y" )
case "$YESNO" in
+
f_rgl="1";;
"Y" | "y" )
+
"N" | "n" )
php="1";;
+
f_rgl="0";;
"N" | "n" )
+
*)
php="0";;
+
f_rgl="0";;
*)
+
esac
php="0";;
+
fi
esac
+
###################### - CGI - #######################################
 
+
clear
if [ "$php" = "1" ]
+
cgi=""
then
+
        clear
        clear
+
        echo
        echo
+
        echo "Do you want to execute CGI?"
        echo "Do you want to allow_url_fopen?"
+
        echo "(Y/N/Enter)"
        echo "This allow open and access remote files in your php scripts"
+
        echo ":"
        echo "(Y/N/Enter)"
+
read YESNO
        echo ":"
+
case "$YESNO" in
read YESNO
+
"Y" | "y" )
case "$YESNO" in
+
cgi="1";;
"Y" | "y" )
+
"N" | "n" )
f_fop="1";;
+
cgi="0";;
"N" | "n" )
+
*)
f_fop="0";;
+
cgi="0";;
*)
+
esac
f_fop="0";;
+
esac
+
if [ "$cgi" = "1" ]
        clear
+
then
        echo
+
ANSWER=1
        echo "If you have eaccelerator, want to enabled?"
+
while [ $ANSWER = 1 ]
        echo "(Y/N/Enter)"
+
do
        echo ":"
+
        clear
read YESNO
+
        echo
case "$YESNO" in
+
        echo "Please enter a directory name to hold your cgi scripts."
"Y" | "y" )
+
        echo "If you don't enter a directory, assume you want to allow cgi scripts in $f_root root directory."
f_eac="1";;
+
        echo "If you provide a directory, this is created under $f_root/your_cgi_dir directory"
"N" | "n" )
+
        echo ":"
f_eac="0";;
+
read cgi_root
*)
+
if [  "$cgi_root"  != "" ]
f_eac="0";;
+
then
esac
+
c_root=$f_root/$cgi_root
        clear
+
YESNO=1
        echo
+
if [ -d $c_root ]
        echo "Do you want to allow register globals?"
+
then
        echo "(Y/N/Enter)"
+
clear
        echo ":"
+
echo "This directory already exist. If you want to remove and all contents"
read YESNO
+
echo "hit Y, or N to continue without change"
case "$YESNO" in
+
echo "(Y/N/Enter)"
"Y" | "y" )
+
echo ":"
f_rgl="1";;
+
read YESNO
"N" | "n" )
+
case "$YESNO" in
f_rgl="0";;
+
"Y" | "y" )
*)
+
YESNO=1
f_rgl="0";;
+
rm -rf $c_root;;
esac
+
"N" | "n" )
fi
+
YESNO=2;;
###################### - CGI - #######################################
+
*)
clear
+
YESNO=2;;
cgi=""
+
esac
        clear
+
fi
        echo
+
ANSWER=0
        echo "Do you want to execute CGI?"
+
        echo "(Y/N/Enter)"
+
if [ "$YESNO" != "2" ]
        echo ":"
+
then
read YESNO
+
mkdir -p $c_root
case "$YESNO" in
+
chown root.www $c_root
"Y" | "y" )
+
chmod 777 $c_root
cgi="1";;
+
fi
"N" | "n" )
+
else
cgi="0";;
+
ANSWER=0
*)
+
c_root=$f_root
cgi="0";;
+
fi
esac
+
done
 
+
if [ "$cgi" = "1" ]
+
if [ "$c_root" = "$f_root" ]
then
+
then
ANSWER=1
+
ca_root=$a_root
while [ $ANSWER = 1 ]
+
chown root.www $ca_root
do
+
chmod 777 $ca_root
        clear
+
else
        echo
+
  clear
        echo "Please enter a directory name to hold your cgi scripts."
+
  ###################### - CGI ALIAS -#########################################
echo "If you don't enter a directory, assume you want to allow cgi scripts in $f_root root directory."
+
ca_root=""
        echo "If you provide a directory, this is created under $f_root/your_cgi_dir directory"
+
ANSWER=1
        echo ":"
+
while [ $ANSWER = 1 ]
read cgi_root
+
do
if [ "$cgi_root" != "" ]
+
        clear
then
+
        echo
c_root=$f_root/$cgi_root
+
        echo "Please, provide a cgi alias."
YESNO=1
+
        echo ":"
if [ -d $c_root ]
+
read calias_root
then
+
if [  "$calias_root" != "" ]
clear
+
then
echo "This directory already exist. If you want to remove and all contents"
+
ca_root=/$calias_root
echo "hit Y, or N to continue without change"
+
ANSWER=0
echo "(Y/N/Enter)"
+
else
echo ":"
+
clear
read YESNO
+
        echo
case "$YESNO" in
+
        echo "You have not enter a cgi alias name. Hit enter to try again"
"Y" | "y" )
+
read x
YESNO=1
+
fi
rm -rf $c_root;;
+
done
"N" | "n" )
+
fi
YESNO=2;;
+
fi
*)
+
#################### - Configuration NAME - ############################################
YESNO=2;;
+
clear
esac
+
c_name=""
fi
+
ANSWER=1
ANSWER=0
+
while [ $ANSWER = 1 ]
 
+
do
if [ "$YESNO" != "2" ]
+
        clear
then
+
        echo
mkdir -p $c_root
+
        echo "Please enter a name for this configuration."
chown root.www $c_root
+
        echo ":"
chmod 777 $c_root
+
read conf_name
fi
+
if [  "$conf_name"  != "" ]
else
+
then
ANSWER=0
+
c_name=99SMESiteMaker_$conf_name
c_root=$f_root
+
ANSWER=0
fi
+
else
done
+
clear
 
+
        echo
if [ "$c_root" = "$f_root" ]
+
        echo "You have not provide a configuration name. Hit enter to try again"
then
+
read x
ca_root=$a_root
+
fi
chown root.www $ca_root
+
done
chmod 777 $ca_root
+
else
+
clear
+
################ - Final Step - ####################################
###################### - CGI ALIAS -#########################################
+
c_file=$custom_httpd_dir/$c_name
ca_root=""
+
if [ -d $custom_httpd_dir ]
ANSWER=1
+
then
while [ $ANSWER = 1 ]
+
custom_httpd_dir=$custom_httpd_dir
do
+
#Anyone know a negate if for check? = if [directory NOT exist $dir]
        clear
+
else
        echo
+
mkdir -p $custom_httpd_dir
        echo "Please, provide a cgi alias."
+
fi
        echo ":"
+
fopt=""
read calias_root
+
touch $c_file
if [  "$calias_root"  != "" ]
+
echo ' ' > $c_file
then
+
echo "Alias $a_root $f_root" >> $c_file
ca_root=/$calias_root
+
if [ "$cgi" = "1" ]
ANSWER=0
+
then
else
+
echo "ScriptAlias $ca_root $c_root" >> $c_file
clear
+
fi
        echo
+
echo "<Directory $f_root>" >> $c_file
        echo "You have not enter a cgi alias name. Hit enter to try again"
+
if [ "$f_ssl" = "1" ]
read x
+
then
fi
+
echo 'SSLRequireSSL on' >> $c_file
done
+
#echo 'RequireSSL on' >> $c_file #for SME6
fi
+
fi
fi
+
if [ "$php" = "1" ]
#################### - Configuration NAME - ############################################
+
then
clear
+
echo 'AddType application/x-httpd-php .php .php3 .phtml' >> $c_file
c_name=""
+
fi
ANSWER=1
+
if [ "$f_idx" = "1" ]||[ "$f_inc" = "1" ]||[ "$f_aov" = "1" ]
while [ $ANSWER = 1 ]
+
then
do
+
fopt="Options "
        clear
+
if [ "$f_idx" = "1" ]
        echo
+
then
        echo "Please enter a name for this configuration."
+
fopt="$fopt Indexes "
        echo ":"
+
fi
read conf_name
+
if [ "$f_inc" = "1" ]
if [ "$conf_name"  != "" ]
+
then
then
+
fopt="$fopt +Includes "
c_name=99SMESiteMaker_$conf_name
+
fi
ANSWER=0
+
if [ "$f_aov" = "1" ]
else
+
then
clear
+
fopt="$fopt FollowSymLinks "
        echo
+
fi
        echo "You have not provide a configuration name. Hit enter to try again"
+
echo "$fopt" >> $c_file
read x
+
if [ "$f_aov" = "1" ]
fi
+
then
done
+
echo 'AllowOverride all' >> $c_file
 
+
fi
 
+
fi
################ - Final Step - ####################################
+
echo 'order deny,allow' >> $c_file
c_file=$custom_httpd_dir/$c_name
+
echo 'deny from all' >> $c_file
if [ -d $custom_httpd_dir ]
+
echo 'allow from all' >> $c_file
then
+
if [ "$php" = "1" ]
custom_httpd_dir=$custom_httpd_dir
+
then
#Anyone know a negate if for check? = if [directory NOT exist $dir]
+
else
+
if [ "$f_fop" = "1" ]
mkdir -p $custom_httpd_dir
+
then
fi
+
echo 'php_flag register_globals on' >> $c_file
fopt=""
+
else
touch $c_file
+
echo 'php_flag register_globals off' >> $c_file
echo ' ' > $c_file
+
fi
echo "Alias $a_root $f_root" >> $c_file
+
if [ "$cgi" = "1" ]
+
if [ "$f_rgl" = "1" ]
then
+
then
echo "ScriptAlias $ca_root $c_root" >> $c_file
+
echo 'php_admin_flag allow_url_fopen on' >> $c_file
fi
+
else
echo "<Directory $f_root>" >> $c_file
+
echo 'php_admin_flag allow_url_fopen off' >> $c_file
if [ "$f_ssl" = "1" ]
+
fi
then
+
echo 'SSLRequireSSL on' >> $c_file
+
if [ "$f_eac" = "1" ]
#echo 'RequireSSL on' >> $c_file #for SME6
+
then
fi
+
echo 'php_admin_value eaccelerator.enable 1' >> $c_file
if [ "$php" = "1" ]
+
fi
then
+
echo 'AddType application/x-httpd-php .php .php3 .phtml' >> $c_file
+
fi
fi
+
echo '</Directory>' >> $c_file
if [ "$f_idx" = "1" ]||[ "$f_inc" = "1" ]||[ "$f_aov" = "1" ]
+
then
+
clear
fopt="Options "
+
# for debug only
if [ "$f_idx" = "1" ]
+
# echo "$files_root"
then
+
# echo "$f_root"
fopt="$fopt Indexes "
+
# echo "$alias_root"
fi
+
# echo "$a_root"
if [ "$f_inc" = "1" ]
+
# echo "$f_ssl"
then
+
# echo "$f_idx"
fopt="$fopt +Includes "
+
# echo "$f_aov"
fi
+
# echo "$f_inc"
if [ "$f_aov" = "1" ]
+
# echo "$php"
then
+
# echo "$f_fop"
fopt="$fopt FollowSymLinks "
+
# echo "$f_eac"
fi
+
# echo "$f_rgl"
echo "$fopt" >> $c_file
+
# echo "$cgi"
if [ "$f_aov" = "1" ]
+
# echo "$cgi_root"
then
+
# echo "$c_root"
echo 'AllowOverride all' >> $c_file
+
# echo "$calias_root"
fi
+
# echo "$ca_root"
fi
+
# echo "$conf_name"
echo 'order deny,allow' >> $c_file
+
# echo "$c_name"
echo 'deny from all' >> $c_file
+
# echo "$custom_httpd_dir"
echo 'allow from all' >> $c_file
+
# echo "$c_file"
if [ "$php" = "1" ]
+
# echo "$fopt"
then
+
 
+
expand-template /etc/httpd/conf/httpd.conf
if [ "$f_fop" = "1" ]
+
/etc/init.d/httpd-e-smith restart
then
+
# /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf  # For SME6
echo 'php_flag register_globals on' >> $c_file
+
# service httpd restart         # For SME6
else
+
echo "====================================================="
echo 'php_flag register_globals off' >> $c_file
+
echo "= Installation of you site is complete.            ="
fi
+
echo "= Now you can copy your site files under $f_root.  ="
 
+
echo "= Access your site in http://your_domain/$alias_root="
if [ "$f_rgl" = "1" ]
+
echo "====================================================="
then
 
echo 'php_admin_flag allow_url_fopen on' >> $c_file
 
else
 
echo 'php_admin_flag allow_url_fopen off' >> $c_file
 
fi
 
 
 
if [ "$f_eac" = "1" ]
 
then
 
echo 'php_admin_value eaccelerator.enable 1' >> $c_file
 
fi
 
 
 
fi
 
echo '</Directory>' >> $c_file
 
 
 
clear
 
# for debug only
 
# echo "$files_root"
 
# echo "$f_root"
 
# echo "$alias_root"
 
# echo "$a_root"
 
# echo "$f_ssl"
 
# echo "$f_idx"
 
# echo "$f_aov"
 
# echo "$f_inc"
 
# echo "$php"
 
# echo "$f_fop"
 
# echo "$f_eac"
 
# echo "$f_rgl"
 
# echo "$cgi"
 
# echo "$cgi_root"
 
# echo "$c_root"
 
# echo "$calias_root"
 
# echo "$ca_root"
 
# echo "$conf_name"
 
# echo "$c_name"
 
# echo "$custom_httpd_dir"
 
# echo "$c_file"
 
# echo "$fopt"
 
 
 
expand-template /etc/httpd/conf/httpd.conf
 
/etc/init.d/httpd-e-smith restart
 
# /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf  # For SME6
 
# service httpd restart         # For SME6
 
echo "====================================================="
 
echo "= Installation of you site is complete.            ="
 
echo "= Now you can copy your site files under $f_root.  ="
 
echo "= Access your site in http://your_domain/$alias_root="
 
echo "====================================================="
 
</nowiki>
 
Code:
 

Revision as of 01:00, 7 April 2007

SME Site Maker

This script is designed to help you when create a new web site under /opt directory.

If you improve or add new functions, please update this wiki page.

Template:DrawBoxNote

Your can download from here:

Untar and execute.

Enjoy.


Code:

#!/bin/bash

# Author: Normando Hall (PicsOne)
# Version: 1.0
# 06/06/2007

clear
echo "========================================================"
echo "=                SME Site Maker Script                 ="
echo "=                                                      ="
echo "= This script will configure your SME webserver, and   ="
echo "= make the necesary directory to hold your site.       ="
echo "=                                                      ="
echo "= No express or implied warranties are provided and its="
echo "= usage is at your own risk.                           ="
echo "=                                                      ="
echo "= If you feel confortable with the above then press    ="
echo "= enter if not press Ctrl+C to abort the configuration ="
echo "= script.                                              ="
echo "=                                                      ="
echo "========================================================"
read x
custom_httpd_dir=/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf
clear
######################### - Site ROOT - ##################################3
f_root=""
ANSWER=1
while [ $ANSWER = 1 ]
do
        clear
        echo " Please enter a directory name where you put the site files."
	echo " The directory is created under /opt dir."
        echo " Example \"mySite\" without \" \". No include end or trailing slash"
        echo ":"
read files_root
if [  "$files_root"  != "" ]
then
f_root=/opt/$files_root
if [ -d $f_root ]
then
	clear
	echo " This directory already exist. If you want to remove and all contents"
	echo " hit Y, or N to continue without change"
	echo " (Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
YESNO=1
rm -rf $f_root;;
"N" | "n" )
YESNO=2;;
*)
YESNO=2;;
esac
fi
ANSWER=0  

if [ "$YESNO" != "2" ]
then
mkdir -p $f_root
chown root.www $f_root
chmod 644 $f_root
fi

else
	clear
        echo
        echo "You have not enter a directory name. Hit enter to try again"
read x
fi
done
#################### -ALIAS - ######################################
clear
a_root=""
ANSWER=1
while [ $ANSWER = 1 ]
do
        clear
        echo
        echo "Please enter an alias name to access your site."
        echo "Example \"wiki\" without \" \". No include end or trailing slash"
        echo ":" 

read alias_root
if [  "$alias_root"  != "" ]
then
a_root=/$alias_root
ANSWER=0
else
	clear
        echo
        echo "You have not provide an alias name. Hit enter to try again"
read x
fi
done
##################### - SSL - ####################################
clear
f_ssl=""
        clear
        echo
        echo "Do you want to force SSL?"
        echo "This is used to force to secure http (https)"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_ssl="1";;
"N" | "n" )
f_ssl="0";;
*)
f_ssl="0";;
esac
############################ - INDEX - ############################################
clear
f_idx=""
        clear
        echo
        echo "Do you want to allow directory index?"
        echo "This is used to index a directory if no index.htm/l or index.php file is available"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_idx="1";;
"N" | "n" )
f_idx="0";;
*)
f_idx="0";;
esac
#################### - AllowOverride - ######################################
clear
f_aov=""
        clear
        echo
        echo "Do you want to set AllowOverride All?"
        echo "This is used to allow process .htaccess files in your site dir"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_aov="1";;
"N" | "n" )
f_aov="0";;
*)
f_aov="0";;
esac
####################### - Includes - ###################################
clear
f_inc=""
        clear
        echo
        echo "Do you want to allow includes?"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_inc="1";;
"N" | "n" )
f_inc="0";;
*)
f_inc="0";;
esac
##################### - PHP - #####################################
clear
php=""
        clear
        echo
        echo "Do you want to execute PHP?"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
php="1";;
"N" | "n" )
php="0";;
*)
php="0";;
esac

if [ "$php" = "1" ]
then
        clear
        echo
        echo "Do you want to allow_url_fopen?"
        echo "This allow open and access remote files in your php scripts"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_fop="1";;
"N" | "n" )
f_fop="0";;
*)
f_fop="0";;
esac
        clear
        echo
        echo "If you have eaccelerator, want to enabled?"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_eac="1";;
"N" | "n" )
f_eac="0";;
*)
f_eac="0";;
esac
        clear
        echo
        echo "Do you want to allow register globals?"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
f_rgl="1";;
"N" | "n" )
f_rgl="0";;
*)
f_rgl="0";;
esac
fi
###################### - CGI - #######################################
clear
cgi=""
        clear
        echo
        echo "Do you want to execute CGI?"
        echo "(Y/N/Enter)"
        echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
cgi="1";;
"N" | "n" )
cgi="0";;
*)
cgi="0";;
esac

if [ "$cgi" = "1" ]
then
ANSWER=1
while [ $ANSWER = 1 ]
do
        clear
        echo
        echo "Please enter a directory name to hold your cgi scripts."
        echo "If you don't enter a directory, assume you want to allow cgi scripts in $f_root root directory."
        echo "If you provide a directory, this is created under $f_root/your_cgi_dir directory"
        echo ":"
read cgi_root
if [  "$cgi_root"  != "" ]
then
c_root=$f_root/$cgi_root
YESNO=1
if [ -d $c_root ]
then
	clear
	echo "This directory already exist. If you want to remove and all contents"
	echo "hit Y, or N to continue without change"
	echo "(Y/N/Enter)"
	echo ":"
read YESNO
case "$YESNO" in
"Y" | "y" )
YESNO=1
rm -rf $c_root;;
"N" | "n" )
YESNO=2;;
*)
YESNO=2;;
esac
fi
ANSWER=0

if [ "$YESNO" != "2" ]
then
mkdir -p $c_root
chown root.www $c_root
chmod 777 $c_root
fi
else
ANSWER=0
c_root=$f_root
fi
done

if [ "$c_root" = "$f_root" ]
then
ca_root=$a_root
chown root.www $ca_root
chmod 777 $ca_root
else
clear
###################### - CGI ALIAS -#########################################
ca_root=""
ANSWER=1
while [ $ANSWER = 1 ]
do
        clear
        echo
        echo "Please, provide a cgi alias."
        echo ":"
read calias_root
if [  "$calias_root"  != "" ]
then
ca_root=/$calias_root
ANSWER=0
else
	clear
        echo
        echo "You have not enter a cgi alias name. Hit enter to try again"
read x
fi
done
fi
fi
#################### - Configuration NAME - ############################################
clear
c_name=""
ANSWER=1
while [ $ANSWER = 1 ]
do
        clear
        echo
        echo "Please enter a name for this configuration."
        echo ":"
read conf_name
if [  "$conf_name"  != "" ]
then
c_name=99SMESiteMaker_$conf_name
ANSWER=0
else
	clear
        echo
        echo "You have not provide a configuration name. Hit enter to try again"
read x
fi
done


################ - Final Step - ####################################
c_file=$custom_httpd_dir/$c_name
if [ -d $custom_httpd_dir ]
then
custom_httpd_dir=$custom_httpd_dir
#Anyone know a negate if for check? = if [directory NOT exist $dir]
else
mkdir -p $custom_httpd_dir
fi
fopt=""
touch $c_file
echo ' ' > $c_file
echo "Alias $a_root $f_root" >> $c_file
if [ "$cgi" = "1" ]
then
echo "ScriptAlias $ca_root $c_root" >> $c_file
fi
echo "<Directory $f_root>" >> $c_file
if [ "$f_ssl" = "1" ]
then
echo 'SSLRequireSSL on' >> $c_file
#echo 'RequireSSL on' >> $c_file #for SME6
fi
if [ "$php" = "1" ]
then
echo 'AddType application/x-httpd-php .php .php3 .phtml' >> $c_file
fi
if [ "$f_idx" = "1" ]||[ "$f_inc" = "1" ]||[ "$f_aov" = "1" ]
then
fopt="Options "
if [ "$f_idx" = "1" ]
then
fopt="$fopt Indexes "
fi
if [ "$f_inc" = "1" ]
then
fopt="$fopt +Includes "
fi
if [ "$f_aov" = "1" ]
then
fopt="$fopt FollowSymLinks "
fi
echo "$fopt" >> $c_file
if [ "$f_aov" = "1" ]
then
echo 'AllowOverride all' >> $c_file
fi
fi
echo 'order deny,allow' >> $c_file
echo 'deny from all' >> $c_file
echo 'allow from all' >> $c_file
if [ "$php" = "1" ]
then

if [ "$f_fop" = "1" ]
then
echo 'php_flag register_globals on' >> $c_file
else
echo 'php_flag register_globals off' >> $c_file
fi

if [ "$f_rgl" = "1" ]
then
echo 'php_admin_flag allow_url_fopen on' >> $c_file
else
echo 'php_admin_flag allow_url_fopen off' >> $c_file
fi

if [ "$f_eac" = "1" ]
then
echo 'php_admin_value eaccelerator.enable 1' >> $c_file
fi

fi
echo '</Directory>' >> $c_file

clear
# for debug only
#	echo "$files_root"
#	echo "$f_root"
#	echo "$alias_root"
#	echo "$a_root"
#	echo "$f_ssl"
#	echo "$f_idx"
#	echo "$f_aov"
#	echo "$f_inc"
#	echo "$php"
#	echo "$f_fop"
#	echo "$f_eac"
#	echo "$f_rgl"
#	echo "$cgi"
#	echo "$cgi_root"
#	echo "$c_root"
#	echo "$calias_root"
#	echo "$ca_root"
#	echo "$conf_name"
#	echo "$c_name"
#	echo "$custom_httpd_dir"
#	echo "$c_file"
#	echo "$fopt"

expand-template /etc/httpd/conf/httpd.conf
/etc/init.d/httpd-e-smith restart
# /sbin/e-smith/expand-template /etc/httpd/conf/httpd.conf  # For SME6
# service httpd restart				    	    # For SME6
echo "====================================================="
echo "= Installation of you site is complete.             ="
echo "= Now you can copy your site files under $f_root.   ="
echo "= Access your site in http://your_domain/$alias_root="
echo "====================================================="