forked from Avix101/Mail-Server-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapache.sh
More file actions
executable file
·111 lines (95 loc) · 3.5 KB
/
apache.sh
File metadata and controls
executable file
·111 lines (95 loc) · 3.5 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
#
#-----------------------------------------#
###Welcome to the apache setup script. Any variables that may need to be adjusted should be changed in the designated "variables" section in the main script.
#-----------------------------------------#
sudo $package_manager install httpd mod_ssl -y
httpd_secure=(SSLCertificateFile SSLCertificateKeyFile SSLProtocol)
for var in ${httpd_secure[*]}; do
temp="$(grep ^$var $httpd_ssl_conf)"
if [ "$temp" != "" ]; then
echo "Updating variable..."
sudo ./perl-find-replace "$temp" "$var ${!var}" "$httpd_ssl_conf"
else
echo "Writing variable..."
echo "$var ${!var}" | sudo tee -a "$httpd_ssl_conf"
fi
done
temp="$(grep ^DirectoryIndex $httpd_conf)"
if [ "$temp" != "" ]; then
echo "Updating variable..."
sudo ./perl-find-replace "$temp" "DirectoryIndex index.html index.html.var index.php" "$httpd_conf"
else
echo "Writing variable..."
echo "DirectoryIndex index.html index.html.var index.php" | sudo tee -a "$httpd_conf"
fi
start_tag="####CURRENT BUILD !!!! LEAVE THIS TAG LINE INTACT IF YOU PLAN TO EVER USE THE SETUP SCRIPT AGAIN OR BE READY TO REINSTALL DOVECOT... DO NOT REMOVE####"
end_tag="####END OF CURRENT BUILD... YOU MAY ADJUST SETTINGS OUTSIDE OF THIS TAG, OR IF YOU WISH TO CHANGE SETTINGS IN THIS TAG, ADJUST dovecot.sh AND RERUN THE SETUP"
sudo mkdir -p "/var/www/vhosts/$mydomain/httpdocs"
sudo mkdir -p "/var/www/vhosts/$mydomain/httpsdocs"
sudo sed -i "/$start_tag/,/$end_tag/d" "$httpd_conf"
echo "$start_tag
<VirtualHost *:80>
<Directory /var/www/vhosts/$mydomain/httpdocs>
AllowOverride All
</Directory>
DocumentRoot /var/www/vhosts/$mydomain/httpdocs
ServerName $mydomain
Redirect permanent /mail https://$mydomain/mail
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCertificateFile $smtpd_tls_cert_file
SSLCertificateKeyFile $smtpd_tls_key_file
<Directory /var/www/vhosts/$mydomain/httpsdocs>
AllowOverride All
</Directory>
DocumentRoot /var/www/vhosts/$mydomain/httpsdocs
ServerName $mydomain
Alias /mail /usr/local/squirrelmail/www
<Directory /usr/local/squirrelmail/www>
Options None
AllowOverride None
DirectoryIndex index.php
Order Allow,Deny
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/*>
Deny from all
</Directory>
<Directory /usr/local/squirrelmail/www/scripts>
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/images>
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/plugins>
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/src>
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/templates>
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/themes>
Allow from all
</Directory>
<Directory /usr/local/squirrelmail/www/contrib>
Order Deny,Allow
Deny from All
Allow from 127
Allow from 10
Allow from 192
</Directory>
<Directory /usr/local/squirrelmail/www/doc>
Order Deny,Allow
Deny from All
Allow from 127
Allow from 10
Allow from 192
</Directory>
</VirtualHost>
$end_tag" | sudo tee -a "$httpd_conf"