Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- vhroot='/etc/apache2/sites-available/'
- NEW_DOMAINS="/home/domain.txt"
- cat ${NEW_DOMAINS} |
- while read domain user email
- do
- echo "<VirtualHost *:80>
- ServerName "$domain"
- ServerAlias www."$domain"
- ServerAdmin "$email"
- DocumentRoot /home/"$user"/domains/"$domain"/public_html
- </VirtualHost>" > $vhroot/$domain
- #mkdir /home/$user/domains/domain
- #mkdir /home/$user/domains/$domain/public_html
- #chown -R $user.$user /home/$user/domains/$domain
- echo "111.21.111.111 $domain" >> host.txt
- #a2ensite $hostname
- done
- echo "" > /home/domain.txt
- # /etc/init.d/apache2 reload
- #!/bin/bash
- vhroot='/etc/apache2/sites-available/'
- NEW_DOMAINS="/home/domain.txt"
- has_new_domains=false #No new domains by default = do not reload the apache config.
- cat ${NEW_DOMAINS} |
- while read domain user email
- do
- has_new_domains=true #true = at least one new domain = reload apache config
- echo "<VirtualHost *:80>
- ServerName "$domain"
- ServerAlias www."$domain"
- ServerAdmin "$email"
- DocumentRoot /home/"$user"/domains/"$domain"/public_html
- </VirtualHost>" > $vhroot/$domain
- #mkdir /home/$user/domains/domain
- #mkdir /home/$user/domains/$domain/public_html
- #chown -R $user.$user /home/$user/domains/$domain
- echo "111.21.111.111 $domain" >> host.txt
- #a2ensite $hostname
- done
- echo "" > /home/domain.txt
- if $has_new_domains ; then #only reload the apache config if there is at least one new domain
- /etc/init.d/apache2 reload
- fi
- #!/bin/bash
- vhroot='/etc/apache2/sites-available/'
- NEW_DOMAINS="adddomain.txt"
- has_new_domains=false #No new domains by default = do not reload the apache config.
- cat ${NEW_DOMAINS} |
- while read domain
- do
- if [ ! -z "$domain" ];
- then
- has_new_domains=true #true = at least one new domain = reload apache config
- echo "<VirtualHost *:80>
- ServerName "$domain"
- ServerAlias www."$domain"
- ServerAdmin postmaster@"$domain"
- DocumentRoot /var/www/html/websites/"$domain"
- </VirtualHost>" > $vhroot/"$domain".conf #.conf extension needed to make a2ensite work in apache -debian
- mkdir /var/www/html/websites/
- mkdir /var/www/html/websites/$domain
- chown -R root:www-data /var/www/html/websites
- chmod -R 755 /var/www/html/websites
- #create index.html file
- echo "<!DOCTYPE html>
- <html>
- <head>
- <title>Welcome to nginx on Debian!</title>
- <style>
- body {
- width: 35em;
- margin: 0 auto;
- font-family: Tahoma, Verdana, Arial, sans-serif;
- }
- </style>
- </head>
- <body>
- <h1>Welcome to "$domain"</h1>
- <p>If you see this page, the Apache web server is successfully installed and working.</p>
- <p>
- You can start building your website
- </p>
- </body> </html>">/var/www/html/websites/$domain/index.html
- #echo "111.21.111.111 $domain" >> host.txt
- a2ensite "$domain".conf
- else echo 'No new domains'
- fi
- done
- > adddomain.txt # with echo "" an empty line is still present in file
- DEL_DOMAINS="deldomain.txt"
- cat ${DEL_DOMAINS} |
- while read deldomain
- do
- has_new_domains=true #true = at least one new domain = reload apache config
- #Make sure we don't delete all parent directory , in case variable is empty
- if [ ! -z "$deldomain" ]; then
- a2dissite "$deldomain".conf
- echo "dominio "$deldomain" eliminado"
- rm -r /var/www/html/websites/$deldomain
- rm $vhroot/"$deldomain".conf
- fi
- done
- > deldomain.txt
- if $has_new_domains ; then #only reload the apache config if there is at least one new domain
- /etc/init.d/apache2 reload
- fi
Add Comment
Please, Sign In to add comment