#!/bin/bash # # 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 . #declare DIRCLIENT="Khanat_Linux64" #declare PREPARE_CLIENT_DIR="khanat/prepare_client/$DIRCLIENT" #declare CLIENT_DIR="khanat/client_service" usage() { cat << EOF usage:$0 [options] Configure Patch Server 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) set_debug 1 shift ;; *) msg_error "[$(basename $0):$LINENO] options '$1' not recognize" usage exit 1 ;; esac done #################################### # Load Environment #################################### msg_debug "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 #declare HOME_PREPARE_CLIENT="$KHANAT_HOME/$PREPARE_CLIENT_DIR" #declare HOME_CLIENT="$KHANAT_HOME/$CLIENT_DIR" #################################### # Prepare language directory #################################### msg_info "[$(basename $0):$LINENO] Create language directory" listlang=$(ls $KHANAT_PATH/server/translation/translated | cut -f 1 -d '.' | sed 's/^.*\(.\{2\}\)$/\1/' | sort | uniq | tr '\n' ' ') msg_info "[$(basename $0):$LINENO] LIST LANG : ${listlang[@]}" create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver" for lang in $listlang do create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang" || exit 2 done #################################### # Create link with data #################################### msg_info "[$(basename $0):$LINENO] COPY DATA TO GENERATE PATCH" create_link "$KHANAT_PATH/server/common/data_common/database.xml" "$PATCH_CLIENT_SYSTEM/kh_server" create_link "$KHANAT_PATH/server/common/data_common/msg.xml" "$PATCH_CLIENT_SYSTEM/kh_server" for file in $KHANAT_PATH/server/client/data/*.packed_sheets do create_link "$file" "$PATCH_CLIENT_SYSTEM/kh_server" done for file in $KHANAT_PATH/server/client/data/*.packed do create_link "$file" "$PATCH_CLIENT_SYSTEM/kh_server" done create_link "$KHANAT_PATH/visual_slot.tab" "$PATCH_CLIENT_SYSTEM/kh_server/" || exit 2 create_link "$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin" "$PATCH_CLIENT_SYSTEM/kh_server/" || exit 2 # create_link "$KHANAT_HOME/ext/khanat-client-data/data" "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2 #create_recursive_link "$KHANAT_HOME/ext/khanat-client-data/data" "$PATCH_CLIENT_SYSTEM/dataserver/data" || exit 2 #################################### # Copy Language #################################### msg_info "[$(basename $0):$LINENO] Create other directory" # language : copy to client (to generate client patch) for lang in $listlang do # cp $KHANAT_PATH/server/translation/translated/*$lang.* $PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang/ || exit 2 for file in $KHANAT_PATH/server/translation/translated/*$lang.* do create_link "$file" "$PATCH_CLIENT_SYSTEM/dataserver/kh_translate_$lang/" || exit 2 done done #################################### # prepare package languages #################################### msg_info "[$(basename $0):$LINENO] Prepare package languages" init_job for lang in $listlang do comment[${#comment[@]}]="$lang" launch_job "(cd $PATCH_CLIENT_SYSTEM/dataserver/; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_translate_$lang -p kh_translate_$lang 2>$KHANAT_HOME/log/configure/patch_kh_translate_$lang.err 1>$KHANAT_HOME/log/configure/patch_kh_translate_$lang.out)" "kh_translate_$lang" done wait_all_job || exit 2 #################################### # prepare package fonts #################################### msg_info "[$(basename $0):$LINENO] Prepare package fonts" init_job #launch_job "(cd $PATCH_CLIENT_SYSTEM/dataserver/; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/fonts -p fonts 2>$KHANAT_HOME/log/configure/patch_fonts.err 1>$KHANAT_HOME/log/configure/patch_fonts.out)" "fonts" launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data; bnp_make -o$HOME_PREPARE_CLIENT/data -p fonts 2>$KHANAT_HOME/log/configure/patch_fonts.err 1>$KHANAT_HOME/log/configure/patch_fonts.out)" "fonts" wait_all_job || exit 2 #################################### # prepare package kh #################################### msg_info "[$(basename $0):$LINENO] Prepare package kh" init_job #for dir in $PATCH_CLIENT_SYSTEM/dataserver/data/kh/* #do # filename=$(basename "$dir") # msg_info "filename:$filename" # launch_job "(cd $dir/..; bnp_make -p $filename 2>$KHANAT_HOME/log/configure/dataserver_data_$filename.err 1>$KHANAT_HOME/log/configure/dataserver_data_$filename.out)" "dataserver_data_$filename" #done for dir in $KHANAT_HOME/ext/khanat-client-data/data/kh/* do filename=$(basename "$dir") msg_debug "filename:$filename" launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data/kh; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename -p $filename 2>$KHANAT_HOME/log/configure/dataserver_data_$filename.err 1>$KHANAT_HOME/log/configure/patch_kh_$filename.out)" "patch_kh_$filename" done wait_all_job || exit 2 #################################### # prepare package kh_shard #################################### msg_info "[$(basename $0):$LINENO] Prepare package kh_shard" init_job for dir in $KHANAT_HOME/ext/khanat-client-data/data/kh_shard/* do filename=$(basename "$dir") msg_debug "filename:$filename" launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data/kh_shard; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename -p $filename 2>$KHANAT_HOME/log/configure/patch_kh_shard_$filename.err 1>$KHANAT_HOME/log/configure/patch_kh_shard_$filename.out)" "patch_kh_shard_$filename" done wait_all_job || exit 2 #################################### # prepare package ryz #################################### msg_info "[$(basename $0):$LINENO] Prepare package ryz" init_job for dir in $KHANAT_HOME/ext/khanat-client-data/data/ryz/* do filename=$(basename "$dir") msg_debug "filename:$filename" launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/data/ryz; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename -p $filename 2>$KHANAT_HOME/log/configure/patch_ryz_$filename.err 1>$KHANAT_HOME/log/configure/patch_ryz_$filename.out)" "patch_ryz_$filename" done wait_all_job || exit 2 #################################### # prepare package client #################################### ## TODO - check how generate '.ref' files msg_info "[$(basename $0):$LINENO] Prepare package patch_client" init_job for dir in $KHANAT_HOME/ext/khanat-client-data/client/* do filename=$(basename "$dir") msg_debug "filename:$filename" launch_job "(cd $KHANAT_HOME/ext/khanat-client-data/client; bnp_make -o$KHANAT_HOME/khanat/patch_service/dataserver/client/$filename -p $filename 2>$KHANAT_HOME/log/configure/patch_client_$filename.err 1>$KHANAT_HOME/log/configure/patch_client_$filename.out)" "patch_client_$filename" done wait_all_job || exit 2 for file in $KHANAT_HOME/khanat/patch_service/dataserver/client/*.bnp do filename="$(basename ${file%.bnp})_.ref" mv "$file" "$PATCH_CLIENT_SYSTEM/patch_game/bnp/$filename" || exit 2 done #################################### # prepare package kh_server #################################### msg_info "[$(basename $0):$LINENO] Prepare package kh_server" init_job launch_job "(cd $PATCH_CLIENT_SYSTEM/; bnp_make -o$PATCH_CLIENT_SYSTEM/patch_game/bnp/kh_server -p kh_server 2>$KHANAT_HOME/log/configure/patch_kh_server.err 1>$KHANAT_HOME/log/configure/patch_kh_server.out)" "kh_server" wait_all_job || exit 2 #################################### # prepare patch #################################### msg_info "[$(basename $0):$LINENO] Prepare Patch" cd $PATCH_CLIENT_SYSTEM;patch_gen createNewProduct patch_game/ryzom.xml 2>$KHANAT_HOME/log/configure/patch_createNewProduct.err 1>$KHANAT_HOME/log/configure/patch_createNewProduct.out || exit 2 cd $PATCH_CLIENT_SYSTEM;touch patch_game/Lirria.version || exit 2 sed -i -r 's/value="main"/value="khanat_lirria"/g' $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml || exit 2 sed -i -r 's/_NextVersionFile type="STRING" value=""/_NextVersionFile type="STRING" value="patch_game\/Lirria.version"/g' $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml || exit 2 # Edit RYZOM file # search all ref files ADDREF="" for file in $PATCH_CLIENT_SYSTEM/patch_game/bnp/*.ref do ADDREF="$ADDREF"'<_Files type=\"STRING\" value=\"'$(basename $file)'\"/>' done cp $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml $PATCH_CLIENT_SYSTEM/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_CLIENT_SYSTEM/patch_game/ryzom.xml.ref > $PATCH_CLIENT_SYSTEM/patch_game/ryzom.xml || exit 2 if [[ -f $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version ]] then export KHANAT_CLIENT_VERSION=$(cat $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version) else if [[ -z "$KHANAT_CLIENT_VERSION" ]] then KHANAT_CLIENT_VERSION=1 fi fi msg_info "[$(basename $0):$LINENO] CLIENT VERSION: $KHANAT_CLIENT_VERSION" echo -n "$KHANAT_CLIENT_VERSION" > $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version #################################### # prepare patch #################################### msg_info "[$(basename $0):$LINENO] Generate patch" cd $PATCH_CLIENT_SYSTEM; patch_gen updateProduct patch_game/ryzom.xml 2>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.err 1>$KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out || exit 2 #################################### # Edit release note #################################### msg_info "[$(basename $0):$LINENO] Edit release note" # Added files for version REALVERSION=$(awk '{if($0 ~ /patch_gen_common.cpp 330 addVersion : 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"