Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #asks password so that it can go and perform action in root directories
- su
- echo "Please give the domain name :"
- read domain
- echo "Please give the IP address :"
- read ipaddrs
- if [ -d "/etc" ]; then
- if [ -d "/etc/apache2" ]; then
- if [ -d "/etc/apache2/sites-available" ]; then
- if [ -f "/etc/apache2/sites-available/"$domain".conf" ]; then
- echo "SITE ALREADY EXISTS"
- else
- echo "CREATE NEW SITE CONFIG FILE"
- cd "/etc/apache2/sites-available"
- touch $domain".conf"
- echo "CREATE ENTRY INSIDE THE SITE CONFIG FILE"
- echo "<VirtualHost *:80>" >> $domain".conf"
- echo '\t DocumentRoot "/home/'$domain'/public"' >> $domain".conf"
- echo "\t ServerName "$domain >> $1".conf"
- echo "\t ServerAlias www."$domain >> $1".conf"
- echo '\t <Directory "/home/'$domain'/public">' >> $domain".conf"
- echo '\t\t allow from all' >> $domain".conf"
- echo '\t\t order allow,deny' >> $domain".conf"
- echo '\t\t AllowOverride All' >> $domain".conf"
- echo '\t </Directory>' >> $domain".conf"
- echo "</VirtualHost>" >> $domain".conf"
- echo "CREATE HOST FILE ENTRY"
- cd "../../"
- echo $ipaddrs $domain >> hosts
- cd "../home"
- echo "CREATE HOME DIRECTORY"
- mkdir $domain
- cd $domain
- mkdir "public"
- cd "public"
- touch index.html
- echo "Welcome to "$domain >> index.html
- echo "HOST SETUP SUCCESSFULLY. PLEASE RESTART APACHE."
- fi
- else
- echo "ERROR: '/etc/apache2/sites-available' does not exists";
- fi
- fi
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement