2017-11-21 21:10:28 +00:00
|
|
|
|
#!/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 <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
2018-09-17 18:37:42 +00:00
|
|
|
|
declare -i METHOD_START=2
|
2018-08-22 21:37:29 +00:00
|
|
|
|
|
2017-11-21 21:10:28 +00:00
|
|
|
|
usage()
|
|
|
|
|
{
|
|
|
|
|
cat << EOF
|
|
|
|
|
usage:$0 [options]
|
|
|
|
|
Prepare and launch server khanat
|
|
|
|
|
|
|
|
|
|
options:
|
2018-08-22 21:37:29 +00:00
|
|
|
|
-h, --help : Show this help
|
|
|
|
|
-d, --debug : Show debug message
|
|
|
|
|
--screen : start khanat with screen
|
|
|
|
|
--opennel-manager : (default) start khanat with OpenNel-Manager
|
|
|
|
|
--bash : launch bash (doesn't start khanat)
|
2017-11-21 21:10:28 +00:00
|
|
|
|
EOF
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function create_default_file_for_screen()
|
|
|
|
|
{
|
2018-04-30 18:34:08 +00:00
|
|
|
|
# on screen mode, we launch with root right
|
2017-11-21 21:10:28 +00:00
|
|
|
|
# But file are created on root, so , to solve that, we generate directory and file before
|
|
|
|
|
|
2018-04-30 18:34:08 +00:00
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/bms_master' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/rws' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters_offline_commands' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/characters/002' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/ai_script_data' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/sale_store' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302/ke' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/www/302/ke/kem' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/totems' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/logs' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/save_shard/sdb' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/pds' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/pds/00000000' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/pds/00000000/logs' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/gpms' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/aes' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/lgs' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/data_shard/primitive_cache' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/su' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/ms' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/egs' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/data_shard_local' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/data_shard_local/statistics' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/fes' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/mfs' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/ras' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/ios' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/sbs' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/ais_newbyland' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/rns' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/ts' || exit 2
|
2017-11-21 21:10:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-22 21:37:29 +00:00
|
|
|
|
function create_default_file_for_opennel_manager()
|
|
|
|
|
{
|
|
|
|
|
create_dir_gameserver '/home/gameserver/log/khanat' || exit 2
|
|
|
|
|
create_dir_gameserver '/home/gameserver/khanat/server/gpms' || exit 2
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-21 21:10:28 +00:00
|
|
|
|
#####################
|
|
|
|
|
# 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
|
|
|
|
|
;;
|
2018-08-22 21:37:29 +00:00
|
|
|
|
--screen)
|
2017-11-21 21:10:28 +00:00
|
|
|
|
METHOD_START=0
|
|
|
|
|
shift
|
|
|
|
|
;;
|
2018-08-22 21:37:29 +00:00
|
|
|
|
--bash)
|
2017-11-21 21:10:28 +00:00
|
|
|
|
METHOD_START=1
|
|
|
|
|
shift
|
|
|
|
|
;;
|
2018-08-22 21:37:29 +00:00
|
|
|
|
--opennel-manager)
|
2017-11-21 21:10:28 +00:00
|
|
|
|
METHOD_START=2
|
|
|
|
|
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"
|
2018-08-22 21:37:29 +00:00
|
|
|
|
|
2018-08-20 22:55:57 +00:00
|
|
|
|
if [ -f /home/gameserver/opennelmanager.flag ]
|
|
|
|
|
then
|
|
|
|
|
rm /home/gameserver/opennelmanager.flag || exit 2
|
|
|
|
|
fi
|
2018-08-22 21:37:29 +00:00
|
|
|
|
|
2017-11-21 21:10:28 +00:00
|
|
|
|
if [[ $METHOD_START -eq 0 ]]
|
|
|
|
|
then
|
2018-08-05 11:36:12 +00:00
|
|
|
|
msg_debug "start with screen"
|
2017-11-21 21:10:28 +00:00
|
|
|
|
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
|
2018-08-22 21:37:29 +00:00
|
|
|
|
msg_debug "launch bash"
|
2017-11-21 21:10:28 +00:00
|
|
|
|
bash
|
2018-08-22 21:37:29 +00:00
|
|
|
|
elif [[ $METHOD_START -eq 2 ]]
|
2018-08-05 11:36:12 +00:00
|
|
|
|
then
|
|
|
|
|
msg_debug "start with OpenNelManager"
|
|
|
|
|
touch /home/gameserver/opennelmanager.flag
|
2018-08-22 21:37:29 +00:00
|
|
|
|
create_default_file_for_opennel_manager
|
2018-08-05 11:36:12 +00:00
|
|
|
|
python3 -m pymanager.manager -c /home/gameserver/khanat/khaganat.cfg --log DEBUG --filelog /home/gameserver/log/khanat/OpenNelManager.log --launch-program &
|
|
|
|
|
#sleep 10
|
|
|
|
|
#screen -t terminal /bin/bash -l
|
|
|
|
|
/bin/bash -l
|
2017-11-21 21:10:28 +00:00
|
|
|
|
else
|
2018-08-22 21:37:29 +00:00
|
|
|
|
msg_error 'Bad option (METHOD_START:$METHOD_START)'
|
2017-11-21 21:10:28 +00:00
|
|
|
|
exit 2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######################
|
|
|
|
|
#
|
|
|
|
|
######################
|