-
Notifications
You must be signed in to change notification settings - Fork 0
/
configshell
68 lines (68 loc) · 1.33 KB
/
configshell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/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;