#!/bin/bash c_bold="\033[1m"; c_norm="\033[0m"; help(){ if [[ "$1" != "" ]];then case "$1" in addsite) echo "Addsite Usage:"; echo "addsite [] - adds a site to apache and enables it"; ;; help) echo "Help Usage:"; echo "help - displays this message"; echo "help - 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 " ServerName $2 DocumentRoot $path Options +ExecCGI +Indexes +FollowSymLinks +MultiViews AllowOverride All RewriteEngine On Order allow,deny allow from all ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined ServerAdmin admin@omnimaga.org " > /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;