155 lines
4.2 KiB
Bash
Executable file
155 lines
4.2 KiB
Bash
Executable file
#!/bin/bash
|
||
#
|
||
# Configure apache
|
||
# Copyright (C) 2017 AleaJactaEst
|
||
#
|
||
# This program is free software: you can redistribute it and/or modify
|
||
# it under the terms of the GNU Affero General Public License as published by
|
||
# the Free Software Foundation, either version 3 of the License, or
|
||
# (at your option) any later version.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU Affero General Public License for more details.
|
||
#
|
||
# You should have received a copy of the GNU Affero General Public License
|
||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||
|
||
echo "CONFIGURE APACHE"
|
||
|
||
if [[ ! -f /home/gameserver/.bashrc ]]
|
||
then
|
||
echo "ERROR - missing /home/gameserver/.bashrc"
|
||
exit 2
|
||
fi
|
||
|
||
# load environment
|
||
source /home/gameserver/.bashrc
|
||
|
||
# Create directory use for patch server
|
||
#mkdir -p $KHANAT_PATH/khanatweb/public_php/
|
||
mkdir -p $PATCH_CLIENT_SYSTEM/patch_game/patch
|
||
mkdir -p $KHANAT_HOME/client_service/
|
||
|
||
# configure apache
|
||
cat << EOF > /etc/apache2/sites-available/000-default.conf
|
||
# Default
|
||
<VirtualHost *:80>
|
||
<Directory "$KHANAT_PATH/khanatweb/">
|
||
Options Indexes FollowSymLinks
|
||
AllowOverride None
|
||
Require all granted
|
||
DirectoryIndex index.php
|
||
AddType text/html .php .phps
|
||
AddHandler application/x-httpd-php .php
|
||
AddHandler application/x-httpd-php-source .phps
|
||
</Directory>
|
||
ServerName lirria.khaganat.net
|
||
|
||
ServerAdmin webmaster@localhost
|
||
DocumentRoot $KHANAT_PATH/khanatweb/public_php/
|
||
|
||
ErrorLog \${APACHE_LOG_DIR}/error.log
|
||
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
||
</VirtualHost>
|
||
|
||
# Khanat Server Web
|
||
<VirtualHost *:40916>
|
||
<Directory "$KHANAT_PATH/khanatweb/">
|
||
Options Indexes FollowSymLinks
|
||
AllowOverride None
|
||
Require all granted
|
||
</Directory>
|
||
ServerName lirria.khaganat.net
|
||
|
||
ServerAdmin admin@localhost
|
||
DocumentRoot $KHANAT_PATH/khanatweb/public_php
|
||
|
||
ErrorLog \${APACHE_LOG_DIR}/error.log
|
||
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
||
</VirtualHost>
|
||
|
||
# Patch Server
|
||
<VirtualHost *:43435>
|
||
ServerName lirria.khaganat.net
|
||
DocumentRoot $PATCH_HOME/patch_service/patch_game/patch/
|
||
|
||
<Directory "$PATCH_HOME/patch_service/patch_game/patch">
|
||
Options -Indexes
|
||
AllowOverride All
|
||
Require all granted
|
||
</Directory>
|
||
</VirtualHost>
|
||
EOF
|
||
|
||
# Open port use by apache
|
||
cat << EOF > /etc/apache2/ports.conf
|
||
# If you just change the port or add more ports here, you will likely also
|
||
# have to change the VirtualHost statement in
|
||
# /etc/apache2/sites-enabled/000-default.conf
|
||
|
||
Listen 80
|
||
Listen 40916
|
||
Listen 43435
|
||
|
||
<IfModule ssl_module>
|
||
Listen 443
|
||
</IfModule>
|
||
|
||
<IfModule mod_gnutls.c>
|
||
Listen 443
|
||
</IfModule>
|
||
|
||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
||
EOF
|
||
|
||
|
||
# Activate php - strange beacause we have only index.php (without php code !)
|
||
cat << EOF > /etc/apache2/conf-available/patch_service.conf
|
||
Alias /patch /home/gameserver/patch_service/patch_game/patch
|
||
<Directory /home/gameserver/patch_service/patch_game/patch>
|
||
Options FollowSymLinks
|
||
DirectoryIndex index.php
|
||
|
||
Require all granted
|
||
|
||
<IfModule mod_php5.c>
|
||
<IfModule mod_mime.c>
|
||
AddType application/x-httpd-php .php
|
||
</IfModule>
|
||
<FilesMatch ".+\.php$">
|
||
SetHandler application/x-httpd-php
|
||
</FilesMatch>
|
||
</IfModule>
|
||
</Directory>
|
||
EOF
|
||
|
||
# Activate & deploy new configuration
|
||
a2enconf patch_service.conf
|
||
|
||
# Configuration de la page client
|
||
cat << EOF > /etc/apache2/conf-available/client_service.conf
|
||
Alias /client /home/gameserver/client_service
|
||
<Directory /home/gameserver/client_service>
|
||
Options FollowSymLinks
|
||
DirectoryIndex index.html
|
||
|
||
Require all granted
|
||
<IfModule mod_php5.c>
|
||
<IfModule mod_mime.c>
|
||
AddType application/tar .tar.gz
|
||
</IfModule>
|
||
<FilesMatch ".+\.php$">
|
||
SetHandler application/tar
|
||
</FilesMatch>
|
||
</IfModule>
|
||
</Directory>
|
||
EOF
|
||
|
||
# Activate & deploy new configuration
|
||
a2enconf client_service.conf
|
||
|
||
# Restart apache
|
||
service apache2 restart || exit 2
|
||
|