adding buster image

This commit is contained in:
AleaJactaEst 2019-10-24 19:02:40 +02:00
parent efd7f0d1a0
commit 6cf69b86ef
28 changed files with 1605 additions and 64 deletions

View file

@ -18,6 +18,7 @@
# Example to execute locally:
# gitlab-runner exec docker --kubernetes-memory-limit="10g" --kubernetes-service-memory-limit="10g" --kubernetes-memory-request="10g" --kubernetes-helper-memory-limit="10g" 'Linux server build'
# gitlab-runner exec docker --timeout=3600 'Linux server build'
# gitlab-runner exec docker --timeout=3600 --kubernetes-memory-limit="10g" --kubernetes-service-memory-limit="10g" --kubernetes-memory-request="10g" --kubernetes-helper-memory-limit="10g" --docker-volumes $PWD/builds:/builds 'Linux server debian buster build'
stages:
@ -98,3 +99,89 @@ Linux server build:
name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-server-debian-stretch"
paths:
- khanat-debian-server.tar.gz
when: manual
Linux server debian buster build:
stage: build
tags:
- Docker
image: amd64/debian:10
script:
- export -p WORKDIR=$PWD
- apt-get update
- apt-get dist-upgrade -y
- DEBIAN_FRONTEND=noninteractive apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx openssh-server sudo net-tools lzma xdelta p7zip p7zip-full default-mysql-server apache2 php libapache2-mod-php php-mysql apache2-utils php-gd php-imagick rrdtool screen mcrypt python3 gdb valgrind electric-fence python3-pip python3-bcrypt python3-pip ddd libc6 libgnutls28-dev libgnutlsxx28 php7.3-curl php7.3-mbstring patch gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php7.3-dev wget jq git unzip
- pecl install mcrypt-1.0.2
- sed -i 's/;extension=xsl/extension=mcrypt.so/g' /etc/php/7.3/cli/php.ini
- sed -i 's/;extension=xsl/extension=mcrypt.so/g' /etc/php/7.3/apache2/php.ini
- wget -q https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz
- mkdir -p /etc/phpmyadmin /usr/share/phpmyadmin /var/lib/phpmyadmin/tmp
- tar xf phpMyAdmin-4.9.0.1-all-languages.tar.gz -C /usr/share/phpmyadmin --strip 1
- chown -R www-data:www-data /var/lib/phpmyadmin
- cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
- mkdir -p /opt/download
- export -p DIR_ARTEFACTS="/opt/download"
- (cd /opt/download ; $WORKDIR/server/common/download_artefacts.sh 'https://git.khaganat.net' 'khaganat' 'mmorpg_khanat/khanat-opennel-code' $CI_COMMIT_REF_NAME 'develop' 'master')
- (cd /opt/download ; $WORKDIR/server/common/download_artefacts.sh 'https://git.khaganat.net' 'khaganat' 'mmorpg_khanat/opennel-pymanager' $CI_COMMIT_REF_NAME 'develop' 'master')
- ls -l /opt/download
- mkdir -p /opt/artefacts
- (cd /opt/artefacts ; for file in /opt/download/khanat-server_static_debug-debian_amd64_buster*.zip ; do echo "extract $file"; unzip -q -o $file; done)
- (cd /opt/artefacts ; for file in /opt/download/khanat-client-debian_buster*.zip ; do echo "extract $file"; unzip -q -o $file; done)
- (cd /opt/artefacts ; for file in /opt/download/opennel-manager-*.zip ; do echo "extract $file"; unzip -q -o $file; done)
- mkdir -p /opt/ext
- cp $WORKDIR/server/debian/common/servercontainer_init_* /opt/
- cp $WORKDIR/server/debian/common/servercontainer_function.sh /opt/
- cp $WORKDIR/server/debian/common/* /opt/ext
- cp $WORKDIR/server/debian/common/khaganat.cfg /opt/ext
- mkdir -p /opt/rootweb
- cp $WORKDIR/server/common/rootweb/* /opt/rootweb/
- echo -e 'export KHANAT_CLIENT_VERSION="1"\nexport UIDGAMESERVER=1000\nexport GIDGAMESERVER=1000\nexport DIRCLIENT="Khanat_Linux64"\nexport PACKAGECLIENT="smokey_linux64"' > /opt/khanat_config.sh
- mkdir -p /var/run/mysqld
- /opt/servercontainer_init_create_account.sh
- /opt/servercontainer_init_mysql.sh
- /opt/servercontainer_init_apache.sh
- /opt/servercontainer_init_configure_envi.sh
- source /home/gameserver/.bashrc
# - export -p KHANAT_HOME=/home/gameserver
# - export -p KHANAT_PATH=/home/gameserver/khanat
# - export -p PATH=$PATH:/usr/local/bin
# - export -p PATCH_CLIENT_SYSTEM=$KHANAT_HOME/khanat/patch_service
# - export -p DIRCLIENT="Khanat_Linux64"
# - export -p PACKAGECLIENT="smokey_linux64"
# - export -p PREPARE_CLIENT_DIR="khanat/prepare_client/$DIRCLIENT"
# - export -p CLIENT_DIR="khanat/client_service"
# - export -p HOME_PREPARE_CLIENT="$KHANAT_HOME/$PREPARE_CLIENT_DIR"
# - export -p HOME_CLIENT="$KHANAT_HOME/$CLIENT_DIR"
- echo "KHANAT_PATH $KHANAT_PATH"
- mkdir -p $KHANAT_PATH
- mkdir -p /home/gameserver/ext
- ln -s /opt/artefacts/code/web /home/gameserver/ext/khanatweb
- ln -s /opt/artefacts/code/ryzom /home/gameserver/ext/ryzom-ressources
- (cd /home/gameserver/ext; git clone -q https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git)
#- ln -s /opt/download/khanat-ressources /home/gameserver/ext/khanat-ressources
- (cd /home/gameserver/ext; git clone -q https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git)
#- ln -s /opt/download/khanat-client-data /home/gameserver/ext/khanat-client-data
- for file in /opt/artefacts/code/build/bin/* ; do ln -s $file /usr/local/bin ; done
- for file in /opt/artefacts/code/build/lib/* ; do ln -s $file /usr/local/lib ; done
- ldconfig
- /opt/ext/servercontainer_configure_auto.sh
- /opt/ext/servercontainer_update_auto.sh
# Install pymanager
- ls /opt/artefacts/dist/
- pip3 install /opt/artefacts/dist/opennel_manager-*.whl
# Clean
- rm -f /opt/servercontainer*
# Create image
- option=""
- echo "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-server-debian-stretch" > /home/gameserver/version.txt
- for dir in /home/* ; do if [ $dir != '/home/gameserver' ] ; then option="$option --exclude=$dir" ; fi ; done
- echo "option '$option'"
#- find /home/gameserver -type d -exec du -sh {} \;
- find /opt -type d -exec du -sh {} \;
- tar --numeric-owner --exclude=.git --exclude=.dockerenv --exclude=/proc --exclude=/sys --exclude=/builds --exclude=/opt/download --exclude=khanat-debian-skedelererver.tar.gz $option -czf khanat-debian-server.tar.gz /
- ls -lh khanat-debian-server.*
artifacts:
name: "khanat-$(echo $CI_BUILD_REF | head -c 7 )-$CI_PIPELINE_ID-server-debian-buster"
paths:
- khanat-debian-server.tar.gz

View file

@ -29,10 +29,11 @@ FROM amd64/debian:9
MAINTAINER AleaJactaEst
ENV HOSTNAME builder
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update ; \
apt-get dist-upgrade -y; \
DEBIAN_FRONTEND=noninteractive apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql python3 python3-pip python3-bcrypt python3-venv rrdtool unzip wget zlib1g-dev python3-coverage python3-pep8
RUN apt-get update && \
apt-get dist-upgrade -y && \
apt-get install -y apache2 apache2-utils autoconf autogen automake bison build-essential cmake cpputest default-libmysqlclient-dev fakeroot git libapache2-mod-php libboost-all-dev libfreetype6-dev libgif-dev libgl1-mesa-dev libjpeg62-turbo-dev liblua5.2-0 liblua5.2-dev liblzma-dev libogg-dev libopenal-dev libpng-dev libssh2-1-dev libssl-dev libtool libtool-bin libvorbis-dev libx11-dev libxml2-dev libxmu-dev libxrandr-dev libxrender-dev libxxf86vm-dev mercurial mysql-server php php-gd php-imagick php-mysql python3 python3-pip python3-bcrypt python3-venv rrdtool unzip wget zlib1g-dev python3-coverage python3-pep8 xsltproc rsync
## Build & Install cpptest
# Impossible to build release 1.1.0, 1.1.1, 1.1.2

View file

@ -25,6 +25,7 @@ declare CXXFLAGS=""
declare -i DONTCOPYSOURCE=0
declare -i BUILD_OPENNEL_CODE=1
declare -i PACKAGE_OPENNEL_PYMANAGER=1
declare -i REGENERATE_DATABASE=0
function usage()
{
@ -37,10 +38,15 @@ workdir: directory use to buid
options:
-h, --help : Show this help
-d, --debug : Show debug message
--add-opts-cmake="string" : add option use on command cmake (generate Makefile)
--add-opts-make="string" : add option use on command make
--cxxflags=[String] : adding cxx flags when generate Makefile (and build)
--dont-copy-source : disable copy source, work directly on source (apply patch)
--add-opts-cmake="string" : add option use on command cmake (generate Makefile)
--add-opts-make="string" : add option use on command make
--cxxflags=[String] : adding cxx flags when generate Makefile (and build)
--dont-copy-source : disable copy source, work directly on source (apply patch)
--build-dir=<directory> : build directory
--code-dir=<directory> : code source localization
--opennel-pymanager-dir=<directory> : opennel manager localization code
--cxxflags="string" : option to add for C++ builder
--regenerate-database : regenerate database_plr.cpp & database_plr.h (depend of database.xml)
EOF
}
@ -150,6 +156,10 @@ do
PACKAGE_OPENNEL_PYMANAGER=0
shift
;;
--regenerate-database)
REGENERATE_DATABASE=1
shift
;;
*)
msg_error "options '$1' not recognize"
usage
@ -168,6 +178,7 @@ msg_debug "MAKEOPTS:$MAKEOPTS"
msg_debug "LOGFILE:$LOGFILE"
msg_debug "CXXFLAGS:$CXXFLAGS"
msg_debug "DONTCOPYSOURCE:$DONTCOPYSOURCE"
msg_debug "REGENERATE_DATABASE:$REGENERATE_DATABASE"
msg_info "CREATE BUILD DIRECTORY"
mkdir -p ${DIRBUILD}/ || exit 2
@ -199,6 +210,16 @@ then
patch_onlyifnotapply ${DIRCODE}/patch/$patchfile || exit 2
done
if [[ $REGENERATE_DATABASE -ne 0 ]]
then
msg_info "GENERATE DATABASE HEADER"
find / -name generate_client_db.xslt 2>/dev/null
cd ${DIRBUILD}/opennel-code/code/ryzom/common/src/game_share; xsltproc --stringparam filename database --stringparam bank PLR --stringparam output header --stringparam side server --output ../../../server/src/entities_game_service/database_plr.h generate_client_db.xslt ../../data_common/database.xml || exit 2
msg_info "GENERATE DATABASE CODE"
cd ${DIRBUILD}/opennel-code/code/ryzom/common/src/game_share; xsltproc --stringparam filename database --stringparam bank PLR --stringparam output cpp --stringparam side server --output ../../../server/src/entities_game_service/database_plr.cpp generate_client_db.xslt ../../data_common/database.xml || exit 2
fi
msg_info "PREPARE BUILD"
msg_debug "cd ${DIRBUILD}; CXXFLAGS="$CXXFLAGS" cmake -DWITH_NEL=ON -DWITH_STATIC=ON -DWITH_STATIC_DRIVERS=ON -DWITH_STATIC_EXTERNAL=ON -DWITH_SYMBOLS=ON -DWITH_LUA52=ON -DWITH_RYZOM_PATCH=ON -DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON ${CMAKEOPTS} ${DIRCODEUSE}/code 1>>$LOGFILE 2>&1 "
cd ${DIRBUILD}; CXXFLAGS="$CXXFLAGS" cmake -DWITH_NEL=ON \

View file

@ -277,7 +277,7 @@ mkdir -p "${DIRBUILD}"
if [[ $REMOVE -ne 0 ]]
then
msg_info "REMOVE OLD BUILD"
rm -rf ${DIRBUILD}/* || exit 2
rm -rf ${DIRBUILD}/* || exit 2
fi
touch ${DIRBUILD}/build.log
@ -314,7 +314,7 @@ then
--hostname=builder \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v $rootdir/builder:/opt/ref/builder:ro \
-v $codedir:/opt/ref/opennel-code:rw \
-v $codedir:/opt/ref/opennel-code:ro \
-v $pymanagerdir:/opt/ref/opennel-pymanager:ro \
-v $rootdir/build:/opt/build \
-v /etc/localtime:/etc/localtime:ro \

View file

@ -80,6 +80,7 @@ if (file_exists('/home/gameserver/opennelmanager.flag')) {
<a href="/EnableJavascript" id="admin-href" >Administration</a>
<a href="/phpmyadmin/">phpmyadmin</a>
<a href="/patch/">patch</a>
<a href="/info.php">info</a>
</p>
<div id='title_info'>KHANAT SERVER DOCKER (TEST ENVIRONMENT)</div>
<div id='important_info'><?php print "SERVER IP: ". getHostByName(gethostname()); ?> </div>

View file

@ -0,0 +1,4 @@
<?php
//Call the phpinfo function.
phpinfo();
?>

View file

@ -147,6 +147,17 @@ table, th, td {
<div id='title_info'>KHANAT SERVER DOCKER (TEST ENVIRONMENT - STATES)</div>
<?php
function split_simple($data, $separator)
{
$pos = strpos($data, $separator);
if ( $pos == false ) {
return $data;
return "";
} else {
return explode($separator, $data, 2);
}
}
function get_port($filecfg)
{
// $ini_array = parse_ini_file($filecfg);
@ -155,8 +166,9 @@ function get_port($filecfg)
$fp = fopen($filecfg, "r");
if ($fp) {
while (($line = fgets($fp)) !== false) {
list($data, $comment) = explode('#', $line, 2);
list($key, $value) = explode('=', $line, 2);
$pos = strpos($line, '#');
list($data, $comment) = split_simple('#', $line);
list($key, $value) = split_simple('=', $data);
$key = trim($key);
if ( $key == "port" ) {
return trim($value);
@ -192,7 +204,6 @@ if (file_exists('/home/gameserver/opennelmanager.flag')) {
ksort($data);
foreach ($data as $key => $value)
{
list($val1, $val2) = explode(':', $value, 2);
$state=$value['state'];
$number_launch=$value['number_launch'];
$number_launch=$value['number_launch'];
@ -223,7 +234,7 @@ if (file_exists('/home/gameserver/opennelmanager.flag')) {
echo "<a>OpenNelManager not used</a>";
}
} else {
echo "<a>OpenNelManager not actiavted</a>";
echo "<a>OpenNelManager not activated</a>";
}
?>

View file

@ -114,8 +114,17 @@ function get_port($filecfg)
$fp = fopen($filecfg, "r");
if ($fp) {
while (($line = fgets($fp)) !== false) {
list($data, $comment) = explode('#', $line, 2);
list($key, $value) = explode('=', $line, 2);
$datawithoutcomment = explode('#', $line);
$data = explode('=', $datawithoutcomment[0]);
if ( count($data) >= 2 ) {
list($key, $value) = explode('=', $datawithoutcomment[0], 2);
} else if ( count($data) == 1 ) {
$key = $data[0];
$value = "";
} else {
$key = "";
$value = "";
}
$key = trim($key);
if ( $key == "port" ) {
return trim($value);
@ -126,6 +135,26 @@ function get_port($filecfg)
return "8000";
}
function is_valid_type($type)
{
if ( $type == 'INF' ) { // Information
return true;
} else if ( $type == 'DBG') { // Information
return true;
} else if ( $type == 'WRN') { // Warning
return true;
} else if ( $type == 'ERR') { // Error
return true;
} else if ( $type == 'STT') { // Statistic
return true;
} else if ( $type == 'AST') { // Assert
return true;
} else if ( $type == 'UKN') { // Unknown
return true;
}
return false;
}
$cfgfile = "/home/gameserver/khanat/khaganat.cfg";
if (file_exists($cfgfile)) {
@ -166,8 +195,29 @@ if (file_exists($cfgfile)) {
if ( $key == "first-line" or $key == "last-line" )
continue;
list($date, $hour, $timezone, $typesrc, $addr, $program, $line, $msg, $type) = array('', '', '', '', '', '', '', '', '?');
// 2018/08/03 10:45:36 CEST INF 442b0740 command.cpp 149
list($date, $hour, $timezone, $typesrc, $addr, $program, $line, $msg) = explode(' ', $value, 8);
$arrayret = explode(' ', $value);
if ( count($arrayret) >= 8 ) {
list($date, $hour, $timezone, $typesrc, $addr, $program, $line, $msg) = explode(' ', $value, 8);
if ( ! is_numeric($line) ) {
if ( is_valid_type($line) ) {
list($date, $hour, $timezone, $data1, $hour1, $kind, $typesrc, $addr, $program, $line, $msg) = explode(' ', $value, 11);
$msg = "[$data1 $hour1 $kind] $msg";
} else {
list($date, $hour, $timezone, $msg) = explode(' ', $value, 4);
$msg = "$msg";
}
} else {
$msg = "$msg";
}
} else if ( count($arrayret) >= 4 ) {
$arrayret = explode(' ', $value, 4);
list($date, $hour, $timezone, $msg) = explode(' ', $value, 4);
} else {
$msg = $value;
}
$type = substr( $typesrc, strlen($typesrc) - 3 );
if ( $type == 'INF' ) { // Information
@ -185,11 +235,11 @@ if (file_exists($cfgfile)) {
} else if ( $type == 'UKN') { // Unknown
$fond = "bgcolor=\"Tomato\"";
} else {
$msg = "$typesrc $addr $program $line $msg";
//$msg = "$typesrc $addr $program $line $msg";
$type = "?";
$addr = "";
$program = "";
$line = "";
//$addr = "";
//$program = "";
//$line = "";
$fond = "bgcolor=\"Tomato\"";
}
if ( $program != "" && $line != "" )

View file

@ -0,0 +1,44 @@
# Dockerfile - Build image to prepare khanat server
#
# 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/>.
#
FROM amd64/debian:10
MAINTAINER AleaJactaEst
ENV HOSTNAME basic_server
ENV DISPLAY :0
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update ; \
apt-get dist-upgrade -y ; \
apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx openssh-server sudo net-tools lzma xdelta p7zip p7zip-full default-mysql-server apache2 php libapache2-mod-php php-mysql apache2-utils php-gd php-imagick rrdtool screen mcrypt python3 gdb valgrind electric-fence python3-pip python3-bcrypt python3-pip ddd libc6 libgnutls28-dev libgnutlsxx28 php7.3-curl php7.3-mbstring patch
# Install php-mcrypt
RUN apt-get -y install gcc make autoconf libc-dev pkg-config libmcrypt-dev php-pear php7.3-dev; \
pecl install mcrypt-1.0.2
RUN sed -i 's/;extension=xsl/extension=mcrypt.so/g' /etc/php/7.3/cli/php.ini;\
sed -i 's/;extension=xsl/extension=mcrypt.so/g' /etc/php/7.3/apache2/php.ini
# Install phpmyadmin
RUN apt-get -y install wget ;\
wget -q https://files.phpmyadmin.net/phpMyAdmin/4.9.0.1/phpMyAdmin-4.9.0.1-all-languages.tar.gz ;\
mkdir -p /etc/phpmyadmin /usr/share/phpmyadmin /var/lib/phpmyadmin/tmp ; \
tar xf phpMyAdmin-4.9.0.1-all-languages.tar.gz -C /usr/share/phpmyadmin --strip 1 ; \
chown -R www-data:www-data /var/lib/phpmyadmin ; \
cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php

View file

@ -0,0 +1,37 @@
# Dockerfile - Build for server debian
#
# 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/>.
#
FROM opennel/server_generic_debian_buster_x86_64
MAINTAINER AleaJactaEst
ENV HOSTNAME khanat_server
RUN ulimit -c unlimited
COPY server/debian/common/servercontainer_function.sh /opt/
COPY server/debian/common/servercontainer_init_* /opt/
COPY server/debian/common/phpmyadmin-apache.conf /opt/
COPY output/opennel_debian_buster_x86_64/khanat_config.sh /opt/khanat_config.sh
COPY server/common/rootweb/* /opt/rootweb/
RUN /opt/servercontainer_init_create_account.sh
RUN /opt/servercontainer_init_mysql.sh
RUN /opt/servercontainer_init_apache.sh -d
RUN /opt/servercontainer_init_configure_envi.sh

View file

@ -0,0 +1,33 @@
# Dockerfile - Build for server debian
#
# 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/>.
#
FROM opennel/server_generic_debian_stretch_x86_64
MAINTAINER AleaJactaEst
ENV HOSTNAME khanat_server
COPY todelete.sh /opt/khanat_config.sh
COPY server/debian/common/ /opt/
COPY output/extra/ryzomcore.tar.gz /opt/
COPY output/extra/ryzom-ressources.tar.gz /opt/
COPY output/extra/khanat-ressources.tar.gz /opt/
COPY output/extra/khanat-client-data.tar.gz /opt/
RUN /opt/serverimage_init_khanat.sh

View file

@ -0,0 +1,576 @@
#!/bin/bash
#
# Script to start khanat server (with docker)
# All data are include on host
#
# 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/>.
declare -i REMOVE=0
declare -i IMAGE=1
declare -i BASICSERVER=0
declare -i KHANATSERVER=0
declare -i CONFIGUREKHANATSERVER=0
declare -i LAUNCHKHANAT=1
declare -i UPDATEDATA=0
declare -i DEBUG=0
declare -i AUTODETEC=1
declare -i STOPKHANAT=0
declare -i CLEANCONTAINERKHANAT=0
declare -i CONNECTSSHKHANAT=0
declare -i KHANAT_CLIENT_VERSION=1
declare -i SHOWIPKHANATSERVER=0
declare METHODSTARTSERVER="--opennel-manager"
declare -i CLEANIMAGENONE=0
declare DOCKERBUILDOPT=""
declare DOCKERRUNOPT=""
declare CONFIGUREAUTO=""
declare UPDATEAUTO=""
declare -i CLEARTERMINAL=0
declare IMAGEGENERICSERVER="opennel/server_generic_debian_buster_x86_64"
declare IMAGEKHANATSERVER="opennel/servercontainer_debian_buster_x86_64"
declare LOCALBUILDDIR="build/opennel/builder_debian_buster_x86_64"
declare DIROUTPUT="output/opennel_debian_buster_x86_64"
declare ROOTDATAKHANAT="$DIROUTPUT/gameserver"
declare DIRLOG="$ROOTDATAKHANAT/log"
declare DIRDATABASE="$ROOTDATAKHANAT/database"
declare ENVIFILE="$DIROUTPUT/khanat_config.sh"
declare DIRKHANAT="$ROOTDATAKHANAT/khanat"
declare DIRLOCAL="$ROOTDATAKHANAT/.local"
declare KHANAT_RESSOURCES_DIR=""
declare KHANAT_CLIENT_DATA_DIR=""
declare OPENNEL_CODE_DIR=""
declare PYMANAGER=""
declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok"
declare DIRCLIENT="Khanat_Linux64"
declare PACKAGECLIENT="smokey_linux64"
usage()
{
cat << EOF
usage:$0 [options]
script to build under docker
Step:
1) create image basic server
2) create image khanat server
3) configure khagant server
4) launch khagant server
options:
-h, --help : Show this help
-d, --debug : Show debug message
-r, --remove : Remove directory data khanat
-b, --force-basic : Force create/recreate image basic server
-k, --force-khanat : Force create/recreate image khanat server
-u, --update-data : generate a new patch (client & update server)
-g, --configure-khanat : Force configure khanat server
-n, --no-launch-khanat : Doesn't launch khanat server
-s, --stop-server : Stop server khanat
-c, --clean-container-khanat : Remove old server khanat (stopped)
-w, --clean-images-none : Remove images docker (with name 'none')
-i, --show-ip-khanat-server : show ip address for khanat server (launch under docker)
--option-docker-build=[STRING] : you can add option in "docker build"
--option-docker-run=[STRING] : you can add option in "docker run"
--khanat-ressources-dir=[DIR] : localization khanat-ressources
--khanat-client-data-dir=[DIR] : localization khanat-client-data
--opennel-code-dir=[DIR] : localization opennel-code
--pymanager-dir=[DIR] : localization pymanager
--start-khanat-with-screen : start with screen
--start-bash : start server khanat and launch bash
--start-with-manager : start khanat with manager (default)
--ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action]
--client-version=[INTEGER] : version client khanat (we need to communicate with our server)
--clear-terminal : clear terminal when script finished
--jobs=[INTEGER] : Number thread for path_gen
Example :
cd [root Khanat directory]
./server.sh
./server.sh -k
./server.sh --ssh
EOF
}
function msg_debug()
{
if [[ $DEBUG -ne 0 ]]
then
echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*"
fi
}
function msg_info()
{
echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*"
}
function msg_error()
{
echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2
}
#
# MAIN
#
#msg_info "START"
calldir="$(dirname $0)"
basedir=$(cd $calldir; pwd)
rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))"
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
dataclientdir="$(dirname ${rootdir})/khanat-client-data"
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
CONFIGUREAUTO="$CONFIGUREAUTO -d"
UPDATEAUTO="$UPDATEAUTO -d"
shift
;;
--ssh)
CONNECTSSHKHANAT=1
shift
;;
-r|--remove)
REMOVE=1
CONFIGUREKHANATSERVER=1
shift
;;
-c|--clean-container-khanat)
CLEANCONTAINERKHANAT=1
shift
;;
-s|--stop-server)
STOPKHANAT=1
shift
;;
-b|--force-basic)
BASICSERVER=1
shift
;;
-n|--no-launch-khanat)
LAUNCHKHANAT=0
shift
;;
-k|--force-khanat)
KHANATSERVER=1
shift
;;
-g|--configure-khanat)
CONFIGUREKHANATSERVER=1
shift
;;
-i|--show-ip-khanat-server)
SHOWIPKHANATSERVER=1
shift
;;
--start-khanat-with-screen)
METHODSTARTSERVER="--screen"
shift
;;
--start-bash)
METHODSTARTSERVER="--bash"
shift
;;
--start-with-manager)
METHODSTARTSERVER="--opennel-manager"
shift
;;
--client-version*)
KHANAT_CLIENT_VERSION="${1#*=}"
shift
;;
--khanat-ressources-dir=*)
KHANAT_RESSOURCES_DIR="${1#*=}"
shift
;;
--khanat-client-data-dir=*)
KHANAT_CLIENT_DATA_DIR="${1#*=}"
shift
;;
--opennel-code-dir=*)
OPENNEL_CODE_DIR="${1#*=}"
shift
;;
--pymanager-dir=*)
PYMANAGER_DIR="${1#*=}"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
;;
-u|--update-data)
UPDATEDATA=1
shift
;;
--option-docker-build=*)
DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}"
shift
;;
--option-docker-run=*)
DOCKERRUNOPT="$DOCKERRUNOPT ${1#*=}"
shift
;;
--clear-terminal)
CLEARTERMINAL=1
;;
--jobs=*)
CONFIGUREAUTO="$CONFIGUREAUTO $1"
UPDATEAUTO="$UPDATEAUTO $1"
shift
;;
*)
msg_error "[$(basename $0):$LINENO] options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "[$(basename $0):$LINENO] BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
then
msg_info "[$(basename $0):$LINENO] START"
fi
msg_debug "[$(basename $0):$LINENO] prg: $0"
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
msg_error "[$(basename $0):$LINENO] docker not installed"
exit 2
fi
case "$(uname -m)" in
x86_64)
;;
i686)
;;
*)
msg_error "[$(basename $0):$LINENO] Unknown archi : $(uname -m)"
exit 2
;;
esac
if [[ $REMOVE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] REMOVE DATA KHANAT : $ROOTDATAKHANAT"
if [[ -n "$ROOTDATAKHANAT" ]]
then
rm -rf ${ROOTDATAKHANAT}/* || exit 2
fi
fi
msg_debug "[$(basename $0):$LINENO] Create directory on host ($ROOTDATAKHANAT)"
mkdir -p $ROOTDATAKHANAT || exit 2
chmod g+s $ROOTDATAKHANAT
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
then
msg_debug "[$(basename $0):$LINENO] clean container"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
if [[ ${#listcontainer[@]} -eq 1 ]]
then
ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]})
fi
fi
if [[ $SHOWIPKHANATSERVER -ne 0 ]]
then
trap '' EXIT
echo "$ipaddress"
exit 0
fi
if [[ $CONNECTSSHKHANAT -ne 0 ]]
then
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END SSH"
exit 0
fi
if [[ $AUTODETEC -ne 0 ]]
then
msg_debug "[$(basename $0):$LINENO] Autodetect state"
if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]]
then
BASICSERVER=1
fi
if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]]
then
KHANATSERVER=1
fi
if [[ -z "$KHANAT_RESSOURCES_DIR" ]]
then
KHANAT_RESSOURCES_DIR="$(dirname $rootdir)/khanat-ressources"
fi
if [[ -z "$KHANAT_CLIENT_DATA_DIR" ]]
then
KHANAT_CLIENT_DATA_DIR="$(dirname $rootdir)/khanat-client-data"
fi
if [[ -z "$OPENNEL_CODE_DIR" ]]
then
OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code"
fi
if [[ -z "$PYMANAGER_DIR" ]]
then
PYMANAGER_DIR="$(dirname $rootdir)/opennel-pymanager"
fi
if [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]]
then
CONFIGUREKHANATSERVER=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] ressourcedir: $ressourcedir"
msg_debug "[$(basename $0):$LINENO] generate basic image: $BASICSERVER"
msg_debug "[$(basename $0):$LINENO] localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}"
msg_debug "[$(basename $0):$LINENO] localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}"
msg_debug "[$(basename $0):$LINENO] localization opennel-code-client : ${OPENNEL_CODE_DIR}"
msg_debug "[$(basename $0):$LINENO] localization opennel-pymanager : ${PYMANAGER_DIR}"
msg_debug "[$(basename $0):$LINENO] generate khanat image: $KHANATSERVER"
msg_debug "[$(basename $0):$LINENO] launch khanat: $LAUNCHKHANAT"
msg_debug "[$(basename $0):$LINENO] stop khanat: $STOPKHANAT"
msg_info "[$(basename $0):$LINENO] check khanat-ressources"
if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-ressources [${KHANAT_RESSOURCES_DIR}]"
cat << EOF
You need clone repo khanat-ressource.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git
EOF
exit 2
fi
msg_info "[$(basename $0):$LINENO] check khanat-client-data"
if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-client-data [${KHANAT_CLIENT_DATA_DIR}]"
cat << EOF
You need clone repo khanat-client-data.
cd $(dirname ${KHANAT_CLIENT_DATA_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git
EOF
exit 2
fi
if [[ ! -d ${OPENNEL_CODE_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory opennel-code [${OPENNEL_CODE_DIR}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
if [[ $STOPKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] STOP SERVER KHANAT"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT UP : ${listcontainer[@]}"
if [[ -n "$listcontainer" ]]
then
docker stop "$listcontainer" || exit 2
fi
fi
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN CONTAINER KHANAT"
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT EXITED : ${listcontainer[@]}"
if [[ -n "${listcontainer[@]}" ]]
then
docker rm --force "${listcontainer[@]}" || exit 2
fi
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "[$(basename $0):$LINENO] IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
if [[ $BASICSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] GENERATE DOCKER IMAGE BASIC SERVER"
#cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \
# --file "${basedir}/Dockerfile" || exit 2
cd $basedir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \
--file "${basedir}/Dockerfile" || exit 2
fi
if [[ $KHANATSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] GENERATE DOCKER IMAGE KHANAT SERVER"
cat << EOF > $rootdir/${ENVIFILE}
#!/bin/bash
# Temporary file, use only to send some information on build docker
export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION
export UIDGAMESERVER=$(id -u)
export GIDGAMESERVER=$(id -g)
export DIRCLIENT="$DIRCLIENT"
export PACKAGECLIENT="$PACKAGECLIENT"
EOF
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
--file "${basedir}/Dockerfile.khanat.container" || exit 2
fi
if [[ $CONFIGUREKHANATSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CONFIGURE KHANAT SERVER"
mkdir -p $DIRLOG || exit 2
mkdir -p $DIRDATABASE || exit 2
mkdir -p ${DIRLOCAL} || exit 2
msg_debug "[$(basename $0):$LINENO] command : cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh $CONFIGUREAUTO || exit 2
fi
if [[ $UPDATEDATA -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] UPDATE KHANAT SERVER"
mkdir -p $DIRLOG || exit 2
mkdir -p $DIRDATABASE || exit 2
mkdir -p ${DIRLOCAL} || exit 2
msg_debug "[$(basename $0):$LINENO] command: cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${rootdir}/${LOCALBUILDDIR}/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh $UPDATEAUTO"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh $UPDATEAUTO || exit 2
fi
if [[ $LAUNCHKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] START KHANAT SERVER"
cd $rootdir; docker run -it $DOCKERRUNOPT --hostname=khanat \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v $rootdir/build:/opt/build:ro \
-v ${OPENNEL_CODE_DIR}:/opt/ref/opennel-code:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
-v ${rootdir}/server/common/rootweb/:/home/gameserver/rootweb:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d
msg_info "[$(basename $0):$LINENO] CLEAR TERMINAL"
if [[ $CLEARTERMINAL -ne 0 ]]
then
clear
tput clear
fi
fi
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END"

View file

@ -0,0 +1,441 @@
#!/bin/bash
#
# Script to start khanat server
#
# 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/>.
declare -i IMAGE=1
declare -i BASICSERVER=0
declare -i KHANATSERVER=0
declare -i KHANATRESSOURCES=0
declare -i KHANATDATACLIENT=0
declare -i RYZOMRESSOURCES=0
declare -i LAUNCHKHANAT=1
declare -i DEBUG=0
declare -i AUTODETEC=1
declare -i STOPKHANAT=0
declare -i CLEANCONTAINERKHANAT=0
declare -i CONNECTSSHKHANAT=0
declare -i KHANAT_CLIENT_VERSION=1
declare -i SHOWIPKHANATSERVER=0
declare -i METHODSTARTSERVER=1
declare -i CLEANIMAGENONE=0
declare DOCKERBUILDOPT=""
declare IMAGEGENERICSERVER="opennel/server_generic_debian_buster_x86_64"
declare IMAGEKHANATSERVER="opennel/serverimage_debian_buster_x86_64"
declare LOCALBUILDDIR="build/opennel/builder_debian_buster_x86_64"
declare DIRCLIENT="Khanat_Linux64"
declare PACKAGECLIENT="smokey_linux64"
declare DIROUTPUT="output/extra"
usage()
{
cat << EOF
usage:$0 [options]
script to build under docker
Step:
1) generate tar with khanat-ressources
2) generate tar with ryzom-ressources
3) create image basic server
4) create image khanat server
5) launch khanat server
options:
-h, --help : Show this help
-d, --debug : Show debug message
-b, --force-basic : Force create/recreate image basic server
-t, --force-tar-ressources : Generate TAR.GZ for khanat-ressources (look directory ../khanat-ressources)
-q, --force-tar-client-data : Generate TAR.GZ for khanat-client-data (look directory ../khanat-client-data)
-z, --force-tar-ryzom-ressources : Generate TAR.GZ in data khanat-code
-k, --force-khanat : Force create/recreate image khanat server
-n, --no-launch-khanat : Doesn't launch khanat server
-s, --stop-server : Stop server khanat
-c, --clean-container-khanat : Remove old server khanat (stopped)
-w, --clean-images-none : Remove images docker (with name 'none')
-i, --show-ip-khanat-server : show ip address for khanat server (launch under docker)
--option-docker-build=[STRING] : you can add option in "docker build"
--opennel-code-dir=[DIR] : localization opennel-code
--start-khanat-with-screen : [default] start khanat with screen
--start-khanat-with-full-log : start server khanat and show full log
--start-khanat-with-watch-state : start server khanat and show state (loop)
--ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action]
--client-version=[INTEGER] : version client khanat (we need to communicate with our server)
Example :
cd [root Khanat directory]
./server.sh
./server.sh -k
./server.sh --ssh
EOF
}
function msg_debug()
{
if [[ $DEBUG -ne 0 ]]
then
echo "$(date "+%Y/%m/%d %H:%M:%S") DEBUG - $*"
fi
}
function msg_info()
{
echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $*"
}
function msg_error()
{
echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2
}
#
# MAIN
#
#msg_info "START"
calldir="$(dirname $0)"
basedir=$(cd $calldir; pwd)
rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))"
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
dataclientdir="$(dirname ${rootdir})/khanat-client-data"
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
shift
;;
--ssh)
CONNECTSSHKHANAT=1
shift
;;
-c|--clean-container-khanat)
CLEANCONTAINERKHANAT=1
shift
;;
-s|--stop-server)
STOPKHANAT=1
shift
;;
-b|--force-basic)
BASICSERVER=1
shift
;;
-n|--no-launch-khanat)
LAUNCHKHANAT=0
shift
;;
-t|--force-tar-ressources)
KHANATRESSOURCES=1
shift
;;
-q|--force-tar-client-data)
KHANATDATACLIENT=1
shift
;;
-z|--force-tar-ryzom-ressources)
RYZOMRESSOURCES=1
shift
;;
-k|--force-khanat)
KHANATSERVER=1
shift
;;
-i|--show-ip-khanat-server)
SHOWIPKHANATSERVER=1
shift
;;
--start-khanat-with-screen)
METHODSTARTSERVER=1
shift
;;
--start-khanat-with-full-log)
METHODSTARTSERVER=2
shift
;;
--start-khanat-with-watch-state)
METHODSTARTSERVER=3
shift
;;
--client-version*)
KHANAT_CLIENT_VERSION="${1#*=}"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
;;
--option-docker-build)
DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}"
shift
;;
--opennel-code-dir=*)
OPENNEL_CODE_DIR="${1#*=}"
shift
;;
*)
msg_error "options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
then
msg_info "[$(basename $0):$LINENO] START"
fi
msg_debug "[$(basename $0):$LINENO] prg: $0"
extradir="${rootdir}/${DIROUTPUT}"
mkdir -p ${extradir} || exit 2
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
msg_error "[$(basename $0):$LINENO] docker not installed"
exit 2
fi
case "$(uname -m)" in
x86_64)
;;
i686)
;;
*)
msg_error "[$(basename $0):$LINENO] Unknown archi : $(uname -m)"
exit 2
;;
esac
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
then
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
if [[ ${#listcontainer[@]} -eq 1 ]]
then
ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]})
fi
fi
if [[ $SHOWIPKHANATSERVER -ne 0 ]]
then
trap '' EXIT
echo "$ipaddress"
exit 0
fi
if [[ $CONNECTSSHKHANAT -ne 0 ]]
then
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END SSH"
exit 0
fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]]
then
BASICSERVER=1
fi
if [[ ! -f ${extradir}/khanat-ressources.tar.gz ]]
then
KHANATRESSOURCES=1
fi
if [[ ! -f ${extradir}/khanat-client-data.tar.gz ]]
then
KHANATDATACLIENT=1
fi
if [[ ! -f ${extradir}/ryzom-ressources.tar.gz ]]
then
RYZOMRESSOURCES=1
fi
if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]]
then
KHANATSERVER=1
fi
if [[ -z "$OPENNEL_CODE_DIR" ]]
then
OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code"
fi
if [[ -f ${extradir}/ryzomcore.tar.gz ]]
then
sumsrc=$(md5sum ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz | awk '{print $1}')
sumdst=$(md5sum ${extradir}/ryzomcore.tar.gz | awk '{print $1}')
else
sumsrc=1
sumdsr=2
fi
msg_debug "[$(basename $0):$LINENO] ryzomcore checksum src:$sumsrc dst:$sumdst"
if [[ "$sumsrc" != "$sumdst" ]]
then
msg_debug "[$(basename $0):$LINENO] copy ryzomcore"
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${extradir}/ryzomcore.tar.gz || exit 2
KHANATSERVER=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] ressourcedir: $ressourcedir"
msg_debug "[$(basename $0):$LINENO] generate basic image: $BASICSERVER"
msg_debug "[$(basename $0):$LINENO] generate tar khanat ressources: $KHANATRESSOURCES"
msg_debug "[$(basename $0):$LINENO] generate tar khanat data client: $KHANATDATACLIENT"
msg_debug "[$(basename $0):$LINENO] generate tar ryzom ressources: $RYZOMRESSOURCES"
msg_debug "[$(basename $0):$LINENO] generate khanat image: $KHANATSERVER"
msg_debug "[$(basename $0):$LINENO] launch khanat: $LAUNCHKHANAT"
msg_debug "[$(basename $0):$LINENO] stop khanat: $STOPKHANAT"
if [[ ! -d ${OPENNEL_CODE_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory opennel-code [${OPENNEL_CODE_DIR}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
if [[ $KHANATRESSOURCES -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with KHANAT Ressources"
if [[ ! -d ${ressourcedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-ressources directory ($ressourcedir)"
exit 2
fi
(cd $ressourcedir; tar --exclude='.git' -czf ${extradir}/khanat-ressources.tar.gz .) || exit 2
fi
if [[ $KHANATDATACLIENT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with KHANAT DATA CLIENT"
if [[ ! -d ${dataclientdir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-client-data directory ($dataclientdir)"
exit 2
fi
(cd $dataclientdir; tar --exclude='.git' -czf ${extradir}/khanat-client-data.tar.gz .) || exit 2
fi
if [[ $RYZOMRESSOURCES -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with RYZOM Ressources"
if [[ ! -d ${ressourcedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-ressources directory ($ressourcedir)"
exit 2
fi
cd ${OPENNEL_CODE_DIR}; tar czf ${extradir}/ryzom-ressources.tar.gz \
code/ryzom/server/shard.screen.rc \
code/ryzom/common/* \
code/ryzom/client/* \
code/ryzom/server/* \
code/ryzom/tools/scripts/linux/* \
code/web/* || exit 2
fi
if [[ $STOPKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] STOP SERVER KHANAT"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT UP : ${listcontainer[@]}"
if [[ -n "$listcontainer" ]]
then
docker stop "$listcontainer" || exit 2
fi
fi
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN CONTAINER KHANAT"
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT EXITED : ${listcontainer[@]}"
if [[ -n "${listcontainer[@]}" ]]
then
docker rm --force "${listcontainer[@]}" || exit 2
fi
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "[$(basename $0):$LINENO] IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
if [[ $BASICSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] GENERATE DOCKER IMAGE BASIC SERVER"
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \
--file "${basedir}/Dockerfile" || exit 2
fi
if [[ $KHANATSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] GENERATE DOCKER IMAGE KHANAT SERVER"
cat << EOF > $rootdir/todelete.sh
#!/bin/bash
# Temporary file, use only to send some information on build docker
export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION
export DIRCLIENT="$DIRCLIENT"
export PACKAGECLIENT="$PACKAGECLIENT"
EOF
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
--file "${basedir}/Dockerfile.khanat.image" || exit 2
rm $rootdir/todelete.sh
fi
if [[ $LAUNCHKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] START KHANAT SERVER"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
${IMAGEKHANATSERVER} /opt/serverimage_autostart.sh $METHODSTARTSERVER
clear
fi
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END"

View file

@ -54,9 +54,14 @@ command = ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserve
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
# buffer size (define value bufsize on subprocess.Popen, this buffer is use before read by manager)
bufsize = 100
activate_filter = yes
size_max_filter = 100
add_filter = "(^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))|(^(.*)(AES client module )(.*)( for service )(?P<Service_up>.*)( is up))|(^(.*)(AES client module )(.*)( of service )(?P<Service_down>.*)( is down)))"
del_filter = "(^(.*)(AES client module )(.*)( for service )(?P<Service_down>.*)( is up))|((^(.*)(AES client module )(.*)( of service )(?P<Service_up>.*)( is down)))"
##############################
# bms_master : backup_service
@ -67,7 +72,10 @@ command = ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserv
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
#[command:bms_pd_master]
# # command to launch the program
@ -88,7 +96,7 @@ path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 3000
# keep some data on array/dict state
activate_filter = yes
# activate_filter = yes
# size array/dict state
size_max_filter = 1000
# search regex to add state (python regex)
@ -98,8 +106,8 @@ size_max_filter = 1000
# del_filter = "^(.*)(disconnectPlayer).+[\s]+(?P<ActivePlayer>.*)[\s]+(is disconnected)"
# add_filter = "^(.*)(setActiveCharForPlayer)(.*)(: set active char )[\d]+( for )(?P<ActivePlayer>.*)"
# del_filter = "^(.*)(disconnectPlayer).+[\s]+(?P<ActivePlayer>.*)[\s]+(is disconnected)"
add_filter = "^((.*)(setActiveCharForPlayer).*(: set active char )[\d]+( for )(?P<ActivePlayer>.*)|(.*)(disconnectPlayer)(.+:.+<.+>){0,1}[\s]+(?P<InactivePlayer>.*)[\s]+(is disconnected))"
del_filter = "^((.*)(setActiveCharForPlayer).*(: set active char )[\d]+( for )(?P<InactivePlayer>.*)|(.*)(disconnectPlayer)(.+:.+<.+>){0,1}[\s]+(?P<ActivePlayer>.*)[\s]+(is disconnected))"
# add_filter = "^((.*)(setActiveCharForPlayer).*(: set active char )[\d]+( for )(?P<ActivePlayer>.*)|(.*)(disconnectPlayer)(.+:.+<.+>){0,1}[\s]+(?P<InactivePlayer>.*)[\s]+(is disconnected))"
# del_filter = "^((.*)(setActiveCharForPlayer).*(: set active char )[\d]+( for )(?P<InactivePlayer>.*)|(.*)(disconnectPlayer)(.+:.+<.+>){0,1}[\s]+(?P<ActivePlayer>.*)[\s]+(is disconnected))"
# autostart (when start OpenNelManager, launch this program)
autostart = yes
# restart after crash
@ -107,6 +115,8 @@ restart_after_crash = yes
# Delay after each restart (second)
restart_delay = 10
egs_filter = yes
activate_filter = yes
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# gpms : gpm_service
@ -117,7 +127,10 @@ command = ryzom_gpm_service -A/home/gameserver/khanat/server -C/home/gameserver/
# Path : where this program is launched
path = /home/gameserver/khanat/server/gpms
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# ios : input_output_service
@ -128,7 +141,10 @@ command = ryzom_ios_service -A/home/gameserver/khanat/server -C/home/gameserver/
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# rns : naming_service
@ -139,7 +155,10 @@ command = ryzom_naming_service -A/home/gameserver/khanat/server -C/home/gameserv
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# rws : welcome_service
@ -150,7 +169,10 @@ command = ryzom_welcome_service -A/home/gameserver/khanat/server -C/home/gameser
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# ts : tick_service
@ -161,7 +183,10 @@ command = ryzom_tick_service -A/home/gameserver/khanat/server -C/home/gameserver
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# ms : mirror_service
@ -172,7 +197,10 @@ command = ryzom_mirror_service -A/home/gameserver/khanat/server -C/home/gameserv
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# ais_newbyland : ai_service
@ -183,7 +211,10 @@ command = ryzom_ai_service -A/home/gameserver/khanat/server -C/home/gameserver/k
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# mfs : mail_forum_service
@ -194,7 +225,10 @@ command = ryzom_mail_forum_service -A/home/gameserver/khanat/server -C/home/game
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# su : shard_unifier_service
@ -205,7 +239,10 @@ command = ryzom_shard_unifier_service -A/home/gameserver/khanat/server -C/home/g
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# fes : frontend_service
@ -216,7 +253,10 @@ command = ryzom_frontend_service -A/home/gameserver/khanat/server -C/home/gamese
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# sbs : session_browser_server
@ -227,7 +267,10 @@ command = ryzom_session_browser_service -A/home/gameserver/khanat/server -C/home
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
##############################
# lgs : logger_service
@ -238,7 +281,10 @@ command = ryzom_logger_service -A/home/gameserver/khanat/server -C/home/gameserv
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"
# [command:mos]
# # command to launch the program
@ -246,7 +292,7 @@ logsize = 1000
# # Path : where this program is launched
# path = /home/gameserver/khanat/server/
# # size buffer log for each program launched (number line stdout)
# logsize = 1000
# logsize = 2000
# [command:pdss]
# # command to launch the program
@ -254,7 +300,7 @@ logsize = 1000
# # Path : where this program is launched
# path = /home/gameserver/khanat/server/
# # size buffer log for each program launched (number line stdout)
# logsize = 1000
# logsize = 2000
##############################
# ras : admin_service
@ -265,4 +311,8 @@ command = ryzom_admin_service --fulladminname=admin_service --shortadminname=AS
# Path : where this program is launched
path = /home/gameserver/khanat/server/
# size buffer log for each program launched (number line stdout)
logsize = 1000
logsize = 2000
activate_filter = yes
size_max_filter = 100
add_filter = "^((.*)(main )(.*)( : SERVICE: Service )(?P<Name>.*))"

View file

@ -0,0 +1,60 @@
# phpMyAdmin default Apache configuration
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options SymLinksIfOwnerMatch
DirectoryIndex index.php
<IfModule mod_php5.c>
<IfModule mod_mime.c>
AddType application/x-httpd-php .php
</IfModule>
<FilesMatch ".+\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
php_admin_value mbstring.func_overload 0
</IfModule>
<IfModule mod_php.c>
<IfModule mod_mime.c>
AddType application/x-httpd-php .php
</IfModule>
<FilesMatch ".+\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
php_value include_path .
php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/:/var/lib/phpmyadmin/:/usr/share/php/php-gettext/:/usr/share/php/php-gettext/:/usr/share/javascript/:/usr/share/php/tcpdf/:/usr/share/doc/phpmyadmin/:/usr/share/php/phpseclib/
php_admin_value mbstring.func_overload 0
</IfModule>
</Directory>
# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
<IfModule mod_authz_core.c>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin Setup"
AuthUserFile /etc/phpmyadmin/htpasswd.setup
</IfModule>
Require valid-user
</IfModule>
</Directory>
# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/templates>
Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
Require all denied
</Directory>

View file

@ -97,6 +97,7 @@ chown_gameserver '/home/gameserver/log/apache2/error.log' || exit 2
touch /home/gameserver/log/apache2/other_vhosts_access.log || exit 2
chown_gameserver '/home/gameserver/log/apache2/other_vhosts_access.log' || exit 2
#####################
# Start & Stop apache2
#####################

View file

@ -16,14 +16,56 @@
# 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/>.
/opt/ext/servercontainer_configure_link.sh || exit 2
/opt/ext/servercontainer_configure_mysql.sh || exit 2
declare DEBUG=""
usage()
{
cat << EOF
usage:$0 [options]
Configure Patch Server
options:
-h, --help : Show this help
-d, --debug : Show debug message
--jobs=[INTEGER] : Number thread for path_gen
EOF
}
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG="-d"
shift
;;
--client-dir=*)
DIRCLIENT="${1#*=}"
shift
;;
--jobs=*)
MULTITHREAD="$1"
shift
;;
*)
msg_error "[$(basename $0):$LINENO] options '$1' not recognize"
usage
exit 1
;;
esac
done
/opt/ext/servercontainer_configure_link.sh $DEBUG || exit 2
/opt/ext/servercontainer_configure_mysql.sh $DEBUG || exit 2
sync
/opt/ext/servercontainer_configure_apache.sh || exit 2
/opt/ext/servercontainer_configure_world.sh -d || exit 2
su -c '/opt/ext/servercontainer_configure_khanat.sh' gameserver || exit 2
su -c '/opt/ext/servercontainer_configure_patch.sh' gameserver || exit 2
su -c '/opt/ext/servercontainer_configure_launcher.sh' gameserver || exit 2
/opt/ext/servercontainer_configure_apache.sh $DEBUG || exit 2
/opt/ext/servercontainer_configure_world.sh $DEBUG || exit 2
su -c "/opt/ext/servercontainer_configure_khanat.sh $DEBUG" gameserver || exit 2
su -c "/opt/ext/servercontainer_configure_patch.sh $DEBUG $MULTITHREAD" gameserver || exit 2
su -c "/opt/ext/servercontainer_configure_launcher.sh $DEBUG" gameserver || exit 2
su -c 'touch /home/gameserver/khanat/step_configure.ok' gameserver || exit 2
sync
exit 0

View file

@ -76,7 +76,7 @@ source /home/gameserver/.bashrc
# opennel-pymanager
####################################
msg_info "[$(basename $0):$LINENO] install/update opennel-pymanager"
last_pymanager_package=$(ls /opt/ref/pymanager/pymanager*.whl | sort -r | head -n 1)
last_pymanager_package=$(ls /opt/ref/opennel_manager/opennel_manager*.whl | sort -r | head -n 1)
if [[ -n "$last_pymanager_package" ]]
then
pip3 show pymanager
@ -88,7 +88,9 @@ then
msg_info "[$(basename $0):$LINENO] install opennel-pymanager"
pip3 install $last_pymanager_package
else
msg_info "[$(basename $0):$LINENO] no package opennel-pymanager"
msg_error "[$(basename $0):$LINENO] no package opennel-pymanager"
find / -name "opennel_manager*.whl"
exit 3
fi
####################################

View file

@ -156,6 +156,8 @@ create_link '/home/gameserver/ext/khanat-ressources/shard/egs/game_event.txt' "$
create_link '/home/gameserver/ext/khanat-ressources/shard/egs/mission_queues.txt' "$KHANAT_PATH/server/data_shard" || exit 2
create_link '/home/gameserver/ext/khanat-ressources/shard/egs/named_items.txt' "$KHANAT_PATH/server/data_shard" || exit 2
# create_link '/home/gameserver/ext/ryzom-ressources/common/data_common/database.xml' /home/gameserver/ext/khanat-client-data/data/kh_shard/kh_server/ || exit 2
####################################
# Link configuration
####################################

View file

@ -91,14 +91,12 @@ msg_debug "Configure Log"
mkdir -p /home/gameserver/log/mysql || exit 2
chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
####################################
# Install Database
####################################
msg_debug "Install Database"
/usr/bin/mysql_install_db --user=gameserver --skip-name-resolve || exit 2
####################################
# Start Database
####################################

View file

@ -29,6 +29,8 @@ usage:$0 [options]
options:
-h, --help : Show this help
-d, --debug : Show debug message
--client-dir=[PATH] : Localization client data
--jobs=[INTEGER] : Number thread for path_gen
EOF
}
@ -54,6 +56,10 @@ do
DIRCLIENT="${1#*=}"
shift
;;
--jobs=*)
MULTITHREAD="$1"
shift
;;
*)
msg_error "[$(basename $0):$LINENO] options '$1' not recognize"
usage
@ -241,6 +247,10 @@ wait_all_job || exit 2
####################################
msg_info "[$(basename $0):$LINENO] Prepare Patch"
patch_gen --help | grep '\-\-jobs' 1>/dev/null || MULTITHREAD=""
tar cvzf /home/gameserver/khanat/patch_data.tar.gz $PATCH_CLIENT_SYSTEM
# TODO - if ryzom.xml exist what's command to update (replace patch_gen createNewProduct)
if [ -f $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml ]
then
@ -293,7 +303,7 @@ echo -n "$KHANAT_CLIENT_VERSION" > $PATCH_CLIENT_SYSTEM/patch_game/Lirria.versi
# prepare patch
####################################
msg_info "[$(basename $0):$LINENO] Generate patch"
cd $PATCH_CLIENT_SYSTEM; patch_gen updateProduct patch_game/ryzom.xml 2>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.err 1>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out || exit 2
cd $PATCH_CLIENT_SYSTEM; patch_gen $MULTITHREAD updateProduct patch_game/ryzom.xml 2>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.err 1>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out || exit 2
####################################
# Edit release note
@ -301,7 +311,15 @@ cd $PATCH_CLIENT_SYSTEM; patch_gen updateProduct patch_game/ryzom.xml 2>$KHANAT_
msg_info "[$(basename $0):$LINENO] Edit release note"
# Added files for version
REALVERSION=$(awk '{if($0 ~ /patch_gen_common.cpp 330 addVersion <Unknown> : Added files for version:/){print $12}}' $KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out)
REALVERSION=$(awk '{if($0 ~ /patch_gen_common.cpp [0-9]+ addVersion <Unknown> : Added files for version:/){print $12}}' $KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out)
if [[ -z "$REALVERSION" ]]
then
REALVERSION=$(awk '{if($0 ~ /patch_gen_common.cpp [0-9]+ addVersion [a-zA-Z0-9_]+ : Added files for version:/){print $12}}' $KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out | head -n 1)
fi
if [[ -z "$REALVERSION" ]]
then
msg_critical "[$(basename $0):$LINENO] IMPOSSIBLE TO DETECT CLIENT VERSION REAL"
fi
msg_info "[$(basename $0):$LINENO] CLIENT VERSION REAL: $REALVERSION"
cat << EOF > $PATCH_CLIENT_SYSTEM/patch_game/patch/index.php

View file

@ -251,6 +251,14 @@ mysql -u root -e "use nel;
UPDATE nel.permission SET AccessPrivilege = 'OPEN,DEV,RESTRICTED';
" || msg_critical "[$(basename $0):$LINENO] mysql - Create nel.permission"
####################################
# configure default nel.permission (use when we create account)
# OPEN (1), DEV (2), RESTRICTED (4) 1 + 2 + 4 = 7
####################################
msg_debug "[$(basename $0):$LINENO] Update default permission"
mysql -u root -e "use nel_ams_lib;
UPDATE settings SET Value = 7 WHERE settings.Setting = 'Domain_Auto_Add';
" || msg_critical "[$(basename $0):$LINENO] mysql - Update default permission"
####################################
# Stop Database & apache

View file

@ -80,11 +80,36 @@ sed -i -r 's/^LogLevel[[:space:]]+warn/LogLevel debug/g' /etc/apache2/apache2.co
# 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
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
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
####################################
# Configure 1st page

View file

@ -47,6 +47,7 @@ update_mysql_config()
sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' $1 || exit 2
sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' $1 || exit 2
sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' $1 || exit 2
sed -i -r 's/^\[mysqld\]/[mysqld]\nsql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"/g' $1 || exit 2
else
msg_debug "nothing for $1"
fi

View file

@ -207,6 +207,12 @@ elif [[ $METHOD_START -eq 2 ]]
then
msg_debug "start with OpenNelManager"
touch /home/gameserver/opennelmanager.flag
# Copy file (if original is link)
if [[ -L /home/gameserver/khanat/server/common.cfg ]]
then
mv /home/gameserver/khanat/server/common.cfg /home/gameserver/khanat/server/common.cfg.ref
cp /home/gameserver/khanat/server/common.cfg.ref /home/gameserver/khanat/server/common.cfg
fi
# Disable Color
grep -e '^StdDisplayerColor' /home/gameserver/khanat/server/common.cfg >/dev/null
if [[ $? -eq 0 ]]
@ -215,6 +221,15 @@ then
else
echo -en "\n// ---- Disable color\nStdDisplayerColor = 0;\n" >> /home/gameserver/khanat/server/common.cfg
fi
# Enable debug message
grep -e '^DisableNLDebug' /home/gameserver/khanat/server/common.cfg >/dev/null
if [[ $? -eq 0 ]]
then
sed -i 's/DisableNLDebug.*/DisableNLDebug = 0;/g' /home/gameserver/khanat/server/common.cfg
else
echo -en "\n// ---- Enable debug\nDisableNLDebug = 0;\n" >> /home/gameserver/khanat/server/common.cfg
fi
# Start OpenNelManager
create_default_file_for_opennel_manager
python3 -m pymanager.manager -c /home/gameserver/khanat/khaganat.cfg --log DEBUG --filelog /home/gameserver/log/khanat/OpenNelManager.log --launch-program &

View file

@ -27,6 +27,7 @@ usage:$0 [options]
options:
-h, --help : Show this help
-d, --debug : Show debug message
--jobs=[INTEGER] : Number thread for path_gen
EOF
}
@ -44,6 +45,10 @@ do
set_debug 1
shift
;;
--jobs=*)
MULTITHREAD="$1"
shift
;;
*)
msg_error "[$(basename $0):$LINENO] options '$1' not recognize"
usage
@ -57,7 +62,7 @@ done
#/opt/ext/servercontainer_configure_apache.sh || exit 2
#/opt/ext/servercontainer_configure_world.sh || exit 2
su -c "/opt/ext/servercontainer_configure_khanat.sh $OPTION" gameserver || msg_critical "[$(basename $0):$LINENO] Issue when configure khanat"
su -c "/opt/ext/servercontainer_configure_patch.sh $OPTION" gameserver || msg_critical "[$(basename $0):$LINENO] Issue when configure patch"
su -c "/opt/ext/servercontainer_configure_patch.sh $OPTION $MULTITHREAD" gameserver || msg_critical "[$(basename $0):$LINENO] Issue when configure patch"
su -c '/opt/ext/servercontainer_configure_launcher.sh' gameserver || exit 2
msg_info "[$(basename $0):$LINENO] => END"

View file

@ -20,10 +20,11 @@ FROM amd64/debian:9
MAINTAINER AleaJactaEst
ENV HOSTNAME basic_server
ENV DISPLAY :0
RUN apt-get update ; \
apt-get dist-upgrade -y ; \
DEBIAN_FRONTEND=noninteractive apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx openssh-server sudo net-tools lzma xdelta p7zip p7zip-full mysql-server apache2 php libapache2-mod-php php-mysql apache2-utils php-gd php-imagick rrdtool screen mcrypt php-mcrypt python3 phpmyadmin gdb valgrind electric-fence python3-pip python3-bcrypt python3-pip
DEBIAN_FRONTEND=noninteractive apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx openssh-server sudo net-tools lzma xdelta p7zip p7zip-full mysql-server apache2 php libapache2-mod-php php-mysql apache2-utils php-gd php-imagick rrdtool screen mcrypt php-mcrypt python3 phpmyadmin gdb valgrind electric-fence python3-pip python3-bcrypt python3-pip ddd libmariadbclient18

View file

@ -96,6 +96,7 @@ options:
--ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action]
--client-version=[INTEGER] : version client khanat (we need to communicate with our server)
--clear-terminal : clear terminal when script finished
--jobs=[INTEGER] : Number thread for path_gen
Example :
cd [root Khanat directory]
@ -236,6 +237,11 @@ do
--clear-terminal)
CLEARTERMINAL=1
;;
--jobs=*)
CONFIGUREAUTO="$CONFIGUREAUTO $1"
UPDATEAUTO="$UPDATEAUTO $1"
shift
;;
*)
msg_error "[$(basename $0):$LINENO] options '$1' not recognize"
usage
@ -479,7 +485,7 @@ then
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/pymanager:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh"
cd $rootdir; docker run -it --hostname=khanat \
@ -493,7 +499,7 @@ then
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/pymanager:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh $CONFIGUREAUTO || exit 2
fi
@ -508,14 +514,14 @@ then
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${rootdir}/${LOCALBUILDDIR}/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/pymanager:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh $UPDATEAUTO"
cd $rootdir; docker run -it --hostname=khanat \
@ -529,7 +535,7 @@ then
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/pymanager:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh $UPDATEAUTO || exit 2
fi
@ -549,6 +555,7 @@ then
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
-v ${rootdir}/${LOCALBUILDDIR}:/opt/ref/opennel_manager:ro \
-v $rootdir/build:/opt/build:ro \
-v ${OPENNEL_CODE_DIR}:/opt/ref/opennel-code:ro \
-v ${rootdir}/${DIRLOCAL}:/home/gameserver/.local:rw \