-
Notifications
You must be signed in to change notification settings - Fork 0
/
genWeb.sh
58 lines (42 loc) · 1.43 KB
/
genWeb.sh
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
#!/bin/bash
# This script will set up an apache site with the given name
# that has PHP enabled
# The data file for this site is located at /var/www/siteName
#
# It will only create a new site if one does not already exist in that directory.
# Any error messages that are created will be printed.
#
#
#
RED='\033[0;31m'
ORANGE='\033[1;33m'
NC='\033[0m'
# Read in the template file
template=$(cat "/path/to/httpTemp.conf")
# Check that a project name is given
if [ $# -eq 1 ]
then
name=$1 # If more than one command-line param,
#+ then just take the first.
else
name="example" # Default, if no command-line parameter.
fi
# Replace the site name place holder with a the name of the website
site=$(echo "$template" | sed -e "s/\${name}/$name/g")
# Make sure that the website does not already exist
if [ ! -f "/etc/apache2/mine/$name.conf" ]; then
# Generate the the sites config file and activate it
echo "$site" > "/etc/apache2/mine/$name.conf";
echo -e "\nInclude /private/etc/apache2/mine/$name.conf" >> "/etc/apache2/httpd.conf";
# Create a project file direcotry for this project
mkdir "/var/www/$name"
echo "Hello world!" >> "/var/www/$name/index.html"
# Make sure the configuration is all good
echo -e "${ORANGE}";
apachectl configtest;
echo -e "${NC}";
# Restart the web server
apachectl restart;
else
echo -e "${RED}Site Already exists! Aborting...${NC}";
fi