#Srript to add site, ftp, user, group to Apache, Proftpd ans Unix #7-11-06 Charles Parker # # # Clear and set all variables apache_conf="/etc/httpd/conf/httpd.conf" #Path to Apache config proftpd_conf="/usr/local/etc/proftpd.conf" #Path to Proftpd config #apache_conf="/var/scripts/httpd.conf" #Path to Apache config debug #proftpd_conf="/var/scripts/proftpd.conf" #Path to Proftpd config debug site_path="/var/www/html/" #Path of site and user home hosts="/etc/hosts" #Path to local hosts file sitename=$1 #Sitename from stdin1 admin_username=$2 #Admin username fro stdin2 admin_pass=$3 #Not used create_site="n" #Yes no flag site_yorn="n" #Yes no flag def_browser="mozilla" #Browser to test new site def_domain="www.micro-bizz.com" #Domain for dns, set to your hosting ip def_group="501" #Group id for adminuser def_shell="/bin/bash" #Shell to use newsite_template="/var/www/html/newsite_template.htm" #Path to under construction page bounce="n" #Flag to bounce servers srv_log="/var/scripts/AddSite.log" #Path to log ADDSITE activity # Intro clear #echo $apache_conf_path $proftpd_conf_path $site_path $admin_username $create_site $site_yorn #echo $def_browser $def_domain echo ADDSITE 1.0 echo "Usage of addsite: addsite sitename siteadmin" echo "Example: addsite mycoolsite.com thecooladmin" echo "Note the WWW will be implied Do not include in sitename" echo "By Charles Parker rcharlesparker@hotmail.com" echo "_______________________________________________________" # verify sitename $site_name echo "Current sitename is (www.$sitename) " echo "Correct ? y/n?" read site_yorn while [ $site_yorn != "y" ] do echo "Enter new site name www." read sitename echo "Your new sitename is (www.$sitename)" echo Correct ? y/n ? read site_yorn done # verify admin name $admin_username site_yorn="n" echo "Current Admin name is ($admin_username) " echo "Correct ? y/n?" read site_yorn while [ $site_yorn != "y" ] do echo "Enter new Admin name " read admin_username echo "Your new Admin name is ($admin_username)" echo Correct ? y/n ? read site_yorn done # create adminuser account mkdir $site_path$sitename chmod 775 $site_path$sitename useradd -c "addsite_www_user_$admin_username" -d $site_path$sitename/bin -g $def_group -s $def_shell $admin_username #chmod 775 $site_path$sitename/home # Create user password passwd $admin_username # verify writing echo "_____________________________________________________" echo "This is what I have so far " echo "Sitename= (www.$sitename)" echo "Admin= ($admin_username)" echo "Password= ***************" # creaqte log file echo "_____________________________________________________" echo "Addsite Created site www.$sitename, with user $admin_username" >> $srv_log # Create Apache config site_yorn="n" echo "" echo "Would you like me to create ($sitename) in $apache_conf ? y/n? " read site_yorn while [ $site_yorn = "y" ] do echo "I will modify Apache Conf in $apache_conf" echo "" >> $apache_conf echo "# Site $sitename added by addsite script" >> $apache_conf echo "" >> $apache_conf echo "" >> $apache_conf echo "DocumentRoot \"$site_path$sitename\"" >> $apache_conf echo "ServerName www.$sitename" >> $apache_conf echo "" >> $apache_conf echo "allow from all " >> $apache_conf echo "Options +Indexes " >> $apache_conf echo " " >> $apache_conf echo "DirectoryIndex index.htm index.html index.php" >> $apache_conf echo "ServerAlias $sitename" >> $apache_conf echo "" >> $apache_conf site_yorn="done" echo "Modified Apache" >> $srv_log done echo "Apache has been modified" # Create ProFtpd config site_yorn="n" echo "" echo "Would you like me to create ($sitename) in $proftpd_conf ? y/n? " read site_yorn while [ $site_yorn = "y" ] do echo "" >> $proftpd_conf echo "# Server for $sitename" >> $proftpd_conf echo "" >> $proftpd_conf echo "" >> $proftpd_conf echo "DefaultRoot $site_path$sitename" >> $proftpd_conf echo "DeleteAbortedStores on" >> $proftpd_conf echo "HiddenStor off:" >> $proftpd_conf echo "Group ftp" >> $proftpd_conf echo "User $admin_username" >> $proftpd_conf echo "" >> $proftpd_conf site_yorn="done" echo "Modified ProFTPd" >> $srv_log done echo "ProFtpd has been modified... Almost done!" # Create Hosts file echo "127.0.0.1 www.$sitename $sitename" >> $hosts echo "" echo "Modified Hosts file" >> $srv_log # Ask to bounce servers # This section you will have to modify depending on how you start your services, ie. xtend, service echo "Should I Bounce (restart) Apache and ProFTPd ? y/n ?" read bounce while [ $bounce = "y" ] do echo Stopping HTTTPD MYSQLD PROFTPD service httpd stop service mysqld stop service proftpd stop echo Starting HTTPD MYSQLD PROFTPD service httpd start service mysqld start service proftpd start echo "Bounced HTTPD MYSQLD PROFTPD " >> $svr_log echo "Time Bounced on " date echo "Your current uptime is " uptime echo "on `date` ">> $srv_log bounce="done" date >> $srv_log echo "***************************************************" >> $srv_log done # Make Under Construction page echo "" >> $site_path$sitename/index.htm echo "" >> $site_path$sitename/index.htm echo "UNDER CONSTRUCTION" >> $site_path$sitename/index.htm echo "" >> $site_path$sitename/index.htm echo "" >> $site_path$sitename/index.htm echo "

/// UNDER CONSTRUCTION ///

" >> $site_path$sitename/index.htm echo "

SITE CREATED BY ADDSITE

" >> $site_path$sitename/index.htm echo "

./addsite by Charles Parker

" >> $site_path$sitename/index.htm echo "

rcharlesparker@hotmail.com

" >> $site_path$sitename/index.htm echo "

Congradulations www.$sitename has been created.

" >> $site_path$sitename/index.htm echo "

You are now ready to add your files and web pages to $site_path$sitename.

" >> $site_path$sitename/index.htm echo "" >> $site_path$sitename/index.htm echo "" >> $site_path$sitename/index.htm chmod 755 $site_path$sitename/index.htm # Test site echo "Would you like to test $sitename in $def_browser ? y/n ?" read site_yorn while [ $site_yorn = "y" ] do $def_browser $sitename done # Get real IP of localhost # Prompt to add sitename to DNS echo "" echo "Remember to add the realworld ip to your dns server" host $def_domain echo "Bye!" exit 0