2017-09-11 18:53:54 +00:00
|
|
|
|
#!/bin/bash
|
2017-10-09 20:10:36 +00:00
|
|
|
|
# Prepare/Configure Apache
|
2017-09-11 18:53:54 +00:00
|
|
|
|
#
|
|
|
|
|
# Copyright (C) 2017 AleaJactaEst
|
|
|
|
|
#
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU 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 General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
usage()
|
|
|
|
|
{
|
|
|
|
|
cat << EOF
|
|
|
|
|
usage:$0 [options]
|
|
|
|
|
prepare mysql (create directory, update configuration)
|
2017-09-11 18:53:54 +00:00
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
options:
|
|
|
|
|
-h, --help : Show this help
|
|
|
|
|
-d, --debug : Show debug message
|
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#####################
|
|
|
|
|
# MAIN
|
|
|
|
|
#####################
|
|
|
|
|
source /opt/servercontainer_function.sh
|
|
|
|
|
msg_info "$(basename $0) => START"
|
|
|
|
|
|
|
|
|
|
while test $# -gt 0
|
|
|
|
|
do
|
|
|
|
|
case "$1" in
|
|
|
|
|
-h|--help)
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
-d|--debug)
|
|
|
|
|
set_debug 1
|
|
|
|
|
shift
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
msg_error "options '$1' not recoginze"
|
|
|
|
|
usage
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
####################################
|
|
|
|
|
# Load Environment
|
|
|
|
|
####################################
|
|
|
|
|
msg_debug "Load environment"
|
|
|
|
|
if [[ ! -f /opt/khanat_config.sh ]]
|
2017-09-11 18:53:54 +00:00
|
|
|
|
then
|
2017-10-09 20:10:36 +00:00
|
|
|
|
echo "ERROR - missing /opt/khanat_config.sh"
|
2017-09-11 18:53:54 +00:00
|
|
|
|
exit 2
|
|
|
|
|
fi
|
2017-10-09 20:10:36 +00:00
|
|
|
|
source /opt/khanat_config.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################################
|
|
|
|
|
# Configure apache log / Account use by apache
|
|
|
|
|
####################################
|
|
|
|
|
msg_debug "Configure apache log / Account use by apache"
|
|
|
|
|
sed -i -r 's/^export[[:space:]]+APACHE_RUN_USER=(.*)/export APACHE_RUN_USER=gameserver/g' /etc/apache2/envvars || exit 2
|
|
|
|
|
sed -i -r 's/^export[[:space:]]+APACHE_RUN_GROUP=(.*)/export APACHE_RUN_GROUP='$(id -g -n gameserver)'/g' /etc/apache2/envvars || exit 2
|
|
|
|
|
sed -i -r 's/^export[[:space:]]+APACHE_LOG_DIR=(.*)/export APACHE_LOG_DIR=\/home\/gameserver\/log\/apache2\$SUFFIX/g' /etc/apache2/envvars || exit 2
|
|
|
|
|
sed -i -r 's/^LogLevel[[:space:]]+warn/LogLevel debug/g' /etc/apache2/apache2.conf || exit 2
|
2017-09-11 18:53:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
####################################
|
|
|
|
|
# configure phpmyadmin
|
|
|
|
|
####################################
|
|
|
|
|
msg_debug "configure phpmyadmin"
|
|
|
|
|
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf || exit 2
|
|
|
|
|
a2enconf phpmyadmin.conf || exit 2
|
|
|
|
|
cp /etc/phpmyadmin/config.inc.php /etc/phpmyadmin/config.inc.php.ref || exit 2
|
|
|
|
|
awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
####################################
|
|
|
|
|
# configure phpmyadmin
|
|
|
|
|
####################################
|
|
|
|
|
msg_debug "configure apache"
|
2017-09-11 18:53:54 +00:00
|
|
|
|
# configure apache
|
|
|
|
|
cat << EOF > /etc/apache2/sites-available/000-default.conf
|
|
|
|
|
# Default
|
|
|
|
|
<VirtualHost *:80>
|
2017-10-09 20:10:36 +00:00
|
|
|
|
<Directory "/home/gameserver/khanat/khanatweb/">
|
2017-09-11 18:53:54 +00:00
|
|
|
|
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
|
2017-10-09 20:10:36 +00:00
|
|
|
|
DocumentRoot /home/gameserver/khanat/khanatweb/public_php/
|
2017-09-11 18:53:54 +00:00
|
|
|
|
|
|
|
|
|
ErrorLog \${APACHE_LOG_DIR}/error.log
|
|
|
|
|
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
|
|
|
|
</VirtualHost>
|
|
|
|
|
|
|
|
|
|
# Khanat Server Web
|
|
|
|
|
<VirtualHost *:40916>
|
2017-10-09 20:10:36 +00:00
|
|
|
|
<Directory "/home/gameserver/khanat/khanatweb/">
|
2017-09-11 18:53:54 +00:00
|
|
|
|
Options Indexes FollowSymLinks
|
|
|
|
|
AllowOverride None
|
|
|
|
|
Require all granted
|
|
|
|
|
</Directory>
|
|
|
|
|
ServerName lirria.khaganat.net
|
|
|
|
|
|
|
|
|
|
ServerAdmin admin@localhost
|
2017-10-09 20:10:36 +00:00
|
|
|
|
DocumentRoot /home/gameserver/khanat/khanatweb/public_php
|
2017-09-11 18:53:54 +00:00
|
|
|
|
|
|
|
|
|
ErrorLog \${APACHE_LOG_DIR}/error.log
|
|
|
|
|
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
|
|
|
|
</VirtualHost>
|
|
|
|
|
|
|
|
|
|
# Patch Server
|
|
|
|
|
<VirtualHost *:43435>
|
|
|
|
|
ServerName lirria.khaganat.net
|
2017-10-09 20:10:36 +00:00
|
|
|
|
DocumentRoot /home/gameserver/khanat/patch_service/patch_game/patch/
|
2017-09-11 18:53:54 +00:00
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
<Directory "/home/gameserver/khanat/patch_service/patch_game/patch">
|
2017-09-11 18:53:54 +00:00
|
|
|
|
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
|
2017-10-09 20:10:36 +00:00
|
|
|
|
Alias /patch /home/gameserver/khanat/patch_service/patch_game/patch
|
|
|
|
|
<Directory /home/gameserver/khanat/patch_service/patch_game/patch>
|
2017-09-11 18:53:54 +00:00
|
|
|
|
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
|
|
|
|
|
|
2017-09-15 20:44:13 +00:00
|
|
|
|
# Configuration de la page client
|
|
|
|
|
cat << EOF > /etc/apache2/conf-available/client_service.conf
|
2017-10-09 20:10:36 +00:00
|
|
|
|
Alias /client /home/gameserver/khanat/client_service
|
|
|
|
|
<Directory /home/gameserver/khanat/client_service>
|
2017-09-15 20:44:13 +00:00
|
|
|
|
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
|
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
####################################
|
|
|
|
|
# Activate web site
|
|
|
|
|
####################################
|
|
|
|
|
|
|
|
|
|
msg_info "Activate patch service"
|
|
|
|
|
# Activate & deploy new configuration
|
|
|
|
|
a2enconf patch_service.conf
|
|
|
|
|
|
|
|
|
|
msg_info "Activate client service"
|
2017-09-15 20:44:13 +00:00
|
|
|
|
# Activate & deploy new configuration
|
|
|
|
|
a2enconf client_service.conf
|
2017-09-11 18:53:54 +00:00
|
|
|
|
|
|
|
|
|
|
2017-10-09 20:10:36 +00:00
|
|
|
|
####################################
|
|
|
|
|
# End
|
|
|
|
|
####################################
|
|
|
|
|
msg_info "$(basename $0) => END"
|