Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- #
- # =======================
- # Linode vhost script
- # =======================
- function make_vhost
- {
- cat <<- _EOF_
- <VirtualHost *:80>
- ServerAdmin linus@unwi.se
- ServerName $dname
- ServerAlias *.$dname
- DocumentRoot /srv/www/$dname/public_html/
- ErrorLog /srv/www/$dname/logs/error.log
- CustomLog /srv/www/$dname/logs/access.log combined
- <Directory /srv/www/$dname/public_html/>
- Options FollowSymLinks
- AllowOverride All
- Order allow,deny
- allow from all
- </Directory>
- </VirtualHost>
- _EOF_
- }
- # =======================
- # header
- # =======================
- clear
- echo "*** Virtual host setup ***"
- # =======================
- # set domain name variable
- # =======================
- echo " "
- echo -n "Enter domain name: "
- read dname
- echo " "
- echo "Setting up files for $dname"
- # =======================
- # create needed directories
- # =======================
- echo " "
- mkdir -vp /srv/www/$dname
- mkdir -vp /srv/www/$dname/public_html
- mkdir -vp /srv/www/$dname/logs
- echo " "
- touch /srv/www/$dname/logs/access.log
- echo "created /srv/www/$dname/logs/access.log"
- touch /srv/www/$dname/logs/error.log
- echo "created /srv/www/$dname/logs/error.log"
- # =======================
- # build vhost config file
- # =======================
- echo " "
- make_vhost > /etc/apache2/sites-available/$dname
- echo "created /etc/apache2/sites-available/$dname"
- cd /srv/www/$dname/public_html
- # =======================
- # add git repo
- # =======================
- echo " "
- while true; do
- read -p "Initialize empty Git repository? $" yn
- case $yn in
- [Yy]* ) git init; touch README; git add .; git commit -m "Initial commit."; git checkout -b live; break;;
- [Nn]* ) break;;
- * ) echo "Please answer yes or no.";;
- esac
- done
- # =======================
- # enable site
- # =======================
- echo " "
- while true; do
- read -p "Enable site? $" yn
- case $yn in
- [Yy]* ) a2ensite $dname; service apache2 reload; break;;
- [Nn]* ) break;;
- * ) echo "Please answer yes or no.";;
- esac
- done
- # =======================
- # exit
- # =======================
- echo " "
- echo "*** Finished setting up files for $dname."
- exit
Add Comment
Please, Sign In to add comment