Add multiple lines to sites-available automatic
Hai THere,
I am making a script that will automate the steps for adding a domain to a linux webserver. How can i add multiple lines in a file with a variable in it. The script works like this: run script; scripts asks which domain: user enters domain; The directories and symbolic links are made; the user rights are set; ***NEED TO ADD BELOW LINES TO sites-available/$DOMAIN*** <VirtualHost ip address> DocumentRoot /export/www/$DOMAIN/html php_flag log_errors on php_value error_log /export/www/$DOMAIN/logs/php_error.log ServerName $DOMAIN ErrorLog /export/www/$DOMAIN/logs/error.log CustomLog /export/www/$DOMAIN/logs/access.log "combined" HostNameLookups off </VirtualHost> How can i do this part? I can add them one at a time but can i put the whole text in a variable? Thank you in advance. Grt. |
Two stupid examples.
A function with tab formatted VHost output: addVH() { echo -en "\n<VirtualHost ip address>\n\tDocumentRoot /export/www/$1/html\n\tphp_flag log_errors on\n\tphp_value error_log /export/www/$1/logs/php_error.log\n\tServerName $1\n\tErrorLog /export/www/$1/logs/error.log\n\tCustomLog /export/www/$1/logs/access.log \"combined\"\n\tHostNameLookups off\n</VirtualHost>\n"; } It takes domain name as single arg so you can do "addVH someDomain >> /some/config/file". A "here" document: Code:
DOMAIN="microsoft.com" |
All times are GMT -5. The time now is 07:11 AM. |