: 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/${PACKAGECLIENT}.tar.gz ]]
+then
+ msg_info "[$(basename $0):$LINENO] 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-client-data/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
+msg_info "[$(basename $0):$LINENO] Generate client package"
+if [[ ! -f $HOME_CLIENT/$PACKAGECLIENT.tar.gz ]]
+then
+ msg_info "[$(basename $0):$LINENO] Generate package"
+ (cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/$PACKAGECLIENT.tar.gz $DIRCLIENT)
+fi
+
+####################################
+# Create web page to present this package
+####################################
+msg_info "[$(basename $0):$LINENO] 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):$LINENO] => END"
+
diff --git a/server/debian/common/servercontainer_configure_world.sh b/server/debian/common/servercontainer_configure_world.sh
new file mode 100755
index 0000000..b6b50b5
--- /dev/null
+++ b/server/debian/common/servercontainer_configure_world.sh
@@ -0,0 +1,280 @@
+#!/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 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 .
+
+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 recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+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_info "Check database is started"
+sleep 1
+until sudo /usr/bin/mysqladmin ping >/dev/null 2>&1
+do
+ echo -n "."
+ sleep 1
+done
+echo ""
+sleep 1
+
+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/server/debian/common/servercontainer_function.sh b/server/debian/common/servercontainer_function.sh
new file mode 100755
index 0000000..5584b0c
--- /dev/null
+++ b/server/debian/common/servercontainer_function.sh
@@ -0,0 +1,235 @@
+#!/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 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 .
+
+######################
+# 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 msg_critical()
+{
+ echo "$(date "+%Y/%m/%d %H:%M:%S") CRITICAL - $*" >&2
+ exit 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 "[$(basename $0):$LINENO] Missing 1st argument (source)"
+ exit 2
+ fi
+
+ if [ ! -f "$1" ]
+ then
+ msg_error "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Missing 1st argument (source)"
+ exit 2
+ fi
+ if [[ -z "$2" ]]
+ then
+ msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)"
+ exit 2
+ fi
+
+ filename_l=$(basename "$1")
+
+ msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Missing 1st argument (source)"
+ exit 2
+ fi
+ if [[ -z "$2" ]]
+ then
+ msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)"
+ exit 2
+ fi
+
+ msg_debug "[$(basename $0):$LINENO] link $1 -> $2"
+ for file in $1/*
+ do
+ if [ -d "$file" ]
+ then
+ filename=$(basename "$file")
+ msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Missing 1st argument (source)"
+ exit 2
+ fi
+ if [[ -z "$2" ]]
+ then
+ msg_error "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Wait job '${COMMENTJOBS[$pid]}' (pid:$pid) "
+ cmd=${JOBS[${pid}]}
+ wait ${pid}
+ JOBS[${pid}]=$?
+ if [[ ${JOBS[${pid}]} -ne 0 ]]
+ then
+ code=${JOBS[${pid}]}
+ msg_error "[$(basename $0):$LINENO] '${COMMENTJOBS[$pid]}' Exited with error [return code:$code, pid:${pid}, command:'${cmd}']"
+ fi
+ done
+ return $code
+}
+
+######################
+#
+######################
diff --git a/server/debian/common/servercontainer_init_apache.sh b/server/debian/common/servercontainer_init_apache.sh
new file mode 100755
index 0000000..e9e7f91
--- /dev/null
+++ b/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 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ prepare mysql (create directory, update configuration)
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+EOF
+}
+
+#####################
+# MAIN
+#####################
+source /opt/servercontainer_function.sh
+msg_info "$(basename $0) => START"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ set_debug 1
+ shift
+ ;;
+ *)
+ msg_error "options '$1' not recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+
+####################################
+# Configure apache log / Account use by apache
+####################################
+msg_debug "Configure apache log / Account use by apache"
+sed -i -r 's/^export[[:space:]]+APACHE_RUN_USER=(.*)/export APACHE_RUN_USER=gameserver/g' /etc/apache2/envvars || exit 2
+sed -i -r 's/^export[[:space:]]+APACHE_RUN_GROUP=(.*)/export APACHE_RUN_GROUP='$(id -g -n gameserver)'/g' /etc/apache2/envvars || exit 2
+sed -i -r 's/^export[[:space:]]+APACHE_LOG_DIR=(.*)/export APACHE_LOG_DIR=\/home\/gameserver\/log\/apache2\$SUFFIX/g' /etc/apache2/envvars || exit 2
+sed -i -r 's/^LogLevel[[:space:]]+warn/LogLevel debug/g' /etc/apache2/apache2.conf || exit 2
+
+
+
+####################################
+# configure phpmyadmin
+####################################
+msg_debug "configure phpmyadmin"
+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/server/debian/common/servercontainer_init_configure_envi.sh b/server/debian/common/servercontainer_init_configure_envi.sh
new file mode 100755
index 0000000..4db1ff9
--- /dev/null
+++ b/server/debian/common/servercontainer_init_configure_envi.sh
@@ -0,0 +1,231 @@
+#!/bin/bash
+#
+# Configure environment
+# 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ prepare mysql (create directory, update configuration)
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+EOF
+}
+
+#####################
+# MAIN
+#####################
+source /opt/servercontainer_function.sh
+msg_info "$(basename $0) => START"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ set_debug 1
+ shift
+ ;;
+ *)
+ msg_error "options '$1' not recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ msg_error "Missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+####################################
+# configure shard.sh
+####################################
+msg_info "configure shard.sh"
+cat << EOF > /opt/shard.sh
+# 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
+
+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="$DIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+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
+
+
+####################################
+# Initialize bashrc gameserver
+####################################
+msg_info "configure bashrc"
+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
+
+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="$DIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+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.
+
+# 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
+
+####################################
+# 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
+
+
+# Initialize ssh
+/etc/init.d/ssh restart
+
+####################################
+# End
+####################################
+msg_info "$(basename $0) => END"
diff --git a/server/debian/common/servercontainer_init_create_account.sh b/server/debian/common/servercontainer_init_create_account.sh
new file mode 100755
index 0000000..60a9bdb
--- /dev/null
+++ b/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 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 .
+
+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 recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+####################################
+# Configure 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/server/debian/common/servercontainer_init_mysql.sh b/server/debian/common/servercontainer_init_mysql.sh
new file mode 100755
index 0000000..a383e10
--- /dev/null
+++ b/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 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ prepare mysql (create directory, update configuration)
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+EOF
+}
+
+#####################
+# MAIN
+#####################
+source /opt/servercontainer_function.sh
+msg_info "$(basename $0) => START"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ set_debug 1
+ shift
+ ;;
+ *)
+ msg_error "options '$1' not recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+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/server/debian/common/servercontainer_init_package.sh b/server/debian/common/servercontainer_init_package.sh
new file mode 100755
index 0000000..87f4a27
--- /dev/null
+++ b/server/debian/common/servercontainer_init_package.sh
@@ -0,0 +1,65 @@
+#!/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 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 .
+
+usage()
+{
+cat << EOF
+usage:$0 [options]
+ prepare mysql (create directory, update configuration)
+
+options:
+ -h, --help : Show this help
+ -d, --debug : Show debug message
+EOF
+}
+
+#####################
+# MAIN
+#####################
+source /opt/servercontainer_function.sh
+msg_info "$(basename $0) => START"
+
+while test $# -gt 0
+do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ -d|--debug)
+ set_debug 1
+ shift
+ ;;
+ *)
+ msg_error "options '$1' not recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+# 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/server/debian/common/servercontainer_launch_auto.sh b/server/debian/common/servercontainer_launch_auto.sh
new file mode 100755
index 0000000..f7d6768
--- /dev/null
+++ b/server/debian/common/servercontainer_launch_auto.sh
@@ -0,0 +1,320 @@
+#!/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 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 .
+
+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
+ --start-with-manager : start khanat with manager
+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'
+}
+
+function create_default_file_for_screen()
+{
+ # on scrren mode, we launch with root right
+ # But file are created on root, so , to solve that, we generate directory and file before
+
+ create_dir_gameserver '/home/gameserver/khanat/server/bms_master'
+ create_dir_gameserver '/home/gameserver/khanat/server/rws'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters_offline_commands'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters/002'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/ai_script_data'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/sale_store'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302/ke'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302/ke/kem'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/totems'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/logs'
+ create_dir_gameserver '/home/gameserver/khanat/server/save_shard/sdb'
+ create_dir_gameserver '/home/gameserver/khanat/server/pds'
+ create_dir_gameserver '/home/gameserver/khanat/server/pds/00000000'
+ create_dir_gameserver '/home/gameserver/khanat/server/pds/00000000/logs'
+ create_dir_gameserver '/home/gameserver/khanat/server/gpms'
+ create_dir_gameserver '/home/gameserver/khanat/server/aes'
+ create_dir_gameserver '/home/gameserver/khanat/server/lgs'
+ create_dir_gameserver '/home/gameserver/khanat/server/data_shard/primitive_cache'
+ create_dir_gameserver '/home/gameserver/khanat/server/su'
+ create_dir_gameserver '/home/gameserver/khanat/server/ms'
+ create_dir_gameserver '/home/gameserver/khanat/server/egs'
+ create_dir_gameserver '/home/gameserver/khanat/server/data_shard_local'
+ create_dir_gameserver '/home/gameserver/khanat/server/data_shard_local/statistics'
+ create_dir_gameserver '/home/gameserver/khanat/server/fes'
+ create_dir_gameserver '/home/gameserver/khanat/server/mfs'
+ create_dir_gameserver '/home/gameserver/khanat/server/ras'
+ create_dir_gameserver '/home/gameserver/khanat/server/ios'
+ create_dir_gameserver '/home/gameserver/khanat/server/sbs'
+ create_dir_gameserver '/home/gameserver/khanat/server/ais_newbyland'
+ create_dir_gameserver '/home/gameserver/khanat/server/rns'
+ create_dir_gameserver '/home/gameserver/khanat/server/ts'
+}
+
+#####################
+# 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
+ ;;
+ --start-with-manager)
+ METHOD_START=6
+ shift
+ ;;
+ *)
+ msg_error "options '$1' not recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+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:]]/}
+sudo sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
+
+
+#####################
+# Reconfigure database
+#####################
+msg_debug "Reconfigure database : Configure Domain"
+## Configure Domain
+sudo 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
+msg_debug "Reconfigure database : Configure nel.shard"
+sudo mysql -u root -e "use nel;
+UPDATE nel.shard
+SET WsAddr = '$addressip:'
+WHERE ShardId = 302;" || exit 2
+
+# Configure nel_tool.neltool_domains
+msg_debug "Reconfigure database : Configure nel_tool.neltool_domains"
+sudo 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; cd "$RYZOM_PATH"; $KHANAT_HOME/khanat/tools/scripts/linux/shard start
+elif [[ $METHOD_START -eq 1 ]]
+then
+ /opt/ext/servercontainer_launch_service.sh
+ sleep 10
+ tail -n+0 -f /home/gameserver/log/khanat/log.log
+elif [[ $METHOD_START -eq 2 ]]
+then
+ /opt/ext/servercontainer_launch_service.sh
+ sleep 10
+ watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
+elif [[ $METHOD_START -eq 3 ]]
+then
+ /opt/ext/servercontainer_launch_service.sh
+ sleep 10
+ tail -n+0 -f /home/gameserver/log/apache2/* /home/gameserver/log/mysql/* /home/gameserver/log/khanat/*
+elif [[ $METHOD_START -eq 4 ]]
+then
+ /opt/ext/servercontainer_launch_service.sh
+ sleep 10
+ watch /opt/ext/servercontainer_launch_status.sh --no-color
+elif [[ $METHOD_START -eq 5 ]]
+then
+ /opt/ext/servercontainer_launch_service.sh
+ #sleep 10
+ bash
+elif [[ $METHOD_START -eq 6 ]]
+then
+ mkdir -p /home/gameserver/log/khanat
+ mkdir -p /home/gameserver/khanat/server/gpms
+ /home/gameserver/ext/khaganat/tools/manage.py --log info --show-log-console --filelog /home/gameserver/log/khanat/manager.log -c /home/gameserver/khanat/khaganat.cfg --launch-program
+ bash
+else
+ msg_error 'Bad option'
+ exit 2
+fi
+
+
+######################
+#
+######################
diff --git a/server/debian/common/servercontainer_launch_service.sh b/server/debian/common/servercontainer_launch_service.sh
new file mode 100755
index 0000000..751ed3c
--- /dev/null
+++ b/server/debian/common/servercontainer_launch_service.sh
@@ -0,0 +1,167 @@
+#!/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 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 .
+
+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 recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "Load environment"
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+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/server/debian/common/servercontainer_launch_status.sh b/server/debian/common/servercontainer_launch_status.sh
new file mode 100755
index 0000000..1d96e3a
--- /dev/null
+++ b/server/debian/common/servercontainer_launch_status.sh
@@ -0,0 +1,174 @@
+#!/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 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 .
+
+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 recognize"
+ 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/server/debian/common/servercontainer_update_auto.sh b/server/debian/common/servercontainer_update_auto.sh
new file mode 100755
index 0000000..e872388
--- /dev/null
+++ b/server/debian/common/servercontainer_update_auto.sh
@@ -0,0 +1,27 @@
+#!/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 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 .
+
+/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/server/debian/common/serverimage_autostart.sh b/server/debian/common/serverimage_autostart.sh
new file mode 100755
index 0000000..11f0743
--- /dev/null
+++ b/server/debian/common/serverimage_autostart.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# Scritp to 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 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 .
+
+declare METHOD_START=$1
+
+/etc/init.d/mysql restart
+/etc/init.d/apache2 restart
+/etc/init.d/ssh restart
+source /opt/shard.sh
+
+tmp=$(hostname -I)
+export addressip=${tmp//[[:blank:]]/}
+sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
+
+/opt/serverimage_prepare_start_server.sh || exit 2
+
+if [[ $METHOD_START -eq 1 ]]
+then
+ export RYZOM_PATH=$KHANAT_PATH
+ /home/gameserver/khanat/tools/scripts/linux/shard start
+elif [[ $METHOD_START -eq 2 ]]
+then
+ bash /opt/serverimage_launch_services.sh
+ sleep 10
+ tail -n+0 -f /home/gameserver/khanat/server/log/log.log
+else
+ bash /opt/serverimage_launch_services.sh
+ sleep 10
+ watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
+fi
diff --git a/server/debian/common/serverimage_configure_apache.sh b/server/debian/common/serverimage_configure_apache.sh
new file mode 100755
index 0000000..76d0f4a
--- /dev/null
+++ b/server/debian/common/serverimage_configure_apache.sh
@@ -0,0 +1,155 @@
+#!/bin/bash
+#
+# Configure apache
+# Copyright (C) 2017 AleaJactaEst
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+
+echo "CONFIGURE APACHE"
+
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+
+# load environment
+source /home/gameserver/.bashrc
+
+# Create directory use for patch server
+#mkdir -p $KHANAT_PATH/khanatweb/public_php/
+mkdir -p $PATCH_CLIENT_SYSTEM/patch_game/patch
+mkdir -p $KHANAT_HOME/client_service/
+
+# 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 $KHANAT_PATH/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 $KHANAT_PATH/khanatweb/public_php
+
+ ErrorLog \${APACHE_LOG_DIR}/error.log
+ CustomLog \${APACHE_LOG_DIR}/access.log combined
+
+
+# Patch Server
+
+ ServerName lirria.khaganat.net
+ DocumentRoot $PATCH_HOME/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/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
+
+# Activate & deploy new configuration
+a2enconf patch_service.conf
+
+# Configuration de la page client
+cat << EOF > /etc/apache2/conf-available/client_service.conf
+Alias /client /home/gameserver/client_service
+
+ Options FollowSymLinks
+ DirectoryIndex index.html
+
+ Require all granted
+
+
+ AddType application/tar .tar.gz
+
+
+ SetHandler application/tar
+
+
+
+EOF
+
+# Activate & deploy new configuration
+a2enconf client_service.conf
+
+# Restart apache
+service apache2 restart || exit 2
+
diff --git a/server/debian/common/serverimage_configure_database.sh b/server/debian/common/serverimage_configure_database.sh
new file mode 100755
index 0000000..1a76209
--- /dev/null
+++ b/server/debian/common/serverimage_configure_database.sh
@@ -0,0 +1,133 @@
+#!/bin/bash
+#
+# Configure database
+# 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 .
+
+
+echo "CONFIGURE DATABASE"
+
+export KHANAT_CLIENT_VERSION=1
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+
+# load environment
+source /home/gameserver/.bashrc
+
+# start/restart service mysql & apache
+service mysql restart || exit 2
+
+# 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
+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 /opt/setup.log || exit 2
+
+# Check account is create
+grep "Domain role successfully installed" /opt/setup.log >/dev/null || exit 2
+
+# Get IP ADDRESS
+tmp=$(hostname -I)
+export addressip=${tmp//[[:blank:]]/}
+
+## 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
+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
+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
+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
+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
+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
+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)
+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 /opt/account_tester.log || exit 2
+
+# configure nel.permission
+mysql -u root -e "use nel;
+UPDATE nel.permission SET AccessPrivilege = 'OPEN,DEV,RESTRICTED';
+" || exit 2
+
+
diff --git a/server/debian/common/serverimage_configure_environment.sh b/server/debian/common/serverimage_configure_environment.sh
new file mode 100755
index 0000000..a80d5bb
--- /dev/null
+++ b/server/debian/common/serverimage_configure_environment.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+#
+# Configure environment
+# 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 .
+
+####################################
+# Load Environment
+####################################
+if [[ ! -f /opt/khanat_config.sh ]]
+then
+ echo "ERROR - missing /opt/khanat_config.sh"
+ exit 2
+fi
+source /opt/khanat_config.sh
+
+
+echo "CONFIGURE ENVIRONMENT"
+
+# configure environment
+cat << EOF > /opt/shard.sh
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux
+export KHANAT_DATA=/home/gameserver/khanat-ressources
+export PATCH_HOME=/home/gameserver
+export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service
+export WORKDIRCLIENT="$WORKDIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+EOF
+
+# configure environment
+cat << EOF > /home/gameserver/.bashrc
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin:\$KHANAT_PATH/tools/scripts/linux
+export KHANAT_DATA=/home/gameserver/khanat-ressources
+export PATCH_HOME=/home/gameserver
+export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service
+export WORKDIRCLIENT="$WORKDIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+EOF
+
+# load environment
+source /home/gameserver/.bashrc
+
+# Initialize ssh
+/etc/init.d/ssh restart
+
+
+
diff --git a/server/debian/common/serverimage_init_basic.sh b/server/debian/common/serverimage_init_basic.sh
new file mode 100755
index 0000000..187ea8d
--- /dev/null
+++ b/server/debian/common/serverimage_init_basic.sh
@@ -0,0 +1,325 @@
+#!/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 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 .
+
+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 "[$(basename $0):$LINENO] => START"
+
+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 recognize"
+ usage
+ exit 1
+ ;;
+ esac
+done
+
+####################################
+# Load Environment
+####################################
+msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Create database"
+ /usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
+fi
+
+# Start the MySQL daemon in the background.
+msg_debug "[$(basename $0):$LINENO] Start database"
+/usr/sbin/mysqld &
+mysql_pid=$!
+
+# Wait mysql start
+msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] configure password root for database"
+/usr/bin/mysqladmin -u root password '' || exit 2
+
+msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Stop database"
+/usr/bin/mysqladmin shutdown
+
+# Wait MySQL stop
+wait $mysql_pid
+
+####################################
+# Initialize bashrc (for root)
+####################################
+msg_debug "[$(basename $0):$LINENO] 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
+
+# configure environment
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux
+export KHANAT_DATA=/home/gameserver/khanat-ressources
+export PATCH_HOME=/home/gameserver
+export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service
+export DIRCLIENT="$DIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+EOF
+
+####################################
+# Initialize bashrc (for gameserver)
+####################################
+msg_debug "[$(basename $0):$LINENO] 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
+
+# configure environment
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux
+export KHANAT_DATA=/home/gameserver/khanat-ressources
+export PATCH_HOME=/home/gameserver
+export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service
+export DIRCLIENT="$DIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+EOF
+chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc
+
+####################################
+# Initialize shard.sh
+####################################
+# configure environment
+msg_debug "[$(basename $0):$LINENO] Configure shard.sh"
+cat << EOF > /opt/shard.sh
+export KHANAT_HOME=/home/gameserver
+export KHANAT_PATH=/home/gameserver/khanat
+export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/linux
+export KHANAT_DATA=/home/gameserver/khanat-ressources
+export PATCH_HOME=/home/gameserver
+export PATCH_CLIENT_SYSTEM=\$PATCH_HOME/patch_service
+export WORKDIRCLIENT="$WORKDIRCLIENT"
+export PACKAGECLIENT="$PACKAGECLIENT"
+EOF
+
+####################################
+# Adding sudo command
+####################################
+
+# Update sudo rule (you can execute all command as root)
+msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Configure message login"
+cat << EOF > /etc/issue.net
+*********************
+* KHANAT SERVER DEV *
+*********************
+
+account gameserver
+password khanat
+
+EOF
+
+# After Login
+msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] Activate banner"
+sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
+
+####################################
+# End
+####################################
+msg_info "[$(basename $0):$LINENO] => END"
+
diff --git a/server/debian/common/serverimage_init_khanat.sh b/server/debian/common/serverimage_init_khanat.sh
new file mode 100755
index 0000000..8fff4b9
--- /dev/null
+++ b/server/debian/common/serverimage_init_khanat.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Script to initialize 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 .
+
+
+function msg_critical()
+{
+ echo "$(date "+%Y/%m/%d %H:%M:%S") CRITICAL - $*" >&2
+ exit 2
+}
+
+/opt/serverimage_init_basic.sh || msg_critical "serverimage_init_basic.sh issue"
+/opt/serverimage_install_package.sh || msg_critical "serverimage_install_package.sh issue"
+/opt/serverimage_configure_apache.sh || msg_critical "serverimage_configure_apache.sh issue"
+/opt/serverimage_configure_database.sh || msg_critical "serverimage_configure_database.sh issue"
+/opt/serverimage_initialize_khanat_server.sh || msg_critical "serverimage_initialize_khanat_server.sh issue"
+/opt/serverimage_initialize_patch_server.sh || msg_critical "serverimage_initialize_patch_server.sh issue"
+/opt/serverimage_prepare_khanat_client.sh || msg_critical "serverimage_prepare_khanat_client.sh issue"
+
+
+#
+# Stop All
+#
+
+service ssh stop || msg_critical "ssh stop issue"
+service apache2 stop|| msg_critical "apache2 stop issue"
+service mysql stop || msg_critical "mysql stop issue"
+
+exit 0
+
diff --git a/server/debian/common/serverimage_initialize_khanat_server.sh b/server/debian/common/serverimage_initialize_khanat_server.sh
new file mode 100755
index 0000000..fb1ca50
--- /dev/null
+++ b/server/debian/common/serverimage_initialize_khanat_server.sh
@@ -0,0 +1,103 @@
+#!/bin/bash
+#
+# Configure 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 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 .
+
+
+echo "INITIALIZE KHANAT SERVER"
+
+#######################
+# GET PARAM ENVIRONMENT
+#######################
+export KHANAT_CLIENT_VERSION=1
+
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+
+# load environment
+source /home/gameserver/.bashrc
+
+# Load
+if [[ -f /opt/khanat_config.sh ]]
+then
+ echo "Configuration loaded"
+ source /opt/khanat_config.sh
+ echo "KHANAT_CLIENT_VERSION:$KHANAT_CLIENT_VERSION"
+fi
+
+# configure khanat server
+sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "localhost";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
+sed -i -r 's/(DBHost)(.*)(=)(.*)(;)/DBHost = "localhost";/g' $KHANAT_PATH/server/sql.cfg || exit 2
+sed -i -r 's/(DBRingName)(.*)(=)(.*)(;)/ DBRingName = "ring_mini01";/g' $KHANAT_PATH/server/sql.cfg || exit 2
+
+# Generate data
+cd /usr/local; /usr/local/bin/make_sheet_id \
+ -o$KHANAT_DATA/leveldesign/game_elem/sheet_id.bin \
+ $KHANAT_DATA/leveldesign/game_elem \
+ $KHANAT_DATA/leveldesign/game_element \
+ $KHANAT_DATA/leveldesign/world \
+ $KHANAT_DATA/leveldesign/ecosystems \
+ $KHANAT_DATA/sound \
+ $KHANAT_DATA/mirror_sheets || exit 2
+
+# configure sheets_packer.cfg
+rm -rf /opt/sheets_packer/*
+mkdir -p /opt/sheets_packer/common /opt/sheets_packer/khanat-ressources /opt/sheets_packer/client
+cat << EOF > /opt/sheets_packer/sheets_packer.cfg
+/////////////////////////////////
+/////////////////////////////////
+/// SHEETS PACKER CONFIG FILE ///
+/////////////////////////////////
+/////////////////////////////////
+DataPath = { "/opt/sheets_packer/common/data_leveldesign",
+ "/opt/sheets_packer/common/data_common",
+ "/opt/sheets_packer/client/data",
+ "/opt/sheets_packer/khanat-ressources/common",
+ "/opt/sheets_packer/khanat-ressources/leveldesign",
+ "/opt/sheets_packer/khanat-ressources/primitives" };
+WorldSheet = "ryzom.world";
+PrimitivesPath = "/opt/sheets_packer/khanat-ressources/primitives";
+OutputDataPath = "/opt/sheets_packer/client/data";
+LigoPrimitiveClass = "world_editor_classes.xml";
+DumpVisualSlotsIndex = 1;
+EOF
+
+# copy data to target
+cp -r /opt/code/ryzom/common/* /opt/sheets_packer/common || exit 2
+cp -r $KHANAT_DATA/* /opt/sheets_packer/khanat-ressources || exit 2
+cp -r /opt/code/ryzom/client/* /opt/sheets_packer/client || exit 2
+cd /opt/sheets_packer; sheets_packer || exit 2
+cp /opt/sheets_packer/visual_slot.tab $KHANAT_PATH/common/data_common/visual_slot.tab || exit 2
+cp /opt/sheets_packer/visual_slot.tab $KHANAT_PATH/client/data/visual_slot.tab || exit 2
+
+# link translation
+for var in $KHANAT_DATA/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_de}; done
+for var in $KHANAT_DATA/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_es}; done
+for var in $KHANAT_DATA/translation/translated/*_wk.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_wk/_ru}; done
+
+# Copy default screen configuration
+cp /opt/code/ryzom/server/shard.screen.rc $KHANAT_PATH/server/shard.screen.rc
+sed -i -r 's/\$RYZOM_PATH\/\.\.\/build\/bin\///g' $KHANAT_PATH/server/shard.screen.rc
+
+ln -s /usr/local /home/gameserver/build
+
+# create default directory for rrd data
+mkdir -p $KHANAT_PATH/server/save_shard/rrd_graphs
+
+
diff --git a/server/debian/common/serverimage_initialize_patch_server.sh b/server/debian/common/serverimage_initialize_patch_server.sh
new file mode 100755
index 0000000..763ff88
--- /dev/null
+++ b/server/debian/common/serverimage_initialize_patch_server.sh
@@ -0,0 +1,217 @@
+#!/bin/bash
+#
+# install / compile data / configure patch 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 .
+
+echo "INITIALIZE PATCH SERVER"
+
+#######################
+# GET ENVIRONMENT
+#######################
+source /etc/apache2/envvars
+export KHANAT_CLIENT_VERSION=1
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+
+# load environment
+source /home/gameserver/.bashrc
+
+# Load
+if [[ -f /opt/khanat_config.sh ]]
+then
+ echo "Configuration loaded"
+ source /opt/khanat_config.sh
+ echo "KHANAT_CLIENT_VERSION:$KHANAT_CLIENT_VERSION"
+fi
+
+#
+# Serveur Patch
+# Account use : gameserver
+
+# Generate data to client
+echo "PATCH - CREATE DIRECTORY"
+echo "PATCH_HOME:$PATCH_HOME"
+echo "PATCH_CLIENT_SYSTEM:$PATCH_CLIENT_SYSTEM"
+mkdir -p $PATCH_HOME/patch_service/dataserver || exit 2
+
+# Search le nombre de langue
+listlang=$(ls $KHANAT_DATA/translation/translated | cut -f 1 -d '.' | sed 's/^.*\(.\{2\}\)$/\1/' | sort | uniq)
+echo "LIST LANG : $listlang"
+
+for lang in $listlang
+do
+ echo "create dir : $PATCH_HOME/patch_service/dataserver/kh_translate_$lang"
+ mkdir -p $PATCH_HOME/patch_service/dataserver/kh_translate_$lang || exit 2
+done
+mkdir -p $PATCH_HOME/patch_service/kh_server || exit 2
+mkdir -p $PATCH_HOME/patch_service/dataserver || exit 2
+mkdir -p $PATCH_CLIENT_SYSTEM/patch_game/bnp/
+
+echo "COPY DATA TO GENERATE PATCH"
+cp $KHANAT_PATH/common/data_common/database.xml $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2
+cp $KHANAT_PATH/common/data_common/msg.xml $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2
+cp /opt/sheets_packer/client/data/*.packed_sheets $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2
+cp /opt/sheets_packer/client/data/*.packed $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2
+cp $KHANAT_PATH/common/data_common/visual_slot.tab $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2
+cp $KHANAT_DATA/leveldesign/game_elem/sheet_id.bin $PATCH_CLIENT_SYSTEM/kh_server/ || exit 2
+
+
+cd $PATCH_HOME/patch_service/dataserver; tar xzf /opt/khanat-client-data.tar.gz || exit 2
+
+# language : copy to client (to generate client patch)
+for lang in $listlang
+do
+ cp $KHANAT_DATA/translation/translated/*$lang.* $PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang/ || exit 2
+done
+
+echo "GENERATE PATCH"
+for lang in $listlang
+do
+ cd $PATCH_CLIENT_SYSTEM/dataserver/; bnp_make -p kh_translate_$lang || exit 2
+done
+
+# tous les bnp de khanat-client-data
+cd $PATCH_HOME/patch_service/dataserver/data/; bnp_make -p fonts || exit 2
+for dir in $PATCH_HOME/patch_service/dataserver/data/kh/*
+do
+ cd $dir/..; bnp_make -p $(basename $dir) || exit 2
+done
+
+for dir in $PATCH_HOME/patch_service/dataserver/data/kh_shard/*
+do
+ cd $dir/..; bnp_make -p $(basename $dir) || exit 2
+done
+
+for dir in $PATCH_HOME/patch_service/dataserver/data/ryz/*
+do
+ cd $dir/..; bnp_make -p $(basename $dir) || exit 2
+done
+
+## TODO - check how generate '.ref' files
+for dir in $PATCH_HOME/patch_service/dataserver/client/*
+do
+ cd $dir/..; bnp_make -p $(basename $dir) || exit 2
+done
+for file in $PATCH_HOME/patch_service/dataserver/client/*.bnp
+do
+ mv "$file" "${file%.bnp}_.ref" || exit 2
+done
+
+
+# kh_server
+cd $PATCH_CLIENT_SYSTEM/; bnp_make -p kh_server || exit 2
+
+echo "MOVE PATCH"
+
+for file in $PATCH_HOME/patch_service/dataserver/client/*.ref
+do
+ mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
+done
+
+for file in $PATCH_HOME/patch_service/dataserver/data/kh/*.bnp
+do
+ mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
+done
+
+#for file in $PATCH_HOME/patch_service/dataserver/data/kh_shard/*.bnp
+#do
+# mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
+#done
+
+for file in $PATCH_HOME/patch_service/dataserver/data/ryz/*.bnp
+do
+ mv "$file" $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
+done
+
+for lang in $listlang
+do
+ mv $PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang.bnp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
+done
+mv kh_server.bnp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
+
+chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service || exit 2
+
+echo "PREPARE PATCH"
+#
+su -c "cd $PATCH_HOME/patch_service; patch_gen createNewProduct patch_game/ryzom.xml" gameserver || exit 2
+su -c "cd $PATCH_HOME/patch_service;touch patch_game/Lirria.version" gameserver || exit 2
+sed -i -r 's/value="main"/value="khanat_lirria"/g' patch_game/ryzom.xml || exit 2
+sed -i -r 's/_NextVersionFile type="STRING" value=""/_NextVersionFile type="STRING" value="patch_game\/Lirria.version"/g' patch_game/ryzom.xml || exit 2
+
+# Edit RYZOM file
+
+# search all ref files
+ADDREF=""
+for file in /home/gameserver/patch_service/patch_game/bnp/*.ref
+do
+ ADDREF="$ADDREF"'<_Files type=\"STRING\" value=\"'$(basename $file)'\"/>'
+done
+
+# Remove other _Category (keep 1st) and add ref file
+cp patch_game/ryzom.xml patch_game/ryzom.xml.ref || exit 2
+awk 'BEGIN{found=0}{
+ if(found==0 && $1 == "<_Category>") {
+ found = 1;
+ } else if(found == 1 && $1 == "") {
+ found = 2;
+ print "'"$ADDREF"'";
+ print $0;
+ } else if(found == 2 && $1 == "") {
+ found = 3;
+ }
+ if ( found != 2 ) {
+ print $0
+ }
+}' patch_game/ryzom.xml.ref > patch_game/ryzom.xml || exit 2
+
+# Force version release
+if [[ $KHANAT_CLIENT_VERSION -gt 1 ]]
+then
+ # rm $PATCH_HOME/patch_service/patch_game/ryzom.hist
+ # rm $PATCH_HOME/patch_service/patch_game/ref/*
+ echo -n "$KHANAT_CLIENT_VERSION" > $PATCH_HOME/patch_service/patch_game/Lirria.version
+fi
+
+# Generate patch
+su -c "cd $PATCH_HOME/patch_service; patch_gen updateProduct patch_game/ryzom.xml" gameserver || exit 2
+
+# Edit release note
+cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/index.php
+
+
+
+
+
+ New test data - Release $KHANAT_CLIENT_VERSION
+ 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
+chown gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service/patch_game/patch/index.php
+
+# TODO - Strange, we need update patch - to be check
+cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/Lirria.version
+$KHANAT_CLIENT_VERSION $KHANAT_CLIENT_VERSION
+EOF
+
+# configure right (apache can read files)
+chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service
+chmod g+w -R $PATCH_HOME/patch_service
+
diff --git a/server/debian/common/serverimage_install_package.sh b/server/debian/common/serverimage_install_package.sh
new file mode 100755
index 0000000..b3ff94b
--- /dev/null
+++ b/server/debian/common/serverimage_install_package.sh
@@ -0,0 +1,104 @@
+#!/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 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 .
+
+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 msg_critical()
+{
+ echo "$(date "+%Y/%m/%d %H:%M:%S") CRITICAL - $*" >&2
+ exit 2
+}
+
+echo "INSTALL PACKAGE"
+
+# Load Environment
+source /etc/apache2/envvars
+export KHANAT_CLIENT_VERSION=1
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+# install new package
+cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || msg_critical "[$LINENO] extract ryzomcore.tar.gz issue"
+cd /opt; tar xzf ryzom-ressources.tar.gz || msg_critical "[$LINENO] extract ryzom-ressources.tar.gz issue"
+
+# Create Home directory (if not exist)
+mkdir -p $KHANAT_PATH || msg_critical "[$LINENO] create directory $KHANAT_PATH issue"
+
+# install web khanat
+ls -l /opt
+ls -l /opt/code
+cp -r /opt/code/web $KHANAT_PATH/khanatweb || msg_critical "[$LINENO] copy web data issue"
+chmod -R a+w $KHANAT_PATH/khanatweb || msg_critical "[$LINENO] change right issue ($KHANAT_PATH/khanatweb)"
+chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $KHANAT_PATH/khanatweb || msg_critical "[$LINENO] change owner issue ($KHANAT_PATH/khanatweb)"
+
+# Get Ressource
+mkdir -p $KHANAT_DATA/ressources
+(cd $KHANAT_DATA; tar xzf /opt/khanat-ressources.tar.gz) || msg_critical "[$LINENO] extract khanat-ressources.tar.gz issue"
+
+# Copy script ryzom
+mkdir -p $KHANAT_PATH/tools/scripts/linux
+cp -r /opt/code/ryzom/tools/scripts/linux/* $KHANAT_PATH/tools/scripts/linux || msg_critical "[$LINENO] copy all script to $KHANAT_PATH/tools/scripts/linux"
+
+# Copy data for server
+mkdir -p $KHANAT_PATH/server || msg_critical "[$LINENO] create directory $KHANAT_PATH/server issue"
+cp -r /opt/code/ryzom/common/ $KHANAT_PATH/common || msg_critical "[$LINENO] copy common data issue"
+cp -r /opt/code/ryzom/client/ $KHANAT_PATH/client || msg_critical "[$LINENO] copy client data issue"
+cp /opt/code/ryzom/server/*.cfg $KHANAT_PATH/server/. || msg_critical "[$LINENO] copy config issue"
+
+# create link resource
+## Directories
+ln -s $KHANAT_DATA/collisions $KHANAT_PATH/server/
+ln -s $KHANAT_DATA/leveldesign $KHANAT_PATH/server/
+ln -s $KHANAT_DATA/primitives $KHANAT_PATH/server/
+ln -s $KHANAT_DATA/translation $KHANAT_PATH/server/
+ln -s $KHANAT_DATA/continents $KHANAT_PATH/server/
+ln -s $KHANAT_DATA/common $KHANAT_PATH/server/
+## Files
+mkdir -p $KHANAT_PATH/server/data_shard
+cp -r /opt/code/ryzom/server/data_shard/* $KHANAT_PATH/server/data_shard/.
+ln -s $KHANAT_DATA/shard/su/dev_gm_names.xml $KHANAT_PATH/server/data_shard/dev_gm_names.xml
+ln -s $KHANAT_DATA/shard/su/invalid_entity_names.txt $KHANAT_PATH/server/data_shard/invalid_entity_names.txt
+ln -s $KHANAT_DATA/shard/su/reserved_names.xml $KHANAT_PATH/server/data_shard/reserved_names.xml
+ln -s $KHANAT_DATA/shard/egs/game_event.txt $KHANAT_PATH/server/data_shard/game_event.txt
+ln -s $KHANAT_DATA/shard/egs/mission_queues.txt $KHANAT_PATH/server/data_shard/mission_queues.txt
+ln -s $KHANAT_DATA/shard/egs/named_items.txt $KHANAT_PATH/server/data_shard/named_items.txt
+
+# copy data from khanat-code
+mkdir -p $KHANAT_DATA/mirror_sheets
+cp -r /opt/code/ryzom/server/data_shard/mirror_sheets/* $KHANAT_DATA/mirror_sheets
+
diff --git a/server/debian/common/serverimage_install_package_static.sh b/server/debian/common/serverimage_install_package_static.sh
new file mode 100755
index 0000000..b527efe
--- /dev/null
+++ b/server/debian/common/serverimage_install_package_static.sh
@@ -0,0 +1,35 @@
+#!/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 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 .
+
+
+echo "INSTALL PACKAGE"
+
+# Load Environment
+source /etc/apache2/envvars
+export KHANAT_CLIENT_VERSION=1
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+# install new package
+cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || exit 2
+cd /opt; tar xzf khanat-ref-ressources.tar.gz || exit 2
+
diff --git a/server/debian/common/serverimage_launch_services.sh b/server/debian/common/serverimage_launch_services.sh
new file mode 100755
index 0000000..3989130
--- /dev/null
+++ b/server/debian/common/serverimage_launch_services.sh
@@ -0,0 +1,99 @@
+#!/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 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 .
+
+mkdir -p /home/gameserver/khanat/server/log
+cd /home/gameserver/khanat/server/log
+
+function start_stop()
+{
+ nameservice=$1
+ mkdir -p /home/gameserver/khanat/server/${nameservice}
+ printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+ nohup $2
+ printf STOPPED > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+}
+
+function launch_service()
+{
+ nameservice=$1
+ start_stop "$1" "$2" 1>/dev/null 2>&1 &
+ #nohup $2 1>/dev/null 2>&1 &
+ #echo "$!" > /home/gameserver/khanat/server/$1.pid
+ #printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
+}
+
+# aes : admin_executor_service.log
+launch_service 'aes' 'ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --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/khanat/server/log --nobreak --writepid'
+
+# mos
+# launch_service 'mos' 'ryzom_monitor_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --nobreak --writepid'
+
+# pdss
+#launch_service 'pdss' 'ryzom_pd_support_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/khanat/server/log --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/khanat/server/log --nobreak --writepid'
+
+
diff --git a/server/debian/common/serverimage_prepare_khanat_client.sh b/server/debian/common/serverimage_prepare_khanat_client.sh
new file mode 100755
index 0000000..c80ae3f
--- /dev/null
+++ b/server/debian/common/serverimage_prepare_khanat_client.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# Script to create package khanat_client
+# 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 .
+
+echo "[$(basename $0):$LINENO] PREPARE PACKAGE KHANAT CLIENT"
+
+# Load Environment
+source /etc/apache2/envvars
+export KHANAT_CLIENT_VERSION=1
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - [$(basename $0):$LINENO] missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+if [ -z "$PACKAGECLIENT" ]
+then
+ echo "ERROR - [$(basename $0):$LINENO] missing definition PACKAGECLIENT"
+ exit 2
+fi
+
+if [ -z "$DIRCLIENT" ]
+then
+ echo "ERROR - [$(basename $0):$LINENO] missing definition DIRCLIENT"
+ exit 2
+fi
+
+declare HOME_PREPARE_CLIENT="$KHANAT_HOME/prepare_client/$DIRCLIENT"
+declare HOME_CLIENT="$KHANAT_HOME/client_service"
+
+# Create directory
+mkdir -p $HOME_PREPARE_CLIENT || exit 2
+mkdir -p $HOME_PREPARE_CLIENT/{data,cfg,save,user,cache} || exit 2
+mkdir -p $HOME_CLIENT || exit 2
+
+# Copy all data
+cp /usr/local/games/khanat_client $HOME_PREPARE_CLIENT/. || exit 2
+cp /usr/local/etc/ryzom/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_HOME/patch_service/patch_game/bnp/kh_translate_{wk,fr,en}.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+cp $PATCH_HOME/patch_service/dataserver/client/exedll_linux64/khanat.png $HOME_PREPARE_CLIENT/data/. || exit 2
+cp $PATCH_HOME/patch_service/dataserver/data/fonts.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+cp $PATCH_HOME/patch_service/patch_game/bnp/kh_interfaces.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+cp $PATCH_HOME/patch_service/patch_game/bnp/ryz_zzz_bazaar.bnp $HOME_PREPARE_CLIENT/data/. || exit 2
+cp $PATCH_HOME/khanat/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
+
+# Generate package
+(cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/${PACKAGECLIENT}.tar.gz $DIRCLIENT)
+
+# create index for client
+cat << EOF > $HOME_CLIENT/index.html
+
+
+
+KHANAT CLIENT
+
+
+
+You can download khanat client
+khanat client
+
+
+
+EOF
+chown -R gameserver:$APACHE_RUN_GROUP $HOME_CLIENT
+
+#################################
+#
+#################################
+
diff --git a/server/debian/common/serverimage_prepare_start_server.sh b/server/debian/common/serverimage_prepare_start_server.sh
new file mode 100755
index 0000000..e2b8e62
--- /dev/null
+++ b/server/debian/common/serverimage_prepare_start_server.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+#
+# Script to update khanat configuration (change ip address)
+#
+# 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 .
+
+echo "PREPARE ENVIRONMENT"
+
+# Load Environment
+export KHANAT_CLIENT_VERSION=1
+if [[ ! -f /home/gameserver/.bashrc ]]
+then
+ echo "ERROR - missing /home/gameserver/.bashrc"
+ exit 2
+fi
+source /home/gameserver/.bashrc
+
+# Get IP ADDRESS
+tmp=$(hostname -I)
+export addressip=${tmp//[[:blank:]]/}
+
+## 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
+
diff --git a/server/debian/jessie/i686/Dockerfile b/server/debian/jessie/i686/Dockerfile
new file mode 100644
index 0000000..9f2abbe
--- /dev/null
+++ b/server/debian/jessie/i686/Dockerfile
@@ -0,0 +1,34 @@
+# 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 .
+#
+
+FROM i386/debian:8
+MAINTAINER AleaJactaEst
+
+ENV HOSTNAME basic_server
+
+RUN apt-get update ; \
+ apt-get dist-upgrade -y ; \
+ apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx ; \
+ apt-get install -y openssh-server sudo net-tools ; \
+ apt-get install -y lzma xdelta p7zip p7zip-full ; \
+ 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 python3 ; \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
+
+
+
diff --git a/server/debian/jessie/i686/Dockerfile.khanat.container b/server/debian/jessie/i686/Dockerfile.khanat.container
new file mode 100644
index 0000000..b2b7500
--- /dev/null
+++ b/server/debian/jessie/i686/Dockerfile.khanat.container
@@ -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 .
+#
+
+FROM opennel/server_generic_debian_jessie_i686
+MAINTAINER AleaJactaEst
+
+ENV HOSTNAME khanat_server
+
+COPY server/debian/common/servercontainer_function.sh /opt/
+COPY server/debian/common/servercontainer_init_* /opt/
+
+COPY output/opennel_debian_jessie_i686/khanat_config.sh /opt/khanat_config.sh
+
+RUN /opt/servercontainer_init_create_account.sh
+RUN /opt/servercontainer_init_mysql.sh
+RUN /opt/servercontainer_init_apache.sh
+RUN /opt/servercontainer_init_configure_envi.sh
+
diff --git a/server/debian/jessie/i686/Dockerfile.khanat.image b/server/debian/jessie/i686/Dockerfile.khanat.image
new file mode 100644
index 0000000..cae8488
--- /dev/null
+++ b/server/debian/jessie/i686/Dockerfile.khanat.image
@@ -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 .
+#
+
+FROM opennel/server_generic_debian_jessie_i686
+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
+
diff --git a/server/debian/jessie/i686/server-container.sh b/server/debian/jessie/i686/server-container.sh
new file mode 100755
index 0000000..4848b0a
--- /dev/null
+++ b/server/debian/jessie/i686/server-container.sh
@@ -0,0 +1,537 @@
+#!/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 .
+
+
+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="--start-khanat-with-screen"
+declare -i CLEANIMAGENONE=0
+declare DOCKERBUILDOPT=""
+
+declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_i686"
+declare IMAGEKHANATSERVER="opennel/servercontainer_debian_jessie_i686"
+declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_i686"
+declare DIROUTPUT="output/opennel_debian_jessie_i686"
+declare ROOTDATAKHANAT="$DIROUTPUT/gameserver"
+declare DIRLOG="$ROOTDATAKHANAT/log"
+declare DIRDATABASE="$ROOTDATAKHANAT/database"
+declare ENVIFILE="$DIROUTPUT/khanat_config.sh"
+declare DIRKHANAT="$ROOTDATAKHANAT/khanat"
+declare KHANAT_RESSOURCES_DIR=""
+declare KHANAT_CLIENT_DATA_DIR=""
+declare OPENNEL_CODE_DIR=""
+declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok"
+declare DIRCLIENT="Khanat_Linux32"
+declare PACKAGECLIENT="smokey_linux32"
+
+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"
+ --khanat-ressources-dir=[DIR] : localization khanat-ressources
+ --khanat-client-data-dir=[DIR] : localization khanat-client-data
+ --opennel-code-dir=[DIR] : localization opennel-code
+ --start-khanat-with-screen : start with screen
+ --start-khanat-with-khanat-log : start server khanat and show khanat log
+ --start-khanat-with-full-log : start server khanat and show full log
+ --start-khanat-with-watch-state : start server khanat and show state (loop)
+ --start-khanat-with-watch-state-nagios : start server khanat and show state [nagios format] (loop)
+ --start-khanat-with-bash-after : start server khanat and launch bash
+ --start-with-manager : start khanat with manager
+ --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
+ ;;
+ -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="--start-khanat-with-screen"
+ shift
+ ;;
+ --start-khanat-with-khanat-log)
+ METHODSTARTSERVER="--show-khanat-log"
+ shift
+ ;;
+ --start-khanat-with-full-log)
+ METHODSTARTSERVER="--show-all-log"
+ shift
+ ;;
+ --start-khanat-with-watch-state)
+ METHODSTARTSERVER="--show-status"
+ shift
+ ;;
+ --start-khanat-with-watch-state-nagios)
+ METHODSTARTSERVER="--show-status-nagios"
+ shift
+ ;;
+ --start-khanat-with-bash-after)
+ METHODSTARTSERVER="--bash-after-start"
+ shift
+ ;;
+ --start-with-manager)
+ METHODSTARTSERVER="--start-with-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
+ ;;
+ -w|--clean-images-none)
+ CLEANIMAGENONE=1
+ shift
+ ;;
+ -u|--update-data)
+ UPDATEDATA=1
+ shift
+ ;;
+ --option-docker-build)
+ DOCKERBUILDOPT="$DOCKERBUILDOPT ${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 "START"
+fi
+
+msg_debug "prg: $0"
+
+docker -v 1>/dev/null
+if [[ $? -ne 0 ]]
+then
+ msg_error "docker not installed"
+ exit 2
+fi
+
+case "$(uname -m)" in
+ x86_64)
+ ;;
+ i686)
+ ;;
+ *)
+ msg_error "Unknown archi : $(uname -m)"
+ exit 2
+ ;;
+esac
+
+if [[ $REMOVE -ne 0 ]]
+then
+ msg_info "REMOVE DATA KHANAT : $ROOTDATAKHANAT"
+ if [[ -n "$ROOTDATAKHANAT" ]]
+ then
+ rm -rf ${ROOTDATAKHANAT}/* || exit 2
+ fi
+fi
+
+msg_debug "Create directory on host ($ROOTDATAKHANAT)"
+mkdir -p $ROOTDATAKHANAT || exit 2
+chmod g+s $ROOTDATAKHANAT
+
+
+if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
+then
+ msg_debug "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 "END SSH"
+ exit 0
+fi
+
+if [[ $AUTODETEC -ne 0 ]]
+then
+ msg_debug "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 [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]]
+ then
+ CONFIGUREKHANATSERVER=1
+ fi
+fi
+
+DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
+
+msg_debug "calldir: $calldir"
+msg_debug "basedir: $basedir"
+msg_debug "rootdir: $rootdir"
+msg_debug "ressourcedir: $ressourcedir"
+msg_debug "generate basic image: $BASICSERVER"
+msg_debug "localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}"
+msg_debug "localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}"
+msg_debug "localization opennel-code-client : ${OPENNEL_CODE_DIR}"
+msg_debug "generate khanat image: $KHANATSERVER"
+msg_debug "launch khanat: $LAUNCHKHANAT"
+msg_debug "stop khanat: $STOPKHANAT"
+
+msg_info "check khanat-ressources"
+if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]]
+then
+ msg_error "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 "check khanat-client-data"
+if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]]
+then
+ msg_error "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 "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 "STOP SERVER KHANAT"
+ listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
+ msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}"
+ if [[ -n "$listcontainer" ]]
+ then
+ docker stop "$listcontainer" || exit 2
+ fi
+fi
+
+if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
+then
+ msg_info "CLEAN CONTAINER KHANAT"
+ listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
+ msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}"
+ if [[ -n "${listcontainer[@]}" ]]
+ then
+ docker rm --force "${listcontainer[@]}" || exit 2
+ fi
+fi
+
+if [[ $CLEANIMAGENONE -ne 0 ]]
+then
+ msg_info "CLEAN IMAGE DOCKER 'NONE'"
+ listimages=( $(docker images | awk '{if ($1=="")print $3}') )
+
+ msg_debug "IMAGES NONE : ${listimages[@]}"
+ if [[ -n "${listimages[@]}" ]]
+ then
+ docker rmi --force "${listimages[@]}" || exit 2
+ fi
+fi
+
+if [[ $BASICSERVER -ne 0 ]]
+then
+ msg_info "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 "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 "CONFIGURE KHANAT SERVER"
+ mkdir -p $DIRLOG || exit 2
+ mkdir -p $DIRDATABASE || exit 2
+ msg_debug "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 \
+ ${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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2
+fi
+
+if [[ $UPDATEDATA -ne 0 ]]
+then
+ msg_info "UPDATE KHANAT SERVER"
+ msg_debug "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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh
+fi
+
+if [[ $LAUNCHKHANAT -ne 0 ]]
+then
+ msg_info "START KHANAT SERVER"
+ cd $rootdir; docker run -it --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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d
+fi
+
+trap '' EXIT
+msg_info "END"
diff --git a/server/debian/jessie/i686/server-image.sh b/server/debian/jessie/i686/server-image.sh
new file mode 100755
index 0000000..2ab11b2
--- /dev/null
+++ b/server/debian/jessie/i686/server-image.sh
@@ -0,0 +1,443 @@
+#!/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 .
+
+
+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 OPENNEL_CODE_DIR=""
+
+declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_i686"
+declare IMAGEKHANATSERVER="opennel/serverimage_debian_jessie_i686"
+declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_i686"
+declare DIRCLIENT="Khanat_Linux32"
+declare PACKAGECLIENT="smokey_linux32"
+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 "START"
+fi
+
+msg_debug "prg: $0"
+
+extradir="${rootdir}/${DIROUTPUT}"
+mkdir -p ${extradir} || exit 2
+
+
+docker -v 1>/dev/null
+if [[ $? -ne 0 ]]
+then
+ msg_error "docker not installed"
+ exit 2
+fi
+
+case "$(uname -m)" in
+ x86_64)
+ ;;
+ i686)
+ ;;
+ *)
+ msg_error "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 "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 "ryzomcore checksum src:$sumsrc dst:$sumdst"
+ if [[ "$sumsrc" != "$sumdst" ]]
+ then
+ msg_debug "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 "calldir: $calldir"
+msg_debug "basedir: $basedir"
+msg_debug "rootdir: $rootdir"
+msg_debug "ressourcedir: $ressourcedir"
+msg_debug "generate basic image: $BASICSERVER"
+msg_debug "generate tar khanat ressources: $KHANATRESSOURCES"
+msg_debug "generate tar khanat data client: $KHANATDATACLIENT"
+msg_debug "generate tar ryzom ressources: $RYZOMRESSOURCES"
+msg_debug "generate khanat image: $KHANATSERVER"
+msg_debug "launch khanat: $LAUNCHKHANAT"
+msg_debug "stop khanat: $STOPKHANAT"
+
+if [[ ! -d ${OPENNEL_CODE_DIR} ]]
+then
+ msg_error "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 "CREATE TAR with KHANAT Ressources"
+ if [[ ! -d ${ressourcedir} ]]
+ then
+ msg_error "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 "CREATE TAR with KHANAT DATA CLIENT"
+ if [[ ! -d ${dataclientdir} ]]
+ then
+ msg_error "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 "CREATE TAR with RYZOM Ressources"
+ if [[ ! -d ${ressourcedir} ]]
+ then
+ msg_error "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 "STOP SERVER KHANAT"
+ listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
+ msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}"
+ if [[ -n "$listcontainer" ]]
+ then
+ docker stop "$listcontainer" || exit 2
+ fi
+fi
+
+if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
+then
+ msg_info "CLEAN CONTAINER KHANAT"
+ listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
+ msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}"
+ if [[ -n "${listcontainer[@]}" ]]
+ then
+ docker rm --force "${listcontainer[@]}" || exit 2
+ fi
+fi
+
+if [[ $CLEANIMAGENONE -ne 0 ]]
+then
+ msg_info "CLEAN IMAGE DOCKER 'NONE'"
+ listimages=( $(docker images | awk '{if ($1=="")print $3}') )
+
+ msg_debug "IMAGES NONE : ${listimages[@]}"
+ if [[ -n "${listimages[@]}" ]]
+ then
+ docker rmi --force "${listimages[@]}" || exit 2
+ fi
+fi
+
+if [[ $BASICSERVER -ne 0 ]]
+then
+ msg_info "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 "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 "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 "END"
diff --git a/server/debian/jessie/x86_64/Dockerfile b/server/debian/jessie/x86_64/Dockerfile
new file mode 100644
index 0000000..030055e
--- /dev/null
+++ b/server/debian/jessie/x86_64/Dockerfile
@@ -0,0 +1,34 @@
+# 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 .
+#
+
+FROM amd64/debian:8
+MAINTAINER AleaJactaEst
+
+ENV HOSTNAME basic_server
+
+RUN apt-get update ; \
+ apt-get dist-upgrade -y ; \
+ apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx ; \
+ apt-get install -y openssh-server sudo net-tools ; \
+ apt-get install -y lzma xdelta p7zip p7zip-full ; \
+ 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 python3 ; \
+ DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
+
+
+
diff --git a/server/debian/jessie/x86_64/Dockerfile.khanat.container b/server/debian/jessie/x86_64/Dockerfile.khanat.container
new file mode 100644
index 0000000..825f087
--- /dev/null
+++ b/server/debian/jessie/x86_64/Dockerfile.khanat.container
@@ -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 .
+#
+
+FROM opennel/server_generic_debian_jessie_x86_64
+MAINTAINER AleaJactaEst
+
+ENV HOSTNAME khanat_server
+
+COPY server/debian/common/servercontainer_function.sh /opt/
+COPY server/debian/common/servercontainer_init_* /opt/
+
+COPY output/opennel_debian_jessie_x86_64/khanat_config.sh /opt/khanat_config.sh
+
+RUN /opt/servercontainer_init_create_account.sh
+RUN /opt/servercontainer_init_mysql.sh
+RUN /opt/servercontainer_init_apache.sh
+RUN /opt/servercontainer_init_configure_envi.sh
+
diff --git a/server/debian/jessie/x86_64/Dockerfile.khanat.image b/server/debian/jessie/x86_64/Dockerfile.khanat.image
new file mode 100644
index 0000000..57b4ff0
--- /dev/null
+++ b/server/debian/jessie/x86_64/Dockerfile.khanat.image
@@ -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 .
+#
+
+FROM opennel/server_generic_debian_jessie_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
+
diff --git a/server/debian/jessie/x86_64/server-container.sh b/server/debian/jessie/x86_64/server-container.sh
new file mode 100755
index 0000000..af3fd46
--- /dev/null
+++ b/server/debian/jessie/x86_64/server-container.sh
@@ -0,0 +1,537 @@
+#!/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 .
+
+
+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="--start-khanat-with-screen"
+declare -i CLEANIMAGENONE=0
+declare DOCKERBUILDOPT=""
+
+declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_x86_64"
+declare IMAGEKHANATSERVER="opennel/servercontainer_debian_jessie_x86_64"
+declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_x86_64"
+declare DIROUTPUT="output/opennel_debian_jessie_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 KHANAT_RESSOURCES_DIR=""
+declare KHANAT_CLIENT_DATA_DIR=""
+declare OPENNEL_CODE_DIR=""
+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"
+ --khanat-ressources-dir=[DIR] : localization khanat-ressources
+ --khanat-client-data-dir=[DIR] : localization khanat-client-data
+ --opennel-code-dir=[DIR] : localization opennel-code
+ --start-khanat-with-screen : start with screen
+ --start-khanat-with-khanat-log : start server khanat and show khanat log
+ --start-khanat-with-full-log : start server khanat and show full log
+ --start-khanat-with-watch-state : start server khanat and show state (loop)
+ --start-khanat-with-watch-state-nagios : start server khanat and show state [nagios format] (loop)
+ --start-khanat-with-bash-after : start server khanat and launch bash
+ --start-with-manager : start khanat with manager
+ --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
+ ;;
+ -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="--start-khanat-with-screen"
+ shift
+ ;;
+ --start-khanat-with-khanat-log)
+ METHODSTARTSERVER="--show-khanat-log"
+ shift
+ ;;
+ --start-khanat-with-full-log)
+ METHODSTARTSERVER="--show-all-log"
+ shift
+ ;;
+ --start-khanat-with-watch-state)
+ METHODSTARTSERVER="--show-status"
+ shift
+ ;;
+ --start-khanat-with-watch-state-nagios)
+ METHODSTARTSERVER="--show-status-nagios"
+ shift
+ ;;
+ --start-khanat-with-bash-after)
+ METHODSTARTSERVER="--bash-after-start"
+ shift
+ ;;
+ --start-with-manager)
+ METHODSTARTSERVER="--start-with-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
+ ;;
+ -w|--clean-images-none)
+ CLEANIMAGENONE=1
+ shift
+ ;;
+ -u|--update-data)
+ UPDATEDATA=1
+ shift
+ ;;
+ --option-docker-build)
+ DOCKERBUILDOPT="$DOCKERBUILDOPT ${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 "START"
+fi
+
+msg_debug "prg: $0"
+
+docker -v 1>/dev/null
+if [[ $? -ne 0 ]]
+then
+ msg_error "docker not installed"
+ exit 2
+fi
+
+case "$(uname -m)" in
+ x86_64)
+ ;;
+ i686)
+ ;;
+ *)
+ msg_error "Unknown archi : $(uname -m)"
+ exit 2
+ ;;
+esac
+
+if [[ $REMOVE -ne 0 ]]
+then
+ msg_info "REMOVE DATA KHANAT : $ROOTDATAKHANAT"
+ if [[ -n "$ROOTDATAKHANAT" ]]
+ then
+ rm -rf ${ROOTDATAKHANAT}/* || exit 2
+ fi
+fi
+
+msg_debug "Create directory on host ($ROOTDATAKHANAT)"
+mkdir -p $ROOTDATAKHANAT || exit 2
+chmod g+s $ROOTDATAKHANAT
+
+
+if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
+then
+ msg_debug "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 "END SSH"
+ exit 0
+fi
+
+if [[ $AUTODETEC -ne 0 ]]
+then
+ msg_debug "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 [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]]
+ then
+ CONFIGUREKHANATSERVER=1
+ fi
+fi
+
+DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
+
+msg_debug "calldir: $calldir"
+msg_debug "basedir: $basedir"
+msg_debug "rootdir: $rootdir"
+msg_debug "ressourcedir: $ressourcedir"
+msg_debug "generate basic image: $BASICSERVER"
+msg_debug "localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}"
+msg_debug "localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}"
+msg_debug "localization opennel-code-client : ${OPENNEL_CODE_DIR}"
+msg_debug "generate khanat image: $KHANATSERVER"
+msg_debug "launch khanat: $LAUNCHKHANAT"
+msg_debug "stop khanat: $STOPKHANAT"
+
+msg_info "check khanat-ressources"
+if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]]
+then
+ msg_error "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 "check khanat-client-data"
+if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]]
+then
+ msg_error "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 "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 "STOP SERVER KHANAT"
+ listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
+ msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}"
+ if [[ -n "$listcontainer" ]]
+ then
+ docker stop "$listcontainer" || exit 2
+ fi
+fi
+
+if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
+then
+ msg_info "CLEAN CONTAINER KHANAT"
+ listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
+ msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}"
+ if [[ -n "${listcontainer[@]}" ]]
+ then
+ docker rm --force "${listcontainer[@]}" || exit 2
+ fi
+fi
+
+if [[ $CLEANIMAGENONE -ne 0 ]]
+then
+ msg_info "CLEAN IMAGE DOCKER 'NONE'"
+ listimages=( $(docker images | awk '{if ($1=="")print $3}') )
+
+ msg_debug "IMAGES NONE : ${listimages[@]}"
+ if [[ -n "${listimages[@]}" ]]
+ then
+ docker rmi --force "${listimages[@]}" || exit 2
+ fi
+fi
+
+if [[ $BASICSERVER -ne 0 ]]
+then
+ msg_info "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 "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 "CONFIGURE KHANAT SERVER"
+ mkdir -p $DIRLOG || exit 2
+ mkdir -p $DIRDATABASE || exit 2
+ msg_debug "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 \
+ ${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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2
+fi
+
+if [[ $UPDATEDATA -ne 0 ]]
+then
+ msg_info "UPDATE KHANAT SERVER"
+ msg_debug "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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh
+fi
+
+if [[ $LAUNCHKHANAT -ne 0 ]]
+then
+ msg_info "START KHANAT SERVER"
+ cd $rootdir; docker run -it --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 \
+ ${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d
+fi
+
+trap '' EXIT
+msg_info "END"
diff --git a/server/debian/jessie/x86_64/server-image.sh b/server/debian/jessie/x86_64/server-image.sh
new file mode 100755
index 0000000..66d031c
--- /dev/null
+++ b/server/debian/jessie/x86_64/server-image.sh
@@ -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 .
+
+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="server_generic_debian_jessie_x86_64"
+declare IMAGEKHANATSERVER="serverimage_khanat_debian_jessie_x86_64"
+declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_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 "START"
+fi
+
+msg_debug "prg: $0"
+
+extradir="${rootdir}/${DIROUTPUT}"
+mkdir -p ${extradir} || exit 2
+
+
+docker -v 1>/dev/null
+if [[ $? -ne 0 ]]
+then
+ msg_error "docker not installed"
+ exit 2
+fi
+
+case "$(uname -m)" in
+ x86_64)
+ ;;
+ i686)
+ ;;
+ *)
+ msg_error "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 "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 "ryzomcore checksum src:$sumsrc dst:$sumdst"
+ if [[ "$sumsrc" != "$sumdst" ]]
+ then
+ msg_debug "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 "calldir: $calldir"
+msg_debug "basedir: $basedir"
+msg_debug "rootdir: $rootdir"
+msg_debug "ressourcedir: $ressourcedir"
+msg_debug "generate basic image: $BASICSERVER"
+msg_debug "generate tar khanat ressources: $KHANATRESSOURCES"
+msg_debug "generate tar khanat data client: $KHANATDATACLIENT"
+msg_debug "generate tar ryzom ressources: $RYZOMRESSOURCES"
+msg_debug "generate khanat image: $KHANATSERVER"
+msg_debug "launch khanat: $LAUNCHKHANAT"
+msg_debug "stop khanat: $STOPKHANAT"
+
+if [[ ! -d ${OPENNEL_CODE_DIR} ]]
+then
+ msg_error "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 "CREATE TAR with KHANAT Ressources"
+ if [[ ! -d ${ressourcedir} ]]
+ then
+ msg_error "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 "CREATE TAR with KHANAT DATA CLIENT"
+ if [[ ! -d ${dataclientdir} ]]
+ then
+ msg_error "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 "CREATE TAR with RYZOM Ressources"
+ if [[ ! -d ${ressourcedir} ]]
+ then
+ msg_error "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 "STOP SERVER KHANAT"
+ listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
+ msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}"
+ if [[ -n "$listcontainer" ]]
+ then
+ docker stop "$listcontainer" || exit 2
+ fi
+fi
+
+if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
+then
+ msg_info "CLEAN CONTAINER KHANAT"
+ listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
+ msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}"
+ if [[ -n "${listcontainer[@]}" ]]
+ then
+ docker rm --force "${listcontainer[@]}" || exit 2
+ fi
+fi
+
+if [[ $CLEANIMAGENONE -ne 0 ]]
+then
+ msg_info "CLEAN IMAGE DOCKER 'NONE'"
+ listimages=( $(docker images | awk '{if ($1=="")print $3}') )
+
+ msg_debug "IMAGES NONE : ${listimages[@]}"
+ if [[ -n "${listimages[@]}" ]]
+ then
+ docker rmi --force "${listimages[@]}" || exit 2
+ fi
+fi
+
+if [[ $BASICSERVER -ne 0 ]]
+then
+ msg_info "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 "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 "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 "END"