1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #!/bin/bash
- c_bold="\033[1m";
- c_norm="\033[0m";
- help(){
- if [[ "$1" != "" ]];then
- case "$1" in
- addsite)
- echo "Addsite Usage:";
- echo "addsite <name> <host> [<path>] - adds a site to apache and enables it";
- ;;
- help)
- echo "Help Usage:";
- echo "help - displays this message";
- echo "help <command> - displays help for a command";
- ;;
- *)
- help;
- esac;
- else
- echo "Commands:";
- echo " help";
- echo " addsite";
- fi;
- }
- addsite(){
- if [ -f /etc/apache2/sites-available/$1.conf ];then
- echo "Site already exists";
- else
- if [[ "$3" != "" ]];then
- path="$3";
- else
- path="/var/www/$1";
- fi;
- mkdir -p "$path";
- echo "<VirtualHost *:80>
- ServerName $2
- DocumentRoot $path
- <Directory $path>
- Options +ExecCGI +Indexes +FollowSymLinks +MultiViews
- AllowOverride All
- RewriteEngine On
- Order allow,deny
- allow from all
- </Directory>
- ErrorLog ${APACHE_LOG_DIR}/error.log
- CustomLog ${APACHE_LOG_DIR}/access.log combined
- ServerAdmin [email protected]
- </VirtualHost>" > /etc/apache2/sites-available/$1.conf;
- echo "Created site $1 ($2) at $path";
- a2ensite $1;
- sudo service apache2 reload;
- fi;
- }
- while true; do
- if [[ "$@" == "" ]];then
- echo -ne "$c_bold$(whoami)@$(pwd)>$c_norm ";
- read input;
- else
- input="$@";
- fi;
- case "$input" in
- *)
- eval "$input";
- esac;
- if [[ "$@" != "" ]];then
- exit;
- fi;
- done;
|