: Added files for version:/){print $12}}' $KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out)
+
+msg_info "CLIENT VERSION: $REALVERSION"
+cat << EOF > $PATCH_CLIENT_SYSTEM/patch_game/patch/index.php
+
+
+
+
+
+ New test data - Release $REALVERSION
+ An update will now be performed to your client(the /user directory to be exact).
+ Please help us test the deployment of our free MMORPG server!!
+
+
+EOF
+
+
+# TODO - Strange, we need update patch - to be check
+cat << EOF > $PATCH_CLIENT_SYSTEM/patch_game/patch/Lirria.version
+$REALVERSION $REALVERSION
+EOF
+
+####################################
+# Prepare client package
+####################################
+if [[ ! -f $HOME_CLIENT/smokey_linux64.tar.gz ]]
+then
+ msg_info "Prepare client package"
+ cp /usr/local/bin/khanat_client $HOME_PREPARE_CLIENT/. || exit 2
+ cp /home/gameserver/ext/ryzom-ressources/client/client_default.cfg $HOME_PREPARE_CLIENT/. || exit 2
+ sed -i -r 's/PatchWanted = 0;/PatchWanted = 1;/g' $HOME_PREPARE_CLIENT/client_default.cfg || exit 2
+
+ cp $PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_translate_{wk,fr,en}.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+ cp $KHANAT_HOME/ext/khanat-data-client/client/exedll_linux64/khanat.png $HOME_PREPARE_CLIENT/data/. || exit 2
+ # cp $PATCH_CLIENT_SYSTEM/dataserver/data/fonts.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+ cp $PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_interfaces.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+ cp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ryz_zzz_bazaar.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+ cp $KHANAT_HOME/ext/ryzom-ressources/client/cfg/* $HOME_PREPARE_CLIENT/cfg/. || exit 2
+
+ # TODO - we need search where are define some files
+ # .DS_Store : function ?
+ # khanat_install_desktop_menu.sh : script to install khanat on desktop
+ # khanat.desktop.in : config desktop for khanat
+ # khanat_install_desktop_menu.sh : script to uninstall khanat on desktop
+fi
+
+####################################
+# Generate client package
+####################################
+# Generate package
+#(cd $PATCH_HOME/..; 7z a smokey_linux64.7z $DIRCLIENT)
+if [[ ! -f $HOME_CLIENT/smokey_linux64.tar.gz ]]
+then
+ msg_info "Generate package"
+ (cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/smokey_linux64.tar.gz $DIRCLIENT)
+fi
+
+####################################
+# Create web page to present this package
+####################################
+msg_info "create index.html for client"
+cat << EOF > $HOME_CLIENT/index.html
+
+
+
+KHANAT CLIENT
+
+
+
+You can download khanat client - release $KHANAT_CLIENT_VERSION
+khanat client
+
+
+
+EOF
+
+####################################
+# End
+####################################
+msg_info "$(basename $0) => END"
+
diff --git a/dist/docker/server/debian/common/servercontainer_configure_world.sh b/dist/docker/server/debian/common/servercontainer_configure_world.sh
new file mode 100755
index 000000000..a66236f31
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_configure_world.sh
@@ -0,0 +1,279 @@
+#!/bin/bash
+#
+# Configure MySQL
+#
+# 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 .
+
+declare DEBUG=0
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ prepare mysql (create directory, update configuration)
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+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
+#####################
+source /opt/ext/servercontainer_function.sh
+msg_info "$(basename $0) => START"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ 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
+
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ msg_error "Missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+
+####################################
+# Start mysql & apache
+####################################
+msg_debug "Start mysql"
+# start/restart service mysql & apache
+sudo service mysql start || exit 2
+
+# Wait mysql start
+msg_debug "Check database is started"
+until /usr/bin/mysqladmin ping >/dev/null 2>&1
+do
+ echo -n "."
+ sleep 1
+done
+echo ""
+
+msg_debug "start apache"
+sudo service apache2 start || exit 2
+
+
+####################################
+# Create account
+####################################
+msg_debug "Create account"
+# Create account shard on MySQL
+mysql -u root -e "CREATE USER 'shard'@'localhost' IDENTIFIED BY '';" || exit 2
+mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'shard'@'localhost' WITH GRANT OPTION;" || exit 2
+
+
+####################################
+# launch web configuration for khanat
+####################################
+msg_debug "launch web configuration for khanat"
+curl 'http://localhost:40916/setup/install.php' \
+ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
+ -H 'Accept-Language: en-US' \
+ -H 'Connection: keep-alive' \
+ -H 'Cookie: PHPSESSID=9jr1ssig58929bp777nrj2fa92' \
+ -H 'DNT: 1' \
+ -H 'Host: localhost:40916' \
+ -H 'Referer: http://localhost:40916/setup/install.php' \
+ -H 'Upgrade-Insecure-Requests: 1' \
+ -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \
+ -H 'Content-Type: application/x-www-form-urlencoded' \
+ --data 'roleService=on'\
+'&roleSupport=on'\
+'&roleDomain=on'\
+'&privatePhpDirectory=..%2Fprivate_php%2F'\
+'&nelSetupPassword=admin'\
+'&nelSqlHostname=localhost'\
+'&nelSqlUsername=root'\
+'&nelSqlPassword='\
+'&nelDatabase=nel'\
+'&toolDatabase=nel_tool'\
+'&toolsAdminUsername=admin'\
+'&toolsAdminPassword=admin'\
+'&amsSqlHostname=localhost'\
+'&amsSqlUsername=root'\
+'&amsSqlPassword='\
+'&amsDatabase=nel_ams'\
+'&amsLibDatabase=nel_ams_lib'\
+'&amsAdminUsername=admin'\
+'&amsAdminPassword=admin'\
+'&nelDomainName=Lirria'\
+'&domainDatabase=ring_mini01'\
+'&submit=Configure' \
+ -o $KHANAT_HOME/log/configure/world_setup.html || exit 2
+
+chown_gameserver $KHANAT_HOME/log/configure/world_setup.html
+
+# Check account is create
+grep "Domain role successfully installed" $KHANAT_HOME/log/configure/world_setup.html >/dev/null || exit 2
+
+
+####################################
+# Get IP ADDRESS
+####################################
+msg_debug "Get IP ADDRESS"
+tmp=$(hostname -I)
+export addressip=${tmp//[[:blank:]]/}
+
+
+####################################
+## Configure Domain
+####################################
+msg_debug "Configure Domain"
+mysql -u root -e "use nel;
+INSERT INTO nel.domain (domain_id, domain_name, status, patch_version, backup_patch_url, patch_urls, login_address, session_manager_address, ring_db_name, web_host, web_host_php, description) VALUES ('12', 'Lirria', 'ds_open', '$KHANAT_CLIENT_VERSION', '$addressip:23001', '$addressip/patch', '$addressip:49998', '$addressip:49999', 'ring_mini01', '$addressip:30000', '$addressip:40916', NULL);" || exit 2
+
+
+####################################
+# Configure nel.shard
+####################################
+msg_debug "Configure nel.shard"
+mysql -u root -e "use nel;
+INSERT INTO nel.shard (ShardId, domain_id, WsAddr, NbPlayers, Name, Online, Version, FixedSessionId, State, MOTD) VALUES ('302', '12', '$addressip:', '0', 'Lirria shard', '0', '', '0', 'ds_open', '');" || exit 2
+
+####################################
+# Configure nel_tool.neltool_domains
+####################################
+msg_debug "Configure nel_tool.neltool_domains"
+mysql -u root -e "use nel;
+INSERT INTO nel_tool.neltool_domains (domain_id, domain_name, domain_as_host, domain_as_port, domain_rrd_path, domain_las_admin_path, domain_las_local_path, domain_application, domain_sql_string, domain_hd_check, domain_mfs_web, domain_cs_sql_string) VALUES ('12', 'Lirria', '$addressip', '46700', '/home/gameserver/khanat/server/save_shard/rrd_graphs', '', '', 'ryzom_open', '', '0', NULL, NULL);" || exit 2
+
+
+####################################
+# configure nel_tool.neltool_shards
+####################################
+msg_debug "Configure nel_tool.neltool_shards"
+mysql -u root -e "use nel;
+INSERT INTO nel_tool.neltool_shards (shard_id, shard_name, shard_as_id, shard_domain_id, shard_lang, shard_restart) VALUES ('302', 'open', 'open', '12', 'fr', '0');" || exit 2
+
+
+####################################
+# configure nel_tool.neltool_user_domains
+####################################
+msg_debug "Configure nel_tool.neltool_user_domains"
+mysql -u root -e "use nel;
+INSERT INTO nel_tool.neltool_user_domains (user_domain_id, user_domain_user_id, user_domain_domain_id) VALUES ('1', '1', '12');" || exit 2
+
+
+####################################
+# configure nel_tool.neltool_user_shards
+####################################
+msg_debug "Configure nel_tool.neltool_user_shards"
+mysql -u root -e "use nel;
+INSERT INTO nel_tool.neltool_user_shards (user_shard_id, user_shard_user_id, user_shard_shard_id, user_shard_domain_id) VALUES ('1', '1', '302', '12');" || exit 2
+
+
+####################################
+# configure ring_mini01.sessions
+####################################
+msg_debug "Configure ring_mini01.sessions"
+mysql -u root -e "use ring_mini01;
+INSERT INTO ring_mini01.sessions (session_id, session_type, title, owner, plan_date, start_date, description, orientation, level, rule_type, access_type, state, host_shard_id, subscription_slots, reserved_slots, free_slots, estimated_duration, final_duration, folder_id, lang, icone, anim_mode, race_filter, religion_filter, guild_filter, shard_filter, level_filter, subscription_closed, newcomer) VALUES ('302', 'st_mainland', '', '0', '2005-09-21 12:41:33.000000', '2005-08-31 00:00:00.000000', '', 'so_other', 'sl_a', 'rt_strict', 'at_private', 'ss_planned', '0', '0', '0', '0', 'et_short', '0', '0', '', '', 'am_dm', '', '', 'gf_only_my_guild', 'sf_shard00,sf_shard01,sf_shard02,sf_shard03,sf_shard04,sf_shard05,sf_shard06,sf_shard07,sf_shard08,sf_shard09,sf_shard10,sf_shard11,sf_shard12,sf_shard13,sf_shard14,sf_shard15,sf_shard16,sf_shard17,sf_shard18,sf_shard19,sf_shard20,sf_shard21,sf_shard22,sf_shard23,sf_shard24,sf_shard25,sf_shard26,sf_shard27,sf_shard28,sf_shard29,sf_shard30', 'lf_a,lf_b,lf_c,lf_d,lf_e,lf_f', '0', '0');" || exit 2
+
+
+####################################
+## Create one user 'tester' (password : tester)
+####################################
+msg_debug "Create one user"
+declare accountuser="tester"
+declare passworduser="tester"
+curl 'http://localhost:40916/ams/index.php' \
+ -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
+ -H 'Accept-Language: en-US' \
+ -H 'Connection: keep-alive' \
+ -H 'Cookie: PHPSESSID=lsoumn9f0ljgm3vo3hgjdead03' \
+ -H 'DNT: 1' \
+ -H 'Host: localhost:40916' \
+ -H 'Referer: http://localhost:40916/ams/index.php?page=register' \
+ -H 'Upgrade-Insecure-Requests: 1' \
+ -H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \
+ -H 'Content-Type: application/x-www-form-urlencoded' \
+ --data 'Username='"$accountuser"'&Password='"$passworduser"'&ConfirmPass=tester&Email=tester%40khaganat.net&TaC=on&function=add_user' \
+ -o $KHANAT_HOME/log/configure/world_account_tester.log || exit 2
+
+
+####################################
+# configure nel.permission
+####################################
+msg_debug "Create nel.permission"
+mysql -u root -e "use nel;
+UPDATE nel.permission SET AccessPrivilege = 'OPEN,DEV,RESTRICTED';
+" || exit 2
+
+
+####################################
+# Stop Database & apache
+####################################
+msg_debug "Stop Database & apache"
+# start/restart service mysql & apache
+sudo service apache2 stop || exit 2
+sudo service mysql stop || exit 2
+
+# Change right for file mysql
+# TODO - remove creation of this file
+chown_gameserver "$KHANAT_HOME/database/mysql_upgrade_info"
+
+####################################
+# End
+####################################
+msg_info "$(basename $0) => END"
+
diff --git a/dist/docker/server/debian/common/servercontainer_function.sh b/dist/docker/server/debian/common/servercontainer_function.sh
new file mode 100755
index 000000000..9d03df832
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_function.sh
@@ -0,0 +1,230 @@
+#!/bin/bash
+#
+# Function use in preparation & configuration
+#
+# 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 .
+
+######################
+# Write output
+######################
+declare -i DEBUG=0
+
+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
+}
+
+function set_debug()
+{
+ if [[ -n "$1" ]]
+ then
+ DEBUG=$1
+ else
+ DEBUG=0
+ fi
+}
+
+######################
+# function to change owner for gameserver
+######################
+function chown_gameserver()
+{
+ # gameserver:$(id -g -n gameserver)
+ chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
+}
+
+######################
+# function duplicate/link file
+######################
+function copy_link()
+{
+ if [[ -z "$1" ]]
+ then
+ msg_error "Missing 1st argument (source)"
+ exit 2
+ fi
+
+ if [ ! -f "$1" ]
+ then
+ msg_error "Missing source : '$1'"
+ exit 2
+ fi
+ mv "$1" "$1.old" || exit 2
+ cp "$1.old" "$1" || exit 2
+ chown_gameserver "$1" || exit 2
+}
+
+function create_link()
+{
+ if [[ -z "$1" ]]
+ then
+ msg_error "Missing 1st argument (source)"
+ exit 2
+ fi
+ if [[ -z "$2" ]]
+ then
+ msg_error "Missing 2nd argument (destination)"
+ exit 2
+ fi
+
+ filename_l=$(basename "$1")
+
+ msg_debug "create link $2/$filename_l"
+ if [ -e "$2/$filename_l" ]
+ then
+ rm "$2/$filename_l" || exit 2
+ elif [ -h "$2/$filename_l" ]
+ then
+ rm "$2/$filename_l" || exit 2
+ fi
+ if [[ (! -e "$1") && (! -h "$1") ]]
+ then
+ msg_error "Missing source : '$1'"
+ exit 2
+ fi
+ ln -s "$1" "$2/$filename_l" || exit 2
+ chown --no-dereference $UIDGAMESERVER:$GIDGAMESERVER "$2/$filename_l" || exit 2
+}
+
+function create_recursive_link()
+{
+ if [[ -z "$1" ]]
+ then
+ msg_error "Missing 1st argument (source)"
+ exit 2
+ fi
+ if [[ -z "$2" ]]
+ then
+ msg_error "Missing 2nd argument (destination)"
+ exit 2
+ fi
+
+ msg_debug "link $1 -> $2"
+ for file in $1/*
+ do
+ if [ -d "$file" ]
+ then
+ filename=$(basename "$file")
+ msg_debug "create dir $2/$filename"
+ if [ ! -f "$2/$filename" ]
+ then
+ mkdir -p "$2/$filename" || exit 2
+ fi
+ chown $UIDGAMESERVER:$GIDGAMESERVER "$2/$filename" || exit 2
+ create_recursive_link "$file" "$2/$filename" || exit 2
+ else
+ create_link "$file" "$2" || exit 2
+ fi
+ done
+}
+
+function create_link_2nd_level()
+{
+ # Function to create link
+ if [[ -z "$1" ]]
+ then
+ msg_error "Missing 1st argument (source)"
+ exit 2
+ fi
+ if [[ -z "$2" ]]
+ then
+ msg_error "Missing 2nd argument (destination)"
+ exit 2
+ fi
+
+ for file in $1
+ do
+ create_link "$file" "$2" || exit 2
+ done
+}
+
+function create_dir_gameserver()
+{
+ if [ -z "$1" ]
+ then
+ msg_error "Missing 1st argument (source)"
+ exit 2
+ fi
+ mkdir -p "$1" || exit 2
+ chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
+}
+
+function create_file_gameserver()
+{
+ if [ -z "$1" ]
+ then
+ msg_error "Missing 1st argument (source)"
+ exit 2
+ fi
+ touch "$1" || exit 2
+ chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
+}
+
+######################
+### Manage multi process
+######################
+declare -A JOBS
+declare -A COMMENTJOBS
+
+function init_job()
+{
+ unset JOBS
+ unset COMMENTJOBS
+}
+
+function launch_job()
+{
+ msg_debug "Launch job '$2'"
+ eval $1 &
+ JOBS[$!]="$1"
+ COMMENTJOBS[$!]="$2"
+}
+
+function wait_all_job()
+{
+ local cmd
+ local code=0
+ for pid in ${!JOBS[@]}
+ do
+ msg_debug "Wait job '${COMMENTJOBS[$pid]}' (pid:$pid) "
+ cmd=${JOBS[${pid}]}
+ wait ${pid}
+ JOBS[${pid}]=$?
+ if [[ ${JOBS[${pid}]} -ne 0 ]]
+ then
+ code=${JOBS[${pid}]}
+ msg_error "'${COMMENTJOBS[$pid]}' Exited with error [return code:$code, pid:${pid}, command:'${cmd}']"
+ fi
+ done
+ return $code
+}
+
+######################
+#
+######################
diff --git a/dist/docker/server/debian/common/servercontainer_init_apache.sh b/dist/docker/server/debian/common/servercontainer_init_apache.sh
new file mode 100755
index 000000000..7722550b1
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_init_apache.sh
@@ -0,0 +1,221 @@
+#!/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 .
+
+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
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride None
+ Require all granted
+ DirectoryIndex index.php
+ AddType text/html .php .phps
+ AddHandler application/x-httpd-php .php
+ AddHandler application/x-httpd-php-source .phps
+
+ ServerName lirria.khaganat.net
+
+ ServerAdmin webmaster@localhost
+ DocumentRoot /home/gameserver/khanat/khanatweb/public_php/
+
+ ErrorLog \${APACHE_LOG_DIR}/error.log
+ CustomLog \${APACHE_LOG_DIR}/access.log combined
+
+
+# Khanat Server Web
+
+
+ Options Indexes FollowSymLinks
+ AllowOverride None
+ Require all granted
+
+ ServerName lirria.khaganat.net
+
+ ServerAdmin admin@localhost
+ DocumentRoot /home/gameserver/khanat/khanatweb/public_php
+
+ ErrorLog \${APACHE_LOG_DIR}/error.log
+ CustomLog \${APACHE_LOG_DIR}/access.log combined
+
+
+# Patch Server
+
+ ServerName lirria.khaganat.net
+ DocumentRoot /home/gameserver/khanat/patch_service/patch_game/patch/
+
+
+ Options -Indexes
+ AllowOverride All
+ Require all granted
+
+
+EOF
+
+# Open port use by apache
+cat << EOF > /etc/apache2/ports.conf
+# If you just change the port or add more ports here, you will likely also
+# have to change the VirtualHost statement in
+# /etc/apache2/sites-enabled/000-default.conf
+
+Listen 80
+Listen 40916
+Listen 43435
+
+
+ Listen 443
+
+
+
+ Listen 443
+
+
+# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
+EOF
+
+
+# Activate php - strange beacause we have only index.php (without php code !)
+cat << EOF > /etc/apache2/conf-available/patch_service.conf
+Alias /patch /home/gameserver/khanat/patch_service/patch_game/patch
+
+ Options FollowSymLinks
+ DirectoryIndex index.php
+
+ Require all granted
+
+
+
+ AddType application/x-httpd-php .php
+
+
+ SetHandler application/x-httpd-php
+
+
+
+EOF
+
+# Configuration de la page client
+cat << EOF > /etc/apache2/conf-available/client_service.conf
+Alias /client /home/gameserver/khanat/client_service
+
+ Options FollowSymLinks
+ DirectoryIndex index.html
+
+ Require all granted
+
+
+ AddType application/tar .tar.gz
+
+
+ SetHandler application/tar
+
+
+
+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"
diff --git a/dist/docker/server/debian/common/init-basic.sh b/dist/docker/server/debian/common/servercontainer_init_configure_envi.sh
similarity index 55%
rename from dist/docker/server/debian/common/init-basic.sh
rename to dist/docker/server/debian/common/servercontainer_init_configure_envi.sh
index 723161fe7..afaecefd1 100755
--- a/dist/docker/server/debian/common/init-basic.sh
+++ b/dist/docker/server/debian/common/servercontainer_init_configure_envi.sh
@@ -1,5 +1,6 @@
#!/bin/bash
-# Install all package we need to prepare and install khanat server
+#
+# Configure environment
#
# Copyright (C) 2017 AleaJactaEst
#
@@ -16,52 +17,129 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-echo "Start Basic"
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ prepare mysql (create directory, update configuration)
-####################################
-# Install some package for server (apache, mysql, screen)
-####################################
-DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
-apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick rrdtool screen mcrypt php5-mcrypt
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+EOF
+}
-####################################
-# Initialize database
-####################################
+#####################
+# MAIN
+#####################
+source /opt/servercontainer_function.sh
+msg_info "$(basename $0) => START"
-/usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
-
-# Start the MySQL daemon in the background.
-/usr/sbin/mysqld &
-mysql_pid=$!
-
-# Wait mysql start
-until /usr/bin/mysqladmin ping >/dev/null 2>&1
+while test $# -gt 0
do
- echo -n "."
- sleep 1
+ 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
-# Initialize password root (to empty)
-/usr/bin/mysqladmin -u root password '' || exit 2
+msg_info "configure shard.sh"
-# Adding phpmyadmin
-DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
+####################################
+# configure shard.sh
+####################################
+cat << EOF > /opt/shard.sh
+# bashrc: executed by bash(1) for non-login shells.
-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
+# You may uncomment the following lines if you want 'ls' to be colorized:
+export SHELL=/bin/bash
+export LS_OPTIONS='--color=auto'
+eval "\`dircolors\`"
+alias ls='ls \$LS_OPTIONS'
+alias ll='ls \$LS_OPTIONS -l'
+alias l='ls \$LS_OPTIONS -lA'
+
+# Some more alias to avoid making mistakes:
+# alias rm='rm -i'
+# alias cp='cp -i'
+# alias mv='mv -i'
+
+# Autocompletion
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
+
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin:/usr/local/sbin
+export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service
+
+export DIRCLIENT="Khanat_Linux64"
+export PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT"
+export CLIENT_DIR="khanat/client_service"
+export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR"
+export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR"
+EOF
-# Stop MySQL
-/usr/bin/mysqladmin shutdown
+####################################
+# Initialize bashrc gameserver
+####################################
+msg_info "configure bashrc"
+cat << EOF > /home/gameserver/.bashrc
+# bashrc: executed by bash(1) for non-login shells.
-# Wait MySQL stop
-wait $mysql_pid
+# You may uncomment the following lines if you want 'ls' to be colorized:
+export SHELL=/bin/bash
+export LS_OPTIONS='--color=auto'
+eval "\`dircolors\`"
+alias ls='ls \$LS_OPTIONS'
+alias ll='ls \$LS_OPTIONS -l'
+alias l='ls \$LS_OPTIONS -lA'
+
+# Some more alias to avoid making mistakes:
+# alias rm='rm -i'
+# alias cp='cp -i'
+# alias mv='mv -i'
+
+# Autocompletion
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
+
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin
+export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service
+
+export DIRCLIENT="Khanat_Linux64"
+export PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT"
+export CLIENT_DIR="khanat/client_service"
+export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR"
+export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR"
+
+EOF
+chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc
+
+
+# load environment
+source /home/gameserver/.bashrc
####################################
# Initialize bashrc (for root)
####################################
+msg_debug "Configure bashrc (for root)"
cat << EOF > /root/.bashrc
# bashrc: executed by bash(1) for non-login shells.
@@ -84,37 +162,12 @@ if [ -f /etc/bash_completion ]; then
fi
EOF
-####################################
-# Initialize bashrc (for gameserver)
-####################################
-cat << EOF > /home/gameserver/.bashrc
-# bashrc: executed by bash(1) for non-login shells.
-
-# You may uncomment the following lines if you want 'ls' to be colorized:
-export SHELL=/bin/bash
-export LS_OPTIONS='--color=auto'
-eval "\`dircolors\`"
-alias ls='ls \$LS_OPTIONS'
-alias ll='ls \$LS_OPTIONS -l'
-alias l='ls \$LS_OPTIONS -lA'
-
-# Some more alias to avoid making mistakes:
-# alias rm='rm -i'
-# alias cp='cp -i'
-# alias mv='mv -i'
-
-# Autocompletion
-if [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
-fi
-EOF
-chown gameserver:gameserver /home/gameserver/.bashrc
-
####################################
# Adding sudo command
####################################
# Update sudo rule (you can execute all command as root)
+msg_debug "Configure sudo"
cat << EOF > /etc/sudoers.d/gameserver
# User privilege specification
gameserver ALL=NOPASSWD: ALL
@@ -126,6 +179,7 @@ EOF
# Message see when connect on ssh
# Before login
+msg_debug "Configure message login"
cat << EOF > /etc/issue.net
*********************
* KHANAT SERVER DEV *
@@ -137,6 +191,7 @@ password khanat
EOF
# After Login
+msg_debug "Configure banner"
cat << EOF > /etc/motd
***************************************************
connect to root use gameserver account and launch sudo command
@@ -152,9 +207,14 @@ log khanat server : /home/gameserver/khanat/server/log/log.log
EOF
# Activate banner
+msg_debug "Activate banner"
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
+
+# Initialize ssh
+/etc/init.d/ssh restart
+
####################################
# End
####################################
-echo "End Basic"
+msg_info "$(basename $0) => END"
diff --git a/dist/docker/server/debian/common/servercontainer_init_create_account.sh b/dist/docker/server/debian/common/servercontainer_init_create_account.sh
new file mode 100755
index 000000000..cf894619a
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_init_create_account.sh
@@ -0,0 +1,82 @@
+#!/bin/bash
+# Create account gameserver
+#
+# 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ create account gameserver
+
+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 account gameserver
+####################################
+msg_debug "Create gameserver account (shared with host)"
+groupadd --gid $GIDGAMESERVER gameserver || echo "group id already exist"
+useradd --uid $UIDGAMESERVER --gid $GIDGAMESERVER -G sudo -c /home -d /home/gameserver -c "Khanat account GAME" -m -p '$6$nxHX/3u.$azS0.eldpfKqxqOLDjgZj8.hPOLC64arXDTUVX0fs7RZvRBX/pNqPzDR89ccP5XkEE/daOyaD3wVtDGDUND5b/' -s /bin/bash gameserver
+msg_debug "group : $(id -g -n gameserver)"
+
+create_dir_gameserver '/home/gameserver/ext'
+create_dir_gameserver '/home/gameserver/khanat'
+
+####################################
+# End
+####################################
+msg_info "$(basename $0) => END"
diff --git a/dist/docker/server/debian/common/servercontainer_init_mysql.sh b/dist/docker/server/debian/common/servercontainer_init_mysql.sh
new file mode 100755
index 000000000..fd32db817
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_init_mysql.sh
@@ -0,0 +1,90 @@
+#!/bin/bash
+# Prepare/Configure MySQL
+#
+# 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 .
+
+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
+
+msg_debug "Create database for account gameserver"
+# Create database on gameserver account (and change directory database)
+sed -i -r 's/^user[[:space:]]+=[[:space:]]+(.*)/user = gameserver/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^datadir[[:space:]]+=[[:space:]]+(.*)/datadir = \/home\/gameserver\/database/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^log_error[[:space:]]+=[[:space:]]+(.*)/log_error = \/home\/gameserver\/log\/mysql\/error\.log/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^(#*)general_log_file[[:space:]]+=(.*)/general_log_file = \/home\/gameserver\/log\/mysql\/mysql\.log/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^(#*)general_log[[:space:]]+=(.*)/general_log = 1/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^(#*)slow_query_log_file[[:space:]]+=(.*)/slow_query_log_file = \/home\/gameserver\/log\/mysql\/mysql-slow\.log/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' /etc/mysql/my.cnf || exit 2
+sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' /etc/mysql/my.cnf || exit 2
+
+mkdir -p /home/gameserver/database/ || exit 2
+chown gameserver:$(id -g -n gameserver) /home/gameserver/database/ || exit 2
+
+mkdir -p /home/gameserver/log/mysql || exit 2
+chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
+
+chown gameserver:$(id -g -n gameserver) /var/run/mysqld/ || exit 2
+
+####################################
+# End
+####################################
+msg_info "$(basename $0) => END"
diff --git a/dist/docker/server/debian/common/servercontainer_init_package.sh b/dist/docker/server/debian/common/servercontainer_init_package.sh
new file mode 100755
index 000000000..674eed637
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_init_package.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+#
+# Install binary and data
+#
+# 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 .
+
+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
+
+# install new package
+cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || exit 2
+# Install data ref (web server, ...)
+cd /opt; tar xzf khanat-ref-ressources.tar.gz || exit 2
+
+####################################
+# End
+####################################
+msg_info "$(basename $0) => END"
+
diff --git a/dist/docker/server/debian/common/servercontainer_launch_auto.sh b/dist/docker/server/debian/common/servercontainer_launch_auto.sh
new file mode 100755
index 000000000..68ce70d84
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_launch_auto.sh
@@ -0,0 +1,267 @@
+#!/bin/bash
+#
+# Prepare and launch server khanat
+#
+# 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ Prepare and launch server khanat
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+ --start-khanat-with-screen : start with screen
+ --show-khanat-log : Show khanat log (after start)
+ --show-all-log : Show all log (after start) [apache, mysql, khanat]
+ --show-status-nagios : show status (ater start)
+ --show-status : show status (ater start)
+ --bash-after-start : command bash after start
+EOF
+}
+
+status_program()
+{
+ pid=$(cat /home/gameserver/khanat/server/$1/$1.pid)
+ ps -p $pid >/dev/null
+ if [[ $? -eq 0 ]]
+ then
+ pidstate="ok"
+ else
+ pidstate="ko"
+ fi
+ state=$(cat /home/gameserver/khanat/server/$1/$1.state)
+ echo "$1 $2 [$state] pid:$pid => $pidstate"
+}
+
+status_all()
+{
+ # aes : admin_executor_service.log
+ status_program 'aes' 'ryzom_admin_service'
+
+ # bms_master : backup_service.log
+ status_program 'bms_master' 'ryzom_backup_service'
+
+ # bms_pd_master
+ # status_program 'bms_pd_master' 'ryzom_backup_service'
+
+ # egs : entities_game_service.log
+ status_program 'egs' 'ryzom_entities_game_service'
+
+ # gpms : gpm_service.log
+ status_program 'gpms' 'ryzom_gpm_service'
+
+ # ios : input_output_service.log
+ status_program 'ios' 'ryzom_ios_service'
+
+ # rns : naming_service.log
+ status_program 'rns' 'ryzom_naming_service'
+
+ # rws : welcome_service.log
+ status_program 'rws' 'ryzom_welcome_service'
+
+ # ts : tick_service.log
+ status_program 'ts' 'ryzom_tick_service'
+
+ # ms : mirror_service.log
+ status_program 'ms' 'ryzom_mirror_service'
+
+ # ais_newbyland : ai_service.log
+ status_program 'ais_newbyland' 'ryzom_ai_service'
+
+ # mfs : mail_forum_service.log
+ status_program 'mfs' 'ryzom_mail_forum_service'
+
+ # su : shard_unifier_service.log
+ status_program 'su' 'ryzom_shard_unifier_service'
+
+ # fes : frontend_service.log
+ status_program 'fes' 'ryzom_frontend_service'
+
+ # sbs : session_browser_server.log
+ status_program 'sbs' 'ryzom_session_browser_service'
+
+ # lgs : logger_service.log
+ status_program 'lgs' 'ryzom_logger_service'
+
+ # mos
+ # status_program 'mos' 'ryzom_monitor_service'
+
+ # pdss
+ #status_program 'pdss' 'ryzom_pd_support_service'
+
+ # ras : admin_service.log
+ status_program 'ras' 'ryzom_admin_service'
+}
+
+#####################
+# MAIN
+#####################
+source /opt/ext/servercontainer_function.sh
+msg_info "START : $(basename $0)"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ set_debug 1
+ shift
+ ;;
+ --start-khanat-with-screen)
+ METHOD_START=0
+ shift
+ ;;
+ --show-khanat-log)
+ METHOD_START=1
+ shift
+ ;;
+ --show-all-log)
+ METHOD_START=3
+ shift
+ ;;
+ --show-status-nagios)
+ METHOD_START=2
+ shift
+ ;;
+ --show-status)
+ METHOD_START=4
+ shift
+ ;;
+ --bash-after-start)
+ METHOD_START=5
+ 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
+
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+
+#####################
+# Start mysql, apache & ssh
+#####################
+msg_debug "Start mysql, apache & ssh"
+sudo /etc/init.d/mysql restart
+sudo /etc/init.d/apache2 restart
+sudo /etc/init.d/ssh restart
+
+
+#####################
+# Update configuration with new IP
+#####################
+msg_debug "Update configuration with new IP"
+tmp=$(hostname -I)
+export addressip=${tmp//[[:blank:]]/}
+sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
+
+
+#####################
+# Reconfigure database
+#####################
+msg_debug "Reconfigure database"
+## Configure Domain
+mysql -u root -e "use nel;
+UPDATE nel.domain
+SET backup_patch_url = '$addressip:23001'
+, patch_urls = '$addressip/patch'
+, login_address = '$addressip:49998'
+, session_manager_address = '$addressip:49999'
+, web_host = '$addressip:30000'
+, web_host_php = '$addressip:40916'
+WHERE domain_id = 12;" || exit 2
+
+# Configure nel.shard
+mysql -u root -e "use nel;
+UPDATE nel.shard
+SET WsAddr = '$addressip:'
+WHERE ShardId = 302;" || exit 2
+
+# Configure nel_tool.neltool_domains
+mysql -u root -e "use nel;
+UPDATE nel_tool.neltool_domains
+SET domain_as_host = '$addressip'
+WHERE domain_id = 12;" || exit 2
+
+
+#####################
+# Start khanat
+#####################
+msg_debug "Start khanat"
+if [[ $METHOD_START -eq 0 ]]
+then
+ source /home/gameserver/.bashrc; export RYZOM_PATH=$KHANAT_PATH; echo ".$RYZOM_PATH."; $KHANAT_HOME/khanat/tools/scripts/linux/shard start
+elif [[ $METHOD_START -eq 1 ]]
+then
+ su -c /opt/ext/servercontainer_launch_service.sh gameserver
+ sleep 10
+ tail -n+0 -f /home/gameserver/log/khanat/log.log
+elif [[ $METHOD_START -eq 2 ]]
+then
+ su -c /opt/ext/servercontainer_launch_service.sh gameserver
+ sleep 10
+ watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
+elif [[ $METHOD_START -eq 3 ]]
+then
+ su -c /opt/ext/servercontainer_launch_service.sh gameserver
+ sleep 10
+ tail -n+0 -f /home/gameserver/log/apache2/* /home/gameserver/log/mysql/* /home/gameserver/log/khanat/*
+elif [[ $METHOD_START -eq 4 ]]
+then
+ su -c /opt/ext/servercontainer_launch_service.sh gameserver
+ sleep 10
+ watch /opt/ext/servercontainer_launch_status.sh --no-color
+elif [[ $METHOD_START -eq 5 ]]
+then
+ #su -c /opt/ext/servercontainer_launch_service.sh gameserver
+ #sleep 10
+ bash
+else
+ msg_error 'Bad option'
+ exit 2
+fi
+
+
+######################
+#
+######################
diff --git a/dist/docker/server/debian/common/servercontainer_launch_service.sh b/dist/docker/server/debian/common/servercontainer_launch_service.sh
new file mode 100755
index 000000000..dd6d91367
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_launch_service.sh
@@ -0,0 +1,168 @@
+#!/bin/bash
+#
+# Script to launch khaganat
+# (see shard.screen.rc)
+#
+# 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ Script to launch khaganat
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+EOF
+}
+
+function start_stop()
+{
+ nameservice=$1
+ printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+ chown_gameserver /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+ nohup $2
+ printf STOPPED > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+}
+
+function launch_service()
+{
+ nameservice=$1
+
+ create_dir_gameserver "/home/gameserver/khanat/server/${nameservice}"
+ create_file_gameserver "/home/gameserver/khanat/server/$1/$1.pid"
+ create_file_gameserver "/home/gameserver/log/khanat/$nameservice.out"
+ create_file_gameserver "/home/gameserver/log/khanat/$nameservice.err"
+
+ start_stop "$1" "$2" 1>/home/gameserver/log/khanat/$nameservice.out 2>/home/gameserver/log/khanat/$nameservice.err &
+ echo "$!" > /home/gameserver/khanat/server/$1/$1.pid
+ #nohup $2 1>/dev/null 2>&1 &
+ #echo "$!" > /home/gameserver/khanat/server/$1.pid
+ #printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+}
+
+#####################
+# MAIN
+#####################
+source /opt/ext/servercontainer_function.sh
+msg_info "START : $(basename $0)"
+
+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
+
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+
+####################################
+# Load Environment
+####################################
+create_dir_gameserver '/home/gameserver/log/khanat'
+cd /home/gameserver/log/khanat
+
+# aes : admin_executor_service.log
+launch_service 'aes' 'ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --fulladminname=admin_executor_service --shortadminname=AES'
+
+# bms_master : backup_service.log
+launch_service 'bms_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -P49990'
+
+# bms_pd_master
+# launch_service 'bms_pd_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -P49992'
+
+# egs : entities_game_service.log
+launch_service 'egs' 'ryzom_entities_game_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# gpms : gpm_service.log
+launch_service 'gpms' 'ryzom_gpm_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# ios : input_output_service.log
+launch_service 'ios' 'ryzom_ios_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# rns : naming_service.log
+launch_service 'rns' 'ryzom_naming_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# rws : welcome_service.log
+launch_service 'rws' 'ryzom_welcome_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# ts : tick_service.log
+launch_service 'ts' 'ryzom_tick_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# ms : mirror_service.log
+launch_service 'ms' 'ryzom_mirror_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# ais_newbyland : ai_service.log
+launch_service 'ais_newbyland' 'ryzom_ai_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -mCommon:Newbieland:Post'
+
+# mfs : mail_forum_service.log
+launch_service 'mfs' 'ryzom_mail_forum_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# su : shard_unifier_service.log
+launch_service 'su' 'ryzom_shard_unifier_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# fes : frontend_service.log
+launch_service 'fes' 'ryzom_frontend_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# sbs : session_browser_server.log
+launch_service 'sbs' 'ryzom_session_browser_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# lgs : logger_service.log
+launch_service 'lgs' 'ryzom_logger_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# mos
+# launch_service 'mos' 'ryzom_monitor_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# pdss
+#launch_service 'pdss' 'ryzom_pd_support_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+# ras : admin_service.log
+launch_service 'ras' 'ryzom_admin_service --fulladminname=admin_service --shortadminname=AS -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
+
+
+######################
+#
+######################
diff --git a/dist/docker/server/debian/common/servercontainer_launch_status.sh b/dist/docker/server/debian/common/servercontainer_launch_status.sh
new file mode 100755
index 000000000..aa6ae0624
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_launch_status.sh
@@ -0,0 +1,175 @@
+#!/bin/bash
+#
+# Script to get status all process khanat
+#
+# 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 .
+
+declare NOCOLOR=0
+declare RED=""
+declare GREEN=""
+declare NORMAL=""
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ Script to launch khaganat
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+ -n, --no-color : disable color
+EOF
+}
+
+status_program()
+{
+ name=$1
+ printf "%15s %-30s" "$1" "$2"
+ color=""
+ color2=""
+
+ pid=$(cat /home/gameserver/khanat/server/$1/$1.pid 2>/dev/null)
+ if [[ -n "$pid" ]]
+ then
+ ps -p $pid >/dev/null
+ if [[ $? -eq 0 ]]
+ then
+ pidstate=" ok "
+ color=$GREEN
+ else
+ pidstate="*ko*"
+ color=$RED
+ fi
+ else
+ pidstate="*ko*"
+ color=$RED
+ fi
+ printf " pid:%-8s %4s" "$pid" "${color}${pidstate}${NORMAL}"
+
+ state=$(cat /home/gameserver/khanat/server/$1/$1.state 2>/dev/null)
+ if [[ -n "$state" ]]
+ then
+ if [[ "$state" == "RUNNING" ]]
+ then
+ color2=$GREEN
+ else
+ color2=$RED
+ fi
+ else
+ state="NOT STARTED"
+ color2=$RED
+ fi
+ printf " %s\n" "${color2}[${state}]${NORMAL}"
+}
+
+status_all()
+{
+ # aes : admin_executor_service.log
+ status_program 'aes' 'ryzom_admin_service'
+
+ # bms_master : backup_service.log
+ status_program 'bms_master' 'ryzom_backup_service'
+
+ # bms_pd_master
+ # status_program 'bms_pd_master' 'ryzom_backup_service'
+
+ # egs : entities_game_service.log
+ status_program 'egs' 'ryzom_entities_game_service'
+
+ # gpms : gpm_service.log
+ status_program 'gpms' 'ryzom_gpm_service'
+
+ # ios : input_output_service.log
+ status_program 'ios' 'ryzom_ios_service'
+
+ # rns : naming_service.log
+ status_program 'rns' 'ryzom_naming_service'
+
+ # rws : welcome_service.log
+ status_program 'rws' 'ryzom_welcome_service'
+
+ # ts : tick_service.log
+ status_program 'ts' 'ryzom_tick_service'
+
+ # ms : mirror_service.log
+ status_program 'ms' 'ryzom_mirror_service'
+
+ # ais_newbyland : ai_service.log
+ status_program 'ais_newbyland' 'ryzom_ai_service'
+
+ # mfs : mail_forum_service.log
+ status_program 'mfs' 'ryzom_mail_forum_service'
+
+ # su : shard_unifier_service.log
+ status_program 'su' 'ryzom_shard_unifier_service'
+
+ # fes : frontend_service.log
+ status_program 'fes' 'ryzom_frontend_service'
+
+ # sbs : session_browser_server.log
+ status_program 'sbs' 'ryzom_session_browser_service'
+
+ # lgs : logger_service.log
+ status_program 'lgs' 'ryzom_logger_service'
+
+ # mos
+ # status_program 'mos' 'ryzom_monitor_service'
+
+ # pdss
+ #status_program 'pdss' 'ryzom_pd_support_service'
+
+ # ras : admin_service.log
+ status_program 'ras' 'ryzom_admin_service'
+}
+
+#####################
+# MAIN
+#####################
+source /opt/ext/servercontainer_function.sh
+msg_info "START : $(basename $0)"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ set_debug 1
+ shift
+ ;;
+ -n|--no-color)
+ NOCOLOR=1
+ shift
+ ;;
+ *)
+ msg_error "options '$1' not recoginze"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+if [[ $NOCOLOR -eq 0 ]]
+then
+ RED=$(tput setaf 1)
+ GREEN=$(tput setaf 2)
+ NORMAL=$(tput sgr0)
+fi
+status_all
+
diff --git a/dist/docker/server/debian/common/servercontainer_update_auto.sh b/dist/docker/server/debian/common/servercontainer_update_auto.sh
new file mode 100755
index 000000000..40cbf0001
--- /dev/null
+++ b/dist/docker/server/debian/common/servercontainer_update_auto.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Script to update 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 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 .
+
+/opt/ext/servercontainer_configure_link.sh || exit 2
+#/opt/ext/servercontainer_configure_mysql.sh || exit 2
+#/opt/ext/servercontainer_configure_apache.sh || exit 2
+#/opt/ext/servercontainer_configure_world.sh || exit 2
+su -c '/opt/ext/servercontainer_configure_khanat.sh' gameserver || exit 2
+su -c '/opt/ext/servercontainer_configure_patch.sh -d' gameserver || exit 2
+
+exit 0
+
diff --git a/dist/docker/server/debian/common/autostart.sh b/dist/docker/server/debian/common/serverimage_autostart.sh
similarity index 90%
rename from dist/docker/server/debian/common/autostart.sh
rename to dist/docker/server/debian/common/serverimage_autostart.sh
index 579198240..9efcb79b3 100755
--- a/dist/docker/server/debian/common/autostart.sh
+++ b/dist/docker/server/debian/common/serverimage_autostart.sh
@@ -28,7 +28,7 @@ tmp=$(hostname -I)
export addressip=${tmp//[[:blank:]]/}
sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
-/opt/prepare_start_server.sh || exit 2
+/opt/serverimage_prepare_start_server.sh || exit 2
if [[ $METHOD_START -eq 1 ]]
then
@@ -36,11 +36,11 @@ then
/home/gameserver/khanat/tools/scripts/linux/shard start
elif [[ $METHOD_START -eq 2 ]]
then
- bash /opt/launch_services.sh
+ bash /opt/serverimage_launch_services.sh
sleep 10
tail -n+0 -f /home/gameserver/khanat/server/log/log.log
else
- bash /opt/launch_services.sh
+ bash /opt/serverimage_launch_services.sh
sleep 10
watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
fi
diff --git a/dist/docker/server/debian/common/configure_apache.sh b/dist/docker/server/debian/common/serverimage_configure_apache.sh
similarity index 100%
rename from dist/docker/server/debian/common/configure_apache.sh
rename to dist/docker/server/debian/common/serverimage_configure_apache.sh
diff --git a/dist/docker/server/debian/common/configure_database.sh b/dist/docker/server/debian/common/serverimage_configure_database.sh
similarity index 100%
rename from dist/docker/server/debian/common/configure_database.sh
rename to dist/docker/server/debian/common/serverimage_configure_database.sh
diff --git a/dist/docker/server/debian/common/configure_environment.sh b/dist/docker/server/debian/common/serverimage_configure_environment.sh
similarity index 100%
rename from dist/docker/server/debian/common/configure_environment.sh
rename to dist/docker/server/debian/common/serverimage_configure_environment.sh
diff --git a/dist/docker/server/debian/common/serverimage_init_basic.sh b/dist/docker/server/debian/common/serverimage_init_basic.sh
new file mode 100755
index 000000000..4e84ceabc
--- /dev/null
+++ b/dist/docker/server/debian/common/serverimage_init_basic.sh
@@ -0,0 +1,289 @@
+#!/bin/bash
+# Install all package we need to prepare and install 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 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 .
+
+declare DEBUG=0
+declare MYSQL_GAMESERVER=0
+declare APACHE_GAMESERVER=0
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ script to intialize server
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+ -m, --mysql-gameserver : create database on gameserver account
+ -a, --apache-gameserver : configure apache to use gameserver account
+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
+}
+
+msg_info "Start Basic"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ DEBUG=1
+ shift
+ ;;
+ -m|--mysql-gameserver)
+ MYSQL_GAMESERVER=1
+ shift
+ ;;
+ -a|--apache-gameserver)
+ APACHE_GAMESERVER=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 account gameserver
+####################################
+if [[ $APACHE_GAMESERVER -ne 0 ]]
+then
+ msg_debug "Create gameserver account (shared with host)"
+ groupadd --gid $GIDGAMESERVER gameserver || echo "group id already exist"
+ useradd --uid $UIDGAMESERVER --gid $GIDGAMESERVER -G sudo -c /home -d /home/gameserver -c "Khanat account GAME" -m -p '$6$nxHX/3u.$azS0.eldpfKqxqOLDjgZj8.hPOLC64arXDTUVX0fs7RZvRBX/pNqPzDR89ccP5XkEE/daOyaD3wVtDGDUND5b/' -s /bin/bash gameserver
+ echo "group : $(id -g -n gameserver)"
+else
+ msg_debug "Create gameserver account"
+ useradd -G sudo,www-data -c /home -d /home/gameserver -c "Khanat account GAME" -m -p '$6$nxHX/3u.$azS0.eldpfKqxqOLDjgZj8.hPOLC64arXDTUVX0fs7RZvRBX/pNqPzDR89ccP5XkEE/daOyaD3wVtDGDUND5b/' -s /bin/bash -U gameserver
+fi
+
+####################################
+# Initialize apache
+####################################
+if [[ $APACHE_GAMESERVER -ne 0 ]]
+then
+ msg_debug "Configure apache log"
+ 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
+ mkdir -p /home/gameserver/log/apache2 || exit 2
+ chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
+fi
+
+####################################
+# Initialize database
+####################################
+
+if [[ $MYSQL_GAMESERVER -ne 0 ]]
+then
+ msg_debug "Create database for account gameserver"
+ # Create database on gameserver account (and change directory database)
+ sed -i -r 's/^user[[:space:]]+=[[:space:]]+(.*)/user = gameserver/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^datadir[[:space:]]+=[[:space:]]+(.*)/datadir = \/home\/gameserver\/database/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^log_error[[:space:]]+=[[:space:]]+(.*)/log_error = \/home\/gameserver\/log\/mysql\/error\.log/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^(#*)general_log_file[[:space:]]+=(.*)/general_log_file = \/home\/gameserver\/log\/mysql\/mysql\.log/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^(#*)general_log[[:space:]]+=(.*)/general_log = 1/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^(#*)slow_query_log_file[[:space:]]+=(.*)/slow_query_log_file = \/home\/gameserver\/log\/mysql\/mysql-slow\.log/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' /etc/mysql/my.cnf || exit 2
+ sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' /etc/mysql/my.cnf || exit 2
+
+ mkdir -p /home/gameserver/database/ || exit 2
+ chown gameserver:$(id -g -n gameserver) /home/gameserver/database/ || exit 2
+
+ mkdir -p /home/gameserver/log/mysql || exit 2
+ chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
+
+ /usr/bin/mysql_install_db --user=gameserver --skip-name-resolve || exit 2
+ chown gameserver:$(id -g -n gameserver) /var/run/mysqld/ || exit 2
+else
+ msg_debug "Create database"
+ /usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
+fi
+
+# Start the MySQL daemon in the background.
+msg_debug "Start database"
+/usr/sbin/mysqld &
+mysql_pid=$!
+
+# Wait mysql start
+msg_debug "Check database is started"
+until /usr/bin/mysqladmin ping >/dev/null 2>&1
+do
+ echo -n "."
+ sleep 1
+done
+
+# Initialize password root (to empty)
+msg_debug "configure password root for database"
+/usr/bin/mysqladmin -u root password '' || exit 2
+
+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
+
+
+# Stop MySQL
+msg_debug "Stop database"
+/usr/bin/mysqladmin shutdown
+
+# Wait MySQL stop
+wait $mysql_pid
+
+####################################
+# Initialize bashrc (for root)
+####################################
+msg_debug "Configure bashrc (for root)"
+cat << EOF > /root/.bashrc
+# bashrc: executed by bash(1) for non-login shells.
+
+# You may uncomment the following lines if you want 'ls' to be colorized:
+export SHELL=/bin/bash
+export LS_OPTIONS='--color=auto'
+eval "\`dircolors\`"
+alias ls='ls \$LS_OPTIONS'
+alias ll='ls \$LS_OPTIONS -l'
+alias l='ls \$LS_OPTIONS -lA'
+
+# Some more alias to avoid making mistakes:
+# alias rm='rm -i'
+# alias cp='cp -i'
+# alias mv='mv -i'
+
+# Autocompletion
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
+EOF
+
+####################################
+# Initialize bashrc (for gameserver)
+####################################
+msg_debug "Configure bashrc (for gameserver)"
+cat << EOF > /home/gameserver/.bashrc
+# bashrc: executed by bash(1) for non-login shells.
+
+# You may uncomment the following lines if you want 'ls' to be colorized:
+export SHELL=/bin/bash
+export LS_OPTIONS='--color=auto'
+eval "\`dircolors\`"
+alias ls='ls \$LS_OPTIONS'
+alias ll='ls \$LS_OPTIONS -l'
+alias l='ls \$LS_OPTIONS -lA'
+
+# Some more alias to avoid making mistakes:
+# alias rm='rm -i'
+# alias cp='cp -i'
+# alias mv='mv -i'
+
+# Autocompletion
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
+EOF
+chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc
+
+####################################
+# Adding sudo command
+####################################
+
+# Update sudo rule (you can execute all command as root)
+msg_debug "Configure sudo"
+cat << EOF > /etc/sudoers.d/gameserver
+# User privilege specification
+gameserver ALL=NOPASSWD: ALL
+EOF
+
+####################################
+# LOGING HEADER
+####################################
+# Message see when connect on ssh
+
+# Before login
+msg_debug "Configure message login"
+cat << EOF > /etc/issue.net
+*********************
+* KHANAT SERVER DEV *
+*********************
+
+account gameserver
+password khanat
+
+EOF
+
+# After Login
+msg_debug "Configure banner"
+cat << EOF > /etc/motd
+***************************************************
+connect to root use gameserver account and launch sudo command
+like :
+
+ sudo bash
+
+---------------------------------------------------
+mysql : account root (no password)
+---------------------------------------------------
+log khanat server : /home/gameserver/khanat/server/log/log.log
+***************************************************
+EOF
+
+# Activate banner
+msg_debug "Activate banner"
+sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
+
+####################################
+# End
+####################################
+msg_info "End Basic"
+
diff --git a/dist/docker/server/debian/common/init-khanat.sh b/dist/docker/server/debian/common/serverimage_init_khanat.sh
similarity index 69%
rename from dist/docker/server/debian/common/init-khanat.sh
rename to dist/docker/server/debian/common/serverimage_init_khanat.sh
index 1e32786ed..b1da9356d 100755
--- a/dist/docker/server/debian/common/init-khanat.sh
+++ b/dist/docker/server/debian/common/serverimage_init_khanat.sh
@@ -18,13 +18,14 @@
# /opt/dist/docker/server/init-khanat.sh
-/opt/configure_environment.sh || exit 2
-/opt/install_package.sh || exit 2
-/opt/configure_apache.sh || exit 2
-/opt/configure_database.sh || exit 2
-/opt/initialize_khanat_server.sh || exit 2
-/opt/initialize_patch_server.sh || exit 2
-/opt/prepare_khanat_client.sh || exit 2
+/opt/serverimage_init_basic.sh || exit 2
+/opt/serverimage_configure_environment.sh || exit 2
+/opt/serverimage_install_package.sh || exit 2
+/opt/serverimage_configure_apache.sh || exit 2
+/opt/serverimage_configure_database.sh || exit 2
+/opt/serverimage_initialize_khanat_server.sh || exit 2
+/opt/serverimage_initialize_patch_server.sh || exit 2
+/opt/serverimage_prepare_khanat_client.sh || exit 2
#
diff --git a/dist/docker/server/debian/common/initialize_khanat_server.sh b/dist/docker/server/debian/common/serverimage_initialize_khanat_server.sh
similarity index 100%
rename from dist/docker/server/debian/common/initialize_khanat_server.sh
rename to dist/docker/server/debian/common/serverimage_initialize_khanat_server.sh
diff --git a/dist/docker/server/debian/common/initialize_patch_server.sh b/dist/docker/server/debian/common/serverimage_initialize_patch_server.sh
similarity index 96%
rename from dist/docker/server/debian/common/initialize_patch_server.sh
rename to dist/docker/server/debian/common/serverimage_initialize_patch_server.sh
index ee16c669f..2f3710c6b 100755
--- a/dist/docker/server/debian/common/initialize_patch_server.sh
+++ b/dist/docker/server/debian/common/serverimage_initialize_patch_server.sh
@@ -20,10 +20,10 @@
echo "INITIALIZE PATCH SERVER"
#######################
-# GET PARAM ENVIRONMENT
+# GET ENVIRONMENT
#######################
+source /etc/apache2/envvars
export KHANAT_CLIENT_VERSION=1
-
if [[ ! -f /home/gameserver/.bashrc ]]
then
echo "ERROR - missing /home/gameserver/.bashrc"
@@ -146,7 +146,7 @@ do
done
mv kh_server.bnp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
-chown -R gameserver:www-data $PATCH_HOME/patch_service || exit 2
+chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service || exit 2
echo "PREPARE PATCH"
#
@@ -205,7 +205,7 @@ cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/index.php