khanat-server-docker-NeL/server/debian/common/servercontainer_configure_khanat.sh

160 lines
7.1 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# Configure 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/>.
declare DEBUG=0
usage()
{
cat << EOF
usage:$0 [options]
Configure Khanat
options:
-h, --help : Show this help
-d, --debug : Show debug message
EOF
}
#####################
# MAIN
#####################
source /opt/ext/servercontainer_function.sh
msg_info "[$(basename $0):$LINENO] => 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 "[$(basename $0):$LINENO] Load environment"
if [[ ! -f /opt/khanat_config.sh ]]
then
msg_error "[$(basename $0):$LINENO] - missing /opt/khanat_config.sh"
exit 2
fi
source /opt/khanat_config.sh
if [[ ! -f /home/gameserver/.bashrc ]]
then
msg_error "[$(basename $0):$LINENO] - missing /home/gameserver/.bashrc"
exit 2
fi
source /home/gameserver/.bashrc
####################################
# Copy configuration & update
####################################
msg_debug "[$(basename $0):$LINENO] configure frontend service"
copy_link "$KHANAT_PATH/server/frontend_service.cfg"
sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "localhost";/g' $KHANAT_PATH/server/frontend_service.cfg || msg_critical "sed issue (file:frontend_service.cfg, update param FSListenHost) "
msg_debug "[$(basename $0):$LINENO] configure database"
copy_link "$KHANAT_PATH/server/sql.cfg"
sed -i -r 's/(DBHost)(.*)(=)(.*)(;)/DBHost = "localhost";/g' $KHANAT_PATH/server/sql.cfg || msg_critical "sed issue (file:sql.cfg, update param DBHost) "
sed -i -r 's/(DBRingName)(.*)(=)(.*)(;)/ DBRingName = "ring_mini01";/g' $KHANAT_PATH/server/sql.cfg || msg_critical "sed issue (file:sql.cfg, update param DBRingName) "
msg_debug "[$(basename $0):$LINENO] prepare sheet_id.bin"
copy_link "$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin"
copy_link "$KHANAT_PATH/server/leveldesign/game_elem/sheets.txt"
cd /usr/local; /usr/local/bin/make_sheet_id \
-o$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin \
$KHANAT_PATH/server/leveldesign/game_elem \
$KHANAT_PATH/server/leveldesign/game_element \
$KHANAT_PATH/server/leveldesign/world \
$KHANAT_PATH/server/leveldesign/ecosystems \
$KHANAT_PATH/server/sound \
$KHANAT_PATH/server/mirror_sheets 2>$KHANAT_HOME/log/configure/make_sheet_id.err 1>$KHANAT_HOME/log/configure/make_sheet_id.out || msg_critical "make_sheet_id issue"
msg_debug "prepare sheets_packer"
cat << EOF > $KHANAT_PATH/sheets_packer.cfg
/////////////////////////////////
/////////////////////////////////
/// SHEETS PACKER CONFIG FILE ///
/////////////////////////////////
/////////////////////////////////
DataPath = { "$KHANAT_PATH/server/common/data_leveldesign",
"$KHANAT_PATH/server/common/data_common",
"$KHANAT_PATH/server/client/data",
"$KHANAT_PATH/server/common",
"$KHANAT_PATH/server/leveldesign",
"$KHANAT_PATH/server/primitives" };
WorldSheet = "ryzom.world";
PrimitivesPath = "$KHANAT_PATH/server/primitives";
OutputDataPath = "$KHANAT_PATH/server/client/data";
LigoPrimitiveClass = "world_editor_classes.xml";
DumpVisualSlotsIndex = 1;
EOF
chown $UIDGAMESERVER:$GIDGAMESERVER $KHANAT_PATH/sheets_packer.cfg || msg_critical "chown issue (sheets_packer.cfg)"
cd $KHANAT_PATH; sheets_packer 2>$KHANAT_HOME/log/configure/sheets_packer.err 1>$KHANAT_HOME/log/configure/sheets_packer.out || msg_critical "sheets_packer issue"
rm -f $KHANAT_PATH/server/common/data_common/visual_slot.tab
cp $KHANAT_PATH/visual_slot.tab $KHANAT_PATH/server/common/data_common/visual_slot.tab || msg_critical "copy issue (visual_slot.tab -> common)"
cp $KHANAT_PATH/visual_slot.tab $KHANAT_PATH/server/client/data/visual_slot.tab || msg_critical "copy issue (visual_slot.tab -> client)"
# link translation
#for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_de}; done
#for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_en/_es}; done
#for var in $KHANAT_PATH/server/translation/translated/*_wk.txt; do nomfic=${var##*/}; ln -s $nomfic ${var%/*}/${nomfic/_wk/_ru}; done
for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; target="${var%/*}/${nomfic/_en/_de}"; rm -f $target; ln -s $nomfic $target; done
for var in $KHANAT_PATH/server/translation/translated/*_en.txt; do nomfic=${var##*/}; target="${var%/*}/${nomfic/_en/_es}"; rm -f $target; ln -s $nomfic $target; done
for var in $KHANAT_PATH/server/translation/translated/*_wk.txt; do nomfic=${var##*/}; target="${var%/*}/${nomfic/_wk/_ru}"; rm -f $target; ln -s $nomfic $target; done
####################################
# Copy screen configuration
####################################
msg_debug "[$(basename $0):$LINENO] screen configuration"
# Copy default screen configuration
cp $KHANAT_HOME/ext/ryzom-ressources/server/shard.screen.rc $KHANAT_PATH/server/shard.screen.rc || msg_critical "copy issue (file:shard.screen.rc)"
2018-07-05 22:52:57 +00:00
sed -i -r 's/\$RYZOM_PATH\/\.\.\/build\/bin\///g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, RYZOM_PATH)"
2018-07-05 22:52:57 +00:00
sed -i -r 's/[-]A[.]/ /g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, param -A)"
2018-07-05 22:52:57 +00:00
sed -i -r 's/[-]C[.]/ -A\/home\/gameserver\/khanat\/server -C\/home\/gameserver\/khanat\/server /g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, param -C)"
2018-07-05 22:52:57 +00:00
sed -i -r 's/[-]L[.]/ -L\/home\/gameserver\/log\/khanat /g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, param -L)"
2018-07-05 22:52:57 +00:00
sed -i -r 's/[.][.]\/tools\/scripts\/linux\//\/home\/gameserver\/khanat\/tools\/scripts\/linux\//g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, tools/script/linux)"
2018-07-05 22:52:57 +00:00
sed -i -r 's/chdir \$RYZOM_PATH\/server/chdir \$RYZOM_PATH\/server\\\nscreen -t terminal \/bin\/bash -l/g' $KHANAT_PATH/server/shard.screen.rc || msg_critical "replace param issue (file:shard.screen.rc, tools/script/linux)"
####################################
# End
####################################
msg_info "[$(basename $0):$LINENO] => END"