script to set up entire website domain

 
 
#!/bin/bash
#steps to set up a website
echo -e " Enter you domain name "
read domain

domain_user=` echo $domain |sed s/\.com/com2631/g `
tmp_name=` echo $domain |sed s/\.com//g `
passwd_file=`cat /etc/passwd |grep $domain |sed s/:/\ /g |awk '{print $1}'`


if [ ! -d /websites/"$domain" ]; then

         if [ "$domain_user" != "$passwd_file" ]; then

useradd -d /websites/"$domain" -s /sbin/nologin "$domain_user"
echo -e " created domain $domain "

echo -e "adding ftp user "
read -p "Please enter the password for user $domain_user" p
(echo $p; echo $p ) | /usr/local/pureftpd/bin/pure-pw useradd "$domain_user" -f /usr/local/pureftpd/etc/pureftpd.passwd  -u "$domain_user" -d /websites/"$domain" -m
echo -e " adding user sucessful "

echo -e "creating directory structure "
mkdir /websites/"$domain"/web /websites/"$domain"/logs /websites/"$domain"/private /websites/"$domain"/data /websites/"$domain"/cgi-bin
echo -e "sucessfully created directory structure   "


echo -e " we chang the permission for the the $user "
chmod 711 /websites/"$domain"/ && chmod 711 /websites/"$domain"/*

echo -e " we change the ownership   for  the $domain "
chown "$user":"$user" /websites/"$domain" && chown "$user":"$user" /websites/"$domain"/*
echo -e " changes for $user was sucessful "


echo -e "Creating the Vhost directive domain $domain "

echo -e "
######################"$domain"2631###################

<VirtualHost 192.168.0.244:80>
ServerAdmin admin@"$tmp_name".sys.qualiproj.com
ServerName "$tmp_name".sys.qualiproj.qualispace.com
ServerAlias www."$tmp_name".sys.qualiproj.qualispace.com
DocumentRoot /websites/"$domain"/web
##############MIME_TYPE_"$domain"2631##################
<Directory /websites/"$domain"/web>
    Options -MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    AllowOverride FileInfo AuthConfig Limit
    Order allow,deny
    Allow from all
</Directory>
#################DIR_PROTECT_"$domain"2631###################
ErrorLog /websites/"$domain"/logs/"$tmp_name".sys.qualiproj.error_log
CustomLog /websites/"$domain"/logs/"$tmp_name".sys.qualiproj.access_log common
ScriptAlias /cgi-bin/ "/websites/"$domain"/cgi-bin/"
<Directory "/websites/"$domain"/cgi-bin">
        AllowOverride None
        Options +ExecCGI -Includes
       Order allow,deny
        Allow from all
</Directory>
</VirtualHost>
 " >>  /usr/local/apache2/conf/extra/httpd_vhost.conf

echo -e "Sucessfully created  the Vhost directive domain $domain "

echo -e " restarting httpd "
/etc/init.d/httpd graceful

echo -e "copying test html page to web folder "
cp -R /websites/agnello.com/web/bob.html /websites/"$domain"/web/index.html
echo -e "done "

echo -e " you can now log on to http://www."$tmp_name".sys.qualiproj.qualispace.com"
    else
echo -e "the user for this doamin already exist"
   fi
 else
echo -e  "the domin $domain already exist"
fi



--

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.

Other Articles

Enter your email address: