create variable to define package client name

This commit is contained in:
Jerome Sagnole 2017-10-11 21:13:19 +02:00
parent 695d3a2147
commit b8c7b5c077
13 changed files with 179 additions and 140 deletions

View file

@ -19,10 +19,12 @@
/opt/ext/servercontainer_configure_link.sh || exit 2
/opt/ext/servercontainer_configure_mysql.sh || exit 2
sync
/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 gameserver || exit 2
su -c '/opt/ext/servercontainer_configure_khanat.sh' gameserver || exit 2
su -c '/opt/ext/servercontainer_configure_patch.sh' gameserver || exit 2
su -c 'touch /home/gameserver/khanat/step_configure.ok' gameserver || exit 2
sync
exit 0

View file

@ -31,47 +31,11 @@ options:
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
}
function copy_link()
{
if [[ -z "$1" ]]
then
msg_error "Missing 1st argument (source)"
exit 2
fi
if [ ! -f "$1" ]
then
msg_error "Missing source : '$1'"
exit 2
fi
mv "$1" "$1.old" || exit 2
cp "$1.old" "$1" || exit 2
chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
}
#####################
# MAIN
#####################
source /opt/ext/servercontainer_function.sh
msg_info "$(basename $0) => START"
msg_info "[$(basename $0):$LINENO] => START"
while test $# -gt 0
do
@ -95,17 +59,17 @@ done
####################################
# Load Environment
####################################
msg_debug "Load environment"
msg_debug "[$(basename $0):$LINENO] Load environment"
if [[ ! -f /opt/khanat_config.sh ]]
then
echo "ERROR - missing /opt/khanat_config.sh"
msg_error "[$(basename $0):$LINENO] - 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"
msg_error "[$(basename $0):$LINENO] - missing /home/gameserver/.bashrc"
exit 2
fi
source /home/gameserver/.bashrc
@ -113,16 +77,16 @@ source /home/gameserver/.bashrc
####################################
# Copy configuration & update
####################################
msg_debug "configure frontend service"
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 || exit 2
msg_debug "configure database"
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 || exit 2
sed -i -r 's/(DBRingName)(.*)(=)(.*)(;)/ DBRingName = "ring_mini01";/g' $KHANAT_PATH/server/sql.cfg || exit 2
msg_debug "prepare sheet_id.bin"
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 \
@ -153,7 +117,7 @@ OutputDataPath = "$KHANAT_PATH/server/client/data";
LigoPrimitiveClass = "world_editor_classes.xml";
DumpVisualSlotsIndex = 1;
EOF
chown $UIDGAMESERVER:$GIDGAMESERVER $KHANAT_PATH/sheets_packer.cfg
chown $UIDGAMESERVER:$GIDGAMESERVER $KHANAT_PATH/sheets_packer.cfg || exit 2
cd $KHANAT_PATH; sheets_packer 2>$KHANAT_HOME/log/configure/sheets_packer.err 1>$KHANAT_HOME/log/configure/sheets_packer.out || exit 2
rm -f $KHANAT_PATH/server/common/data_common/visual_slot.tab
@ -173,17 +137,17 @@ for var in $KHANAT_PATH/server/translation/translated/*_wk.txt; do nomfic=${var#
####################################
# Copy screen configuration
####################################
msg_debug "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
sed -i -r 's/\$RYZOM_PATH\/\.\.\/build\/bin\///g' $KHANAT_PATH/server/shard.screen.rc
sed -i -r 's/[-]A[.]/ /g' $KHANAT_PATH/server/shard.screen.rc
sed -i -r 's/[-]C[.]/ -A\/home\/gameserver\/khanat\/server -C\/home\/gameserver\/khanat\/server /g' $KHANAT_PATH/server/shard.screen.rc
sed -i -r 's/[-]L[.]/ -L\/home\/gameserver\/log\/khanat /g' $KHANAT_PATH/server/shard.screen.rc
sed -i -r 's/[.][.]\/tools\/scripts\/linux\//\/home\/gameserver\/khanat\/tools\/scripts\/linux\//g' $KHANAT_PATH/server/shard.screen.rc
cp $KHANAT_HOME/ext/ryzom-ressources/server/shard.screen.rc $KHANAT_PATH/server/shard.screen.rc || exit 2
sed -i -r 's/\$RYZOM_PATH\/\.\.\/build\/bin\///g' $KHANAT_PATH/server/shard.screen.rc || exit 2
sed -i -r 's/[-]A[.]/ /g' $KHANAT_PATH/server/shard.screen.rc || exit 2
sed -i -r 's/[-]C[.]/ -A\/home\/gameserver\/khanat\/server -C\/home\/gameserver\/khanat\/server /g' $KHANAT_PATH/server/shard.screen.rc || exit 2
sed -i -r 's/[-]L[.]/ -L\/home\/gameserver\/log\/khanat /g' $KHANAT_PATH/server/shard.screen.rc || exit 2
sed -i -r 's/[.][.]\/tools\/scripts\/linux\//\/home\/gameserver\/khanat\/tools\/scripts\/linux\//g' $KHANAT_PATH/server/shard.screen.rc || exit 2
####################################
# End
####################################
msg_info "$(basename $0) => END"
msg_info "[$(basename $0):$LINENO] => END"

View file

@ -111,7 +111,7 @@ mysql_pid=$!
# Wait mysql start
msg_info "Check database is started"
sleep 1
until /usr/bin/mysqladmin ping >/dev/null 2>&1
until sudo /usr/bin/mysqladmin ping >/dev/null 2>&1
do
echo -n "."
sleep 1

View file

@ -38,7 +38,7 @@ EOF
# MAIN
#####################
source /opt/ext/servercontainer_function.sh
msg_info "$(basename $0) => START"
msg_info "[$(basename $0):$LINENO] => START"
while test $# -gt 0
do
@ -52,7 +52,7 @@ do
shift
;;
*)
msg_error "options '$1' not recoginze"
msg_error "[$(basename $0):$LINENO] options '$1' not recoginze"
usage
exit 1
;;
@ -66,14 +66,14 @@ done
msg_debug "Load environment"
if [[ ! -f /opt/khanat_config.sh ]]
then
msg_error "Missing /opt/khanat_config.sh"
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 "Missing /home/gameserver/.bashrc"
msg_error "[$(basename $0):$LINENO] Missing /home/gameserver/.bashrc"
exit 2
fi
source /home/gameserver/.bashrc
@ -84,9 +84,9 @@ source /home/gameserver/.bashrc
####################################
# Prepare language directory
####################################
msg_info "Create 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 "LIST LANG : ${listlang[@]}"
msg_info "[$(basename $0):$LINENO] LIST LANG : ${listlang[@]}"
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver"
for lang in $listlang
@ -98,7 +98,7 @@ done
####################################
# Create link with data
####################################
msg_info "COPY DATA TO GENERATE PATCH"
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
@ -120,7 +120,7 @@ create_link "$KHANAT_PATH/server/leveldesign/game_elem/sheet_id.bin" "$PATCH_CL
####################################
# Copy Language
####################################
msg_info "Create other directory"
msg_info "[$(basename $0):$LINENO] Create other directory"
# language : copy to client (to generate client patch)
for lang in $listlang
do
@ -135,7 +135,7 @@ done
####################################
# prepare package languages
####################################
msg_info "Prepare package languages"
msg_info "[$(basename $0):$LINENO] Prepare package languages"
init_job
for lang in $listlang
do
@ -148,7 +148,7 @@ wait_all_job || exit 2
####################################
# prepare package fonts
####################################
msg_info "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-data-client/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"
@ -158,7 +158,7 @@ wait_all_job || exit 2
####################################
# prepare package kh
####################################
msg_info "Prepare package kh"
msg_info "[$(basename $0):$LINENO] Prepare package kh"
init_job
#for dir in $PATCH_CLIENT_SYSTEM/dataserver/data/kh/*
#do
@ -178,7 +178,7 @@ wait_all_job || exit 2
####################################
# prepare package kh_shard
####################################
msg_info "Prepare package kh_shard"
msg_info "[$(basename $0):$LINENO] Prepare package kh_shard"
init_job
for dir in $KHANAT_HOME/ext/khanat-data-client/data/kh_shard/*
do
@ -192,7 +192,7 @@ wait_all_job || exit 2
####################################
# prepare package ryz
####################################
msg_info "Prepare package ryz"
msg_info "[$(basename $0):$LINENO] Prepare package ryz"
init_job
for dir in $KHANAT_HOME/ext/khanat-data-client/data/ryz/*
do
@ -207,7 +207,7 @@ wait_all_job || exit 2
# prepare package client
####################################
## TODO - check how generate '.ref' files
msg_info "Prepare package patch_client"
msg_info "[$(basename $0):$LINENO] Prepare package patch_client"
init_job
for dir in $KHANAT_HOME/ext/khanat-data-client/client/*
do
@ -227,7 +227,7 @@ done
####################################
# prepare package kh_server
####################################
msg_info "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
@ -236,7 +236,7 @@ wait_all_job || exit 2
####################################
# prepare patch
####################################
msg_info "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
@ -278,19 +278,19 @@ else
fi
fi
msg_info "CLIENT VERSION: $KHANAT_CLIENT_VERSION"
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 "Generate 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 "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 <Unknown> : Added files for version:/){print $12}}' $KHANAT_HOME/log/configure/patch_${KHANAT_CLIENT_VERSION}_updateProduct.out)
@ -318,9 +318,9 @@ EOF
####################################
# Prepare client package
####################################
if [[ ! -f $HOME_CLIENT/smokey_linux64.tar.gz ]]
if [[ ! -f $HOME_CLIENT/${PACKAGECLIENT}.tar.gz ]]
then
msg_info "Prepare client package"
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
@ -343,17 +343,17 @@ fi
# Generate client package
####################################
# Generate package
#(cd $PATCH_HOME/..; 7z a smokey_linux64.7z $DIRCLIENT)
if [[ ! -f $HOME_CLIENT/smokey_linux64.tar.gz ]]
msg_info "[$(basename $0):$LINENO] Generate client package"
if [[ ! -f $HOME_CLIENT/$PACKAGECLIENT.tar.gz ]]
then
msg_info "Generate package"
(cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/smokey_linux64.tar.gz $DIRCLIENT)
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 "create index.html for client"
msg_info "[$(basename $0):$LINENO] create index.html for client"
cat << EOF > $HOME_CLIENT/index.html
<!DOCTYPE html>
<html>
@ -363,7 +363,7 @@ cat << EOF > $HOME_CLIENT/index.html
<body>
<h1>You can download khanat client - release $KHANAT_CLIENT_VERSION</h1>
<a href="smokey_linux64.tar.gz">khanat client</a>
<a href="$PACKAGECLIENT.tar.gz">khanat client</a>
</body>
</html>
@ -372,5 +372,5 @@ EOF
####################################
# End
####################################
msg_info "$(basename $0) => END"
msg_info "[$(basename $0):$LINENO] => END"

View file

@ -103,7 +103,7 @@ sudo service mysql start || exit 2
# Wait mysql start
msg_info "Check database is started"
sleep 1
until /usr/bin/mysqladmin ping >/dev/null 2>&1
until sudo /usr/bin/mysqladmin ping >/dev/null 2>&1
do
echo -n "."
sleep 1

View file

@ -66,13 +66,13 @@ function copy_link()
{
if [[ -z "$1" ]]
then
msg_error "Missing 1st argument (source)"
msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)"
exit 2
fi
if [ ! -f "$1" ]
then
msg_error "Missing source : '$1'"
msg_error "[$(basename $0):$LINENO] Missing source : '$1'"
exit 2
fi
mv "$1" "$1.old" || exit 2
@ -84,18 +84,18 @@ function create_link()
{
if [[ -z "$1" ]]
then
msg_error "Missing 1st argument (source)"
msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)"
exit 2
fi
if [[ -z "$2" ]]
then
msg_error "Missing 2nd argument (destination)"
msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)"
exit 2
fi
filename_l=$(basename "$1")
msg_debug "create link $2/$filename_l"
msg_debug "[$(basename $0):$LINENO] create link $2/$filename_l"
if [ -e "$2/$filename_l" ]
then
rm "$2/$filename_l" || exit 2
@ -105,7 +105,7 @@ function create_link()
fi
if [[ (! -e "$1") && (! -h "$1") ]]
then
msg_error "Missing source : '$1'"
msg_error "[$(basename $0):$LINENO] Missing source : '$1'"
exit 2
fi
ln -s "$1" "$2/$filename_l" || exit 2
@ -116,22 +116,22 @@ function create_recursive_link()
{
if [[ -z "$1" ]]
then
msg_error "Missing 1st argument (source)"
msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)"
exit 2
fi
if [[ -z "$2" ]]
then
msg_error "Missing 2nd argument (destination)"
msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)"
exit 2
fi
msg_debug "link $1 -> $2"
msg_debug "[$(basename $0):$LINENO] link $1 -> $2"
for file in $1/*
do
if [ -d "$file" ]
then
filename=$(basename "$file")
msg_debug "create dir $2/$filename"
msg_debug "[$(basename $0):$LINENO] create dir $2/$filename"
if [ ! -f "$2/$filename" ]
then
mkdir -p "$2/$filename" || exit 2
@ -149,12 +149,12 @@ function create_link_2nd_level()
# Function to create link
if [[ -z "$1" ]]
then
msg_error "Missing 1st argument (source)"
msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)"
exit 2
fi
if [[ -z "$2" ]]
then
msg_error "Missing 2nd argument (destination)"
msg_error "[$(basename $0):$LINENO] Missing 2nd argument (destination)"
exit 2
fi
@ -168,7 +168,7 @@ function create_dir_gameserver()
{
if [ -z "$1" ]
then
msg_error "Missing 1st argument (source)"
msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)"
exit 2
fi
mkdir -p "$1" || exit 2
@ -179,7 +179,7 @@ function create_file_gameserver()
{
if [ -z "$1" ]
then
msg_error "Missing 1st argument (source)"
msg_error "[$(basename $0):$LINENO] Missing 1st argument (source)"
exit 2
fi
touch "$1" || exit 2
@ -200,7 +200,7 @@ function init_job()
function launch_job()
{
msg_debug "Launch job '$2'"
msg_debug "[$(basename $0):$LINENO] Launch job '$2'"
eval $1 &
JOBS[$!]="$1"
COMMENTJOBS[$!]="$2"
@ -212,14 +212,14 @@ function wait_all_job()
local code=0
for pid in ${!JOBS[@]}
do
msg_debug "Wait job '${COMMENTJOBS[$pid]}' (pid:$pid) "
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 "'${COMMENTJOBS[$pid]}' Exited with error [return code:$code, pid:${pid}, command:'${cmd}']"
msg_error "[$(basename $0):$LINENO] '${COMMENTJOBS[$pid]}' Exited with error [return code:$code, pid:${pid}, command:'${cmd}']"
fi
done
return $code

View file

@ -54,11 +54,21 @@ do
esac
done
msg_info "configure shard.sh"
####################################
# 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.
@ -85,7 +95,8 @@ 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="Khanat_Linux64"
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"
@ -123,7 +134,8 @@ export KHANAT_PATH=/home/gameserver/khanat
export PATH=\$PATH:/usr/local/bin
export PATCH_CLIENT_SYSTEM=\$KHANAT_HOME/khanat/patch_service
export DIRCLIENT="Khanat_Linux64"
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"

View file

@ -17,6 +17,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
####################################
# 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"
@ -28,6 +38,8 @@ export PATH=\$PATH:/usr/local/bin:/usr/local/sbin:\$KHANAT_PATH/tools/scripts/li
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
@ -38,6 +50,8 @@ 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

View file

@ -52,7 +52,7 @@ function msg_error()
echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - $*" >&2
}
msg_info "Start Basic"
msg_info "[$(basename $0):$LINENO] => START"
while test $# -gt 0
do
@ -84,7 +84,7 @@ done
####################################
# Load Environment
####################################
msg_debug "Load environment"
msg_debug "[$(basename $0):$LINENO] Load environment"
if [[ ! -f /opt/khanat_config.sh ]]
then
echo "ERROR - missing /opt/khanat_config.sh"
@ -97,12 +97,12 @@ source /opt/khanat_config.sh
####################################
if [[ $APACHE_GAMESERVER -ne 0 ]]
then
msg_debug "Create gameserver account (shared with host)"
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 "Create gameserver account"
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
@ -111,7 +111,7 @@ fi
####################################
if [[ $APACHE_GAMESERVER -ne 0 ]]
then
msg_debug "Configure apache log"
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
@ -125,7 +125,7 @@ fi
if [[ $MYSQL_GAMESERVER -ne 0 ]]
then
msg_debug "Create database for account gameserver"
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
@ -146,17 +146,17 @@ then
/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 "Create database"
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 "Start database"
msg_debug "[$(basename $0):$LINENO] Start database"
/usr/sbin/mysqld &
mysql_pid=$!
# Wait mysql start
msg_debug "Check database is started"
msg_debug "[$(basename $0):$LINENO] Check database is started"
until /usr/bin/mysqladmin ping >/dev/null 2>&1
do
echo -n "."
@ -164,10 +164,10 @@ do
done
# Initialize password root (to empty)
msg_debug "configure password root for database"
msg_debug "[$(basename $0):$LINENO] configure password root for database"
/usr/bin/mysqladmin -u root password '' || exit 2
msg_debug "configure phpmyadmin"
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
@ -175,7 +175,7 @@ awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc
# Stop MySQL
msg_debug "Stop database"
msg_debug "[$(basename $0):$LINENO] Stop database"
/usr/bin/mysqladmin shutdown
# Wait MySQL stop
@ -184,7 +184,7 @@ wait $mysql_pid
####################################
# Initialize bashrc (for root)
####################################
msg_debug "Configure 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.
@ -205,12 +205,22 @@ alias l='ls \$LS_OPTIONS -lA'
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 "Configure 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.
@ -231,15 +241,41 @@ alias l='ls \$LS_OPTIONS -lA'
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 "Configure sudo"
msg_debug "[$(basename $0):$LINENO] Configure sudo"
cat << EOF > /etc/sudoers.d/gameserver
# User privilege specification
gameserver ALL=NOPASSWD: ALL
@ -251,7 +287,7 @@ EOF
# Message see when connect on ssh
# Before login
msg_debug "Configure message login"
msg_debug "[$(basename $0):$LINENO] Configure message login"
cat << EOF > /etc/issue.net
*********************
* KHANAT SERVER DEV *
@ -263,7 +299,7 @@ password khanat
EOF
# After Login
msg_debug "Configure banner"
msg_debug "[$(basename $0):$LINENO] Configure banner"
cat << EOF > /etc/motd
***************************************************
connect to root use gameserver account and launch sudo command
@ -279,11 +315,11 @@ log khanat server : /home/gameserver/khanat/server/log/log.log
EOF
# Activate banner
msg_debug "Activate banner"
msg_debug "[$(basename $0):$LINENO] Activate banner"
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
####################################
# End
####################################
msg_info "End Basic"
msg_info "[$(basename $0):$LINENO] => END"

View file

@ -19,7 +19,7 @@
# /opt/dist/docker/server/init-khanat.sh
/opt/serverimage_init_basic.sh || exit 2
/opt/serverimage_configure_environment.sh || exit 2
# /opt/serverimage_configure_environment.sh || exit 2
/opt/serverimage_install_package.sh || exit 2
/opt/serverimage_configure_apache.sh || exit 2
/opt/serverimage_configure_database.sh || exit 2

View file

@ -16,19 +16,30 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
echo "PREPARE PACKAGE KHANAT CLIENT"
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 - missing /home/gameserver/.bashrc"
echo "ERROR - [$(basename $0):$LINENO] missing /home/gameserver/.bashrc"
exit 2
fi
source /home/gameserver/.bashrc
declare DIRCLIENT="Khanat_Linux64"
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"
@ -56,8 +67,7 @@ cp $PATCH_HOME/khanat/client/cfg/* $HOME_PREPARE_CLIENT/cfg/. || exit 2
# khanat_install_desktop_menu.sh : script to uninstall khanat on desktop
# Generate package
#(cd $PATCH_HOME/..; 7z a smokey_linux64.7z $DIRCLIENT)
(cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/smokey_linux64.tar.gz $DIRCLIENT)
(cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/${PACKAGECLIENT}.tar.gz $DIRCLIENT)
# create index for client
cat << EOF > $HOME_CLIENT/index.html
@ -69,7 +79,7 @@ cat << EOF > $HOME_CLIENT/index.html
<body>
<h1>You can download khanat client</h1>
<a href="smokey_linux64.tar.gz">khanat client</a>
<a href="${PACKAGECLIENT}.tar.gz">khanat client</a>
</body>
</html>

View file

@ -48,7 +48,9 @@ declare ENVIFILE="$DIROUTPUT/khanat_config.sh"
declare DIRKHANAT="$ROOTDATAKHANAT/khanat"
declare KHANAT_RESSOURCES_DIR=""
declare KHANAT_DATA_CLIENT_DIR=""
declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok"
declare DIRCLIENT="Khanat_Linux64"
declare PACKAGECLIENT="smokey_linux64"
usage()
{
cat << EOF
@ -321,7 +323,7 @@ then
then
KHANAT_DATA_CLIENT_DIR="$(dirname $rootdir)/khanat-data-client"
fi
if [[ ! (-d $rootdir/$ROOTDATAKHANAT) ]]
if [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]]
then
CONFIGUREKHANATSERVER=1
fi
@ -419,6 +421,8 @@ then
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
@ -427,13 +431,6 @@ fi
if [[ $CONFIGUREKHANATSERVER -ne 0 ]]
then
msg_info "CONFIGURE 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)
EOF
mkdir -p $DIRLOG || exit 2
mkdir -p $DIRDATABASE || exit 2
cd $rootdir; docker run -it --hostname=khanat \

View file

@ -39,6 +39,8 @@ declare DOCKERBUILDOPT=""
declare IMAGEGENERICSERVER="server_generic_debian_jessie_x86_64"
declare IMAGEKHANATSERVER="serverimage_khanat_debian_jessie_x86_64"
declare LOCALBUILDDIR="build/builder_khanat_debian_jessie_x86_64"
declare DIRCLIENT="Khanat_Linux64"
declare PACKAGECLIENT="smokey_linux64"
usage()
{
@ -394,6 +396,8 @@ then
#!/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