2017-11-21 21:10:28 +00:00
|
|
|
|
#!/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 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/>.
|
|
|
|
|
|
|
|
|
|
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 recognize"
|
|
|
|
|
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"
|
2019-10-24 17:02:40 +00:00
|
|
|
|
if [[ -f /etc/phpmyadmin/apache.conf ]]
|
|
|
|
|
then
|
|
|
|
|
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf || exit 2
|
|
|
|
|
elif [[ -f /opt/phpmyadmin-apache.conf ]]
|
|
|
|
|
then
|
|
|
|
|
ln -s /opt/phpmyadmin-apache.conf /etc/apache2/conf-available/phpmyadmin.conf || exit 2
|
|
|
|
|
else
|
|
|
|
|
echo "Error - Missing configuration phpmyadmin for apache" >&2
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
2017-11-21 21:10:28 +00:00
|
|
|
|
|
2019-10-24 17:02:40 +00:00
|
|
|
|
a2enconf phpmyadmin.conf || exit 2
|
|
|
|
|
if [[ -f /etc/phpmyadmin/config.inc.php ]]
|
|
|
|
|
then
|
|
|
|
|
msg_debug "configure phpmyadmin /etc/phpmyadmin/config.inc.php"
|
|
|
|
|
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
|
|
|
|
|
elif [[ -f /usr/share/phpmyadmin/config.inc.php ]]
|
|
|
|
|
then
|
|
|
|
|
msg_debug "configure phpmyadmin /usr/share/phpmyadmin/config.inc.php"
|
|
|
|
|
sed -i "s/.*\$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\] =.*;/\$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\] = true;/g" /usr/share/phpmyadmin/config.inc.php || exit 2
|
|
|
|
|
elif [[ -f /usr/share/phpmyadmin/setup/frames/config.inc.php ]]
|
|
|
|
|
then
|
|
|
|
|
msg_debug "configure phpmyadmin /usr/share/phpmyadmin/setup/frames/config.inc.php"
|
|
|
|
|
cp /usr/share/phpmyadmin/setup/frames/config.inc.php /etc/phpmyadmin/config.inc.php || exit 2
|
|
|
|
|
echo "\$cfg['Servers'][\$i]['AllowNoPassword'] = TRUE;" >> /etc/phpmyadmin/config.inc.php || exit 2
|
|
|
|
|
else
|
|
|
|
|
echo "Error - Impossible to configure AllowNoPassword for phpMyAdmin" >&2
|
|
|
|
|
exit 2
|
|
|
|
|
fi
|
2017-11-21 21:10:28 +00:00
|
|
|
|
|
2018-06-28 08:45:45 +00:00
|
|
|
|
####################################
|
|
|
|
|
# Configure 1st page
|
|
|
|
|
####################################
|
|
|
|
|
msg_debug "Configure 1st page"
|
|
|
|
|
create_dir_gameserver '/home/gameserver/rootweb'
|
|
|
|
|
cp /opt/rootweb/* /home/gameserver/rootweb/ || exit 2
|
|
|
|
|
|
2017-11-21 21:10:28 +00:00
|
|
|
|
####################################
|
|
|
|
|
# configure phpmyadmin
|
|
|
|
|
####################################
|
|
|
|
|
msg_debug "configure apache"
|
|
|
|
|
# configure apache
|
|
|
|
|
cat << EOF > /etc/apache2/sites-available/000-default.conf
|
|
|
|
|
# Default
|
|
|
|
|
<VirtualHost *:80>
|
2018-06-28 08:45:45 +00:00
|
|
|
|
<Directory "/home/gameserver/rootweb/">
|
2017-11-21 21:10:28 +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
|
2018-07-09 19:48:03 +00:00
|
|
|
|
AddHandler application/x-httpd-php .sh
|
2017-11-21 21:10:28 +00:00
|
|
|
|
</Directory>
|
2018-06-28 08:45:45 +00:00
|
|
|
|
ServerName lirria.khaganat.net
|
2017-11-21 21:10:28 +00:00
|
|
|
|
|
2018-06-28 08:45:45 +00:00
|
|
|
|
ServerAdmin webmaster@localhost
|
|
|
|
|
DocumentRoot /home/gameserver/rootweb/
|
2017-11-21 21:10:28 +00:00
|
|
|
|
|
2018-06-28 08:45:45 +00:00
|
|
|
|
ErrorLog \${APACHE_LOG_DIR}/error.log
|
|
|
|
|
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
2017-11-21 21:10:28 +00:00
|
|
|
|
</VirtualHost>
|
|
|
|
|
|
|
|
|
|
# Khanat Server Web
|
|
|
|
|
<VirtualHost *:40916>
|
|
|
|
|
<Directory "/home/gameserver/khanat/khanatweb/">
|
|
|
|
|
Options Indexes FollowSymLinks
|
|
|
|
|
AllowOverride None
|
|
|
|
|
Require all granted
|
|
|
|
|
</Directory>
|
2018-06-28 08:45:45 +00:00
|
|
|
|
ServerName lirria.khaganat.net
|
2017-11-21 21:10:28 +00:00
|
|
|
|
|
2018-06-28 08:45:45 +00:00
|
|
|
|
ServerAdmin admin@localhost
|
|
|
|
|
DocumentRoot /home/gameserver/khanat/khanatweb/public_php
|
2017-11-21 21:10:28 +00:00
|
|
|
|
|
2018-06-28 08:45:45 +00:00
|
|
|
|
ErrorLog \${APACHE_LOG_DIR}/error.log
|
|
|
|
|
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
2017-11-21 21:10:28 +00:00
|
|
|
|
</VirtualHost>
|
|
|
|
|
|
|
|
|
|
# Patch Server
|
|
|
|
|
<VirtualHost *:43435>
|
|
|
|
|
ServerName lirria.khaganat.net
|
|
|
|
|
DocumentRoot /home/gameserver/khanat/patch_service/patch_game/patch/
|
|
|
|
|
|
2018-06-28 08:45:45 +00:00
|
|
|
|
<Directory "/home/gameserver/khanat/patch_service/patch_game/patch">
|
2017-11-21 21:10:28 +00:00
|
|
|
|
Options -Indexes
|
|
|
|
|
AllowOverride All
|
|
|
|
|
Require all granted
|
2018-06-28 08:45:45 +00:00
|
|
|
|
</Directory>
|
2017-11-21 21:10:28 +00:00
|
|
|
|
</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"
|