#!/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 General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
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
#################################
#
#################################