#!/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 . 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 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 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 # Khanat Server Web Options Indexes FollowSymLinks AllowOverride None Require all granted 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 # Patch Server ServerName lirria.khaganat.net DocumentRoot $PATCH_HOME/patch_service/patch_game/patch/ Options -Indexes AllowOverride All Require all granted 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 Listen 443 Listen 443 # 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 Options FollowSymLinks DirectoryIndex index.php Require all granted AddType application/x-httpd-php .php SetHandler application/x-httpd-php 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 Options FollowSymLinks DirectoryIndex index.html Require all granted AddType application/tar .tar.gz SetHandler application/tar EOF # Activate & deploy new configuration a2enconf client_service.conf # Restart apache service apache2 restart || exit 2