mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-02 00:06:00 +00:00
221 lines
6.2 KiB
Bash
Executable file
221 lines
6.2 KiB
Bash
Executable file
#!/bin/bash
|
||
# Prepare/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 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/>.
|
||
|
||
usage()
|
||
{
|
||
cat << EOF
|
||
usage:$0 [options]
|
||
prepare mysql (create directory, update configuration)
|
||
|
||
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 ]]
|
||
then
|
||
echo "ERROR - missing /opt/khanat_config.sh"
|
||
exit 2
|
||
fi
|
||
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
|
||
|
||
|
||
|
||
####################################
|
||
# 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"
|
||
# configure apache
|
||
cat << EOF > /etc/apache2/sites-available/000-default.conf
|
||
# Default
|
||
<VirtualHost *:80>
|
||
<Directory "/home/gameserver/khanat/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 /home/gameserver/khanat/khanatweb/public_php/
|
||
|
||
ErrorLog \${APACHE_LOG_DIR}/error.log
|
||
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
||
</VirtualHost>
|
||
|
||
# Khanat Server Web
|
||
<VirtualHost *:40916>
|
||
<Directory "/home/gameserver/khanat/khanatweb/">
|
||
Options Indexes FollowSymLinks
|
||
AllowOverride None
|
||
Require all granted
|
||
</Directory>
|
||
ServerName lirria.khaganat.net
|
||
|
||
ServerAdmin admin@localhost
|
||
DocumentRoot /home/gameserver/khanat/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 /home/gameserver/khanat/patch_service/patch_game/patch/
|
||
|
||
<Directory "/home/gameserver/khanat/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/khanat/patch_service/patch_game/patch
|
||
<Directory /home/gameserver/khanat/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
|
||
|
||
# Configuration de la page client
|
||
cat << EOF > /etc/apache2/conf-available/client_service.conf
|
||
Alias /client /home/gameserver/khanat/client_service
|
||
<Directory /home/gameserver/khanat/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 web site
|
||
####################################
|
||
|
||
msg_info "Activate patch service"
|
||
# Activate & deploy new configuration
|
||
a2enconf patch_service.conf
|
||
|
||
msg_info "Activate client service"
|
||
# Activate & deploy new configuration
|
||
a2enconf client_service.conf
|
||
|
||
|
||
####################################
|
||
# End
|
||
####################################
|
||
msg_info "$(basename $0) => END"
|