mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-24 15:56:22 +00:00
adding new method to start server (in container)
This commit is contained in:
parent
3fdb2b8401
commit
08916f050a
38 changed files with 3701 additions and 120 deletions
|
@ -1 +1,2 @@
|
|||
code
|
||||
build
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
declare DIRBUILD="/opt/code/build/"
|
||||
declare DIRBUILD="/opt/build/"
|
||||
if [[ -n "$1" ]]
|
||||
then
|
||||
DIRBUILD="$1"
|
||||
|
@ -26,22 +26,28 @@ declare LOGFILE="${DIRBUILD}/build.log"
|
|||
|
||||
function chrashed()
|
||||
{
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD FAILED (code:$?)" >> $LOGFILE
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") ERROR - BUILD FAILED (code:$?)" >> $LOGFILE
|
||||
exit 2
|
||||
}
|
||||
|
||||
function msg_info()
|
||||
{
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1"
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") INFO - $1" >> $LOGFILE
|
||||
}
|
||||
|
||||
trap chrashed EXIT
|
||||
|
||||
msg_info "CREATE BUILD DIRECTORY"
|
||||
mkdir -p ${DIRBUILD}/ || exit 2
|
||||
|
||||
if [[ -f ${DIRBUILD}/envi.sh ]]
|
||||
then
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") LOAD ENVI" >> $LOGFILE
|
||||
msg_info "LOAD ENVIRONMENT"
|
||||
source ${DIRBUILD}/envi.sh
|
||||
fi
|
||||
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD START" >> $LOGFILE
|
||||
|
||||
msg_info "PREPARE BUILD"
|
||||
cd ${DIRBUILD}; cmake -DWITH_NEL=ON \
|
||||
-DWITH_STATIC=ON \
|
||||
-DWITH_STATIC_DRIVERS=ON \
|
||||
|
@ -51,12 +57,13 @@ cd ${DIRBUILD}; cmake -DWITH_NEL=ON \
|
|||
-DWITH_RYZOM_PATCH=ON \
|
||||
-DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \
|
||||
${CMAKEOPTS} \
|
||||
../.. 1>>$LOGFILE 2>&1 || exit 2
|
||||
../../code 1>>$LOGFILE 2>&1 || exit 2
|
||||
|
||||
msg_info "BUILD START"
|
||||
cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2
|
||||
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") PACKAGE" > $LOGFILE
|
||||
msg_info "GENERATE PACKAGE"
|
||||
cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2
|
||||
|
||||
trap '' EXIT
|
||||
echo "$(date "+%Y/%m/%d %H:%M:%S") BUILD END" >> $LOGFILE
|
||||
msg_info "BUILD END"
|
||||
|
|
|
@ -34,6 +34,8 @@ declare DOCKERBUILDOPT=""
|
|||
declare IMAGEDOCKER="builder_khanat_debian_jessie_x86_64"
|
||||
declare LOCALBUILDDIR="build/$IMAGEDOCKER"
|
||||
declare LOCALSRC="debian/jessie/x86_64"
|
||||
declare PACKAGEBIN="output/khanat_debian_jessie_x86_64/package/ryzomcore_jessie_x86_64.tar.gz"
|
||||
declare PACKAGEREF="output/khanat_debian_jessie_x86_64/package/khanat-ref-ressources.tar.gz"
|
||||
|
||||
|
||||
usage()
|
||||
|
@ -46,7 +48,7 @@ usage:$0 [options]
|
|||
1) clean old build directory
|
||||
2) create image builder
|
||||
3) launch build under docker (launch script build-under-docker.sh)
|
||||
4) remove docker container with state exited
|
||||
4) remove docker container with state exited and clean docker images NONE
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
|
@ -197,7 +199,7 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}"
|
||||
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
|
||||
|
||||
msg_debug "calldir: $calldir"
|
||||
msg_debug "basedir: $basedir"
|
||||
|
@ -234,11 +236,26 @@ then
|
|||
cd $rootdir; docker run -it \
|
||||
--hostname=builder \
|
||||
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
|
||||
-v $rootdir/dist:/opt/dist \
|
||||
-v $rootdir/code:/opt/code \
|
||||
-v $rootdir/dist:/opt/dist:ro \
|
||||
-v $rootdir/code:/opt/code:ro \
|
||||
-v $rootdir/build:/opt/build \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
${DOCKEROPTS} \
|
||||
${IMAGEDOCKER} \
|
||||
/opt/dist/docker/builder/${LOCALSRC}/build-under-docker.sh "/opt/code/${LOCALBUILDDIR}" || exit 2
|
||||
/opt/dist/docker/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2
|
||||
fi
|
||||
|
||||
if [[ $BUILD -ne 0 ]]
|
||||
then
|
||||
msg_info "COPY PACKAGES"
|
||||
mkdir -p output/package/
|
||||
cd ${rootdir}; tar czf ${PACKAGEREF} \
|
||||
code/ryzom/server/shard.screen.rc \
|
||||
code/ryzom/common/* \
|
||||
code/ryzom/client/* \
|
||||
code/ryzom/server/* \
|
||||
code/web/* || exit 2
|
||||
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2
|
||||
fi
|
||||
|
||||
if [[ $CLEANDOCKER -ne 0 ]]
|
||||
|
|
114
dist/docker/server/debian/common/servercontainer_configure_apache.sh
vendored
Executable file
114
dist/docker/server/debian/common/servercontainer_configure_apache.sh
vendored
Executable file
|
@ -0,0 +1,114 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Configure Apache
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/ext/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
|
||||
#####################
|
||||
# Install web service
|
||||
#####################
|
||||
msg_debug "Install web service"
|
||||
# create_recursive_link '/home/gameserver/ext/khanatweb' "$KHANAT_PATH/khanatweb"
|
||||
su -c "cp -r /home/gameserver/ext/khanatweb/* $KHANAT_PATH/khanatweb" gameserver
|
||||
|
||||
|
||||
#####################
|
||||
# Create apache log
|
||||
#####################
|
||||
msg_debug "Create apache log"
|
||||
create_dir_gameserver '/home/gameserver/log/apache2'
|
||||
|
||||
touch /home/gameserver/log/apache2/access.log || exit 2
|
||||
chown_gameserver '/home/gameserver/log/apache2/access.log' || exit 2
|
||||
|
||||
touch /home/gameserver/log/apache2/error.log || exit 2
|
||||
chown_gameserver '/home/gameserver/log/apache2/error.log' || exit 2
|
||||
|
||||
touch /home/gameserver/log/apache2/other_vhosts_access.log || exit 2
|
||||
chown_gameserver '/home/gameserver/log/apache2/other_vhosts_access.log' || exit 2
|
||||
|
||||
|
||||
#####################
|
||||
# Start & Stop apache2
|
||||
#####################
|
||||
msg_debug "Stop/Start apache"
|
||||
service apache2 start || exit 2
|
||||
service apache2 stop || exit 2
|
||||
|
||||
|
||||
#####################
|
||||
# End
|
||||
#####################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
28
dist/docker/server/debian/common/servercontainer_configure_auto.sh
vendored
Executable file
28
dist/docker/server/debian/common/servercontainer_configure_auto.sh
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to configure khanat server
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/opt/ext/servercontainer_configure_link.sh || exit 2
|
||||
/opt/ext/servercontainer_configure_mysql.sh || exit 2
|
||||
/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
|
||||
|
||||
exit 0
|
||||
|
189
dist/docker/server/debian/common/servercontainer_configure_khanat.sh
vendored
Executable file
189
dist/docker/server/debian/common/servercontainer_configure_khanat.sh
vendored
Executable file
|
@ -0,0 +1,189 @@
|
|||
#!/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 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 <http://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
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
DEBUG=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
####################################
|
||||
# Copy configuration & update
|
||||
####################################
|
||||
msg_debug "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"
|
||||
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"
|
||||
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 || exit 2
|
||||
|
||||
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
|
||||
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
|
||||
cp $KHANAT_PATH/visual_slot.tab $KHANAT_PATH/server/common/data_common/visual_slot.tab || exit 2
|
||||
cp $KHANAT_PATH/visual_slot.tab $KHANAT_PATH/server/client/data/visual_slot.tab || exit 2
|
||||
|
||||
# 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 "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
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
185
dist/docker/server/debian/common/servercontainer_configure_link.sh
vendored
Executable file
185
dist/docker/server/debian/common/servercontainer_configure_link.sh
vendored
Executable file
|
@ -0,0 +1,185 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Configure Link (link package, ...)
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
Configure Link
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/ext/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
####################################
|
||||
# Create directory target
|
||||
####################################
|
||||
msg_debug "create directory target"
|
||||
create_dir_gameserver "$KHANAT_PATH" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/collisions" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/leveldesign" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/primitives" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/translation" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/continents" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/common" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/sound" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/client" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/save_shard" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/server/save_shard/rrd_graphs" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/patch_service" || exit 2
|
||||
create_dir_gameserver "$KHANAT_HOME/log/configure" || exit 2
|
||||
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/kh_server" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/patch_game" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/patch_game/bnp" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data/kh" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data/kh_shard" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/data/ryz" || exit 2
|
||||
create_dir_gameserver "$PATCH_CLIENT_SYSTEM/dataserver/client" || exit 2
|
||||
create_dir_gameserver "$KHANAT_HOME/khanat/prepare_client" || exit 2
|
||||
create_dir_gameserver "$HOME_PREPARE_CLIENT" || exit 2
|
||||
create_dir_gameserver "$HOME_PREPARE_CLIENT/data" || exit 2
|
||||
create_dir_gameserver "$HOME_PREPARE_CLIENT/cfg" || exit 2
|
||||
create_dir_gameserver "$HOME_PREPARE_CLIENT/save" || exit 2
|
||||
create_dir_gameserver "$HOME_PREPARE_CLIENT/user" || exit 2
|
||||
create_dir_gameserver "$HOME_PREPARE_CLIENT/cache" || exit 2
|
||||
create_dir_gameserver "$HOME_CLIENT" || exit 2
|
||||
|
||||
create_dir_gameserver "$KHANAT_PATH/patch_service" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/patch_service/patch_game" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/patch_service/patch_game/patch" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/khanatweb" || exit 2
|
||||
|
||||
msg_debug "Configure Log"
|
||||
create_dir_gameserver '/home/gameserver/log/apache2' || exit 2
|
||||
create_file_gameserver '/home/gameserver/log/apache2/access.log' || exit 2
|
||||
create_file_gameserver '/home/gameserver/log/apache2/error.log' || exit 2
|
||||
create_file_gameserver '/home/gameserver/log/apache2/other_vhosts_access.log' || exit 2
|
||||
|
||||
####################################
|
||||
# Create link (like copy)
|
||||
####################################
|
||||
msg_debug "create link from ryzom-ressources"
|
||||
create_recursive_link '/home/gameserver/ext/ryzom-ressources/server/data_shard' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
|
||||
create_recursive_link '/home/gameserver/ext/ryzom-ressources/common' "$KHANAT_PATH/server/common" || exit 2
|
||||
#create_dir_gameserver "$KHANAT_PATH/server/common" || exit 2
|
||||
#create_link_2nd_level "/home/gameserver/ext/ryzom-ressources/common/*" "$KHANAT_PATH/server/common/" || exit 2
|
||||
|
||||
create_recursive_link '/home/gameserver/ext/ryzom-ressources/client' "$KHANAT_PATH/server/client" || exit 2
|
||||
#create_link '/home/gameserver/ext/ryzom-ressources/client' "$KHANAT_PATH/server/client" || exit 2
|
||||
|
||||
msg_debug "create link from khanat-ressources"
|
||||
#create_recursive_link '/home/gameserver/ext/khanat-ressources/collisions' "$KHANAT_PATH/server/collisions" || exit 2
|
||||
create_recursive_link '/home/gameserver/ext/khanat-ressources/leveldesign' "$KHANAT_PATH/server/leveldesign" || exit 2
|
||||
#create_recursive_link '/home/gameserver/ext/khanat-ressources/primitives' "$KHANAT_PATH/server/primitives" || exit 2
|
||||
create_recursive_link '/home/gameserver/ext/khanat-ressources/translation' "$KHANAT_PATH/server/translation" || exit 2
|
||||
#create_recursive_link '/home/gameserver/ext/khanat-ressources/continents' "$KHANAT_PATH/server/continents" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/collisions' "$KHANAT_PATH/server/collisions" || exit 2
|
||||
#create_link '/home/gameserver/ext/khanat-ressources/leveldesign' "$KHANAT_PATH/server/leveldesign" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/primitives' "$KHANAT_PATH/server/primitives" || exit 2
|
||||
#create_link '/home/gameserver/ext/khanat-ressources/translation' "$KHANAT_PATH/server/translation" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/continents' "$KHANAT_PATH/server/continents" || exit 2
|
||||
|
||||
create_recursive_link '/home/gameserver/ext/khanat-ressources/common' "$KHANAT_PATH/server/common" || exit 2
|
||||
#create_link_2nd_level "/home/gameserver/ext/khanat-ressources/common/*" "$KHANAT_PATH/server/common/" || exit 2
|
||||
|
||||
create_link '/home/gameserver/ext/khanat-ressources/shard/su/dev_gm_names.xml' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/shard/su/invalid_entity_names.txt' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/shard/su/reserved_names.xml' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/shard/egs/game_event.txt' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/shard/egs/mission_queues.txt' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
create_link '/home/gameserver/ext/khanat-ressources/shard/egs/named_items.txt' "$KHANAT_PATH/server/data_shard" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Link configuration
|
||||
####################################
|
||||
msg_debug "create link configuration"
|
||||
create_link_2nd_level "/home/gameserver/ext/ryzom-ressources/server/*.cfg" "$KHANAT_PATH/server" || exit 2
|
||||
#for file in /home/gameserver/ext/ryzom-ressources/server/*.cfg
|
||||
#do
|
||||
# create_link "$file" "$KHANAT_PATH/server" || exit 2
|
||||
#done
|
||||
|
||||
####################################
|
||||
# Link tools script (shard)
|
||||
####################################
|
||||
msg_debug "create link (tools)"
|
||||
create_dir_gameserver "$KHANAT_PATH/tools" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/tools/scripts" || exit 2
|
||||
create_dir_gameserver "$KHANAT_PATH/tools/scripts/linux" || exit 2
|
||||
create_recursive_link '/home/gameserver/ext/ryzom-ressources/tools/scripts/linux' "$KHANAT_PATH/tools/scripts/linux" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
143
dist/docker/server/debian/common/servercontainer_configure_mysql.sh
vendored
Executable file
143
dist/docker/server/debian/common/servercontainer_configure_mysql.sh
vendored
Executable file
|
@ -0,0 +1,143 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Configure MySQL
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
declare DEBUG=0
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
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
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/ext/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
DEBUG=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
####################################
|
||||
# Configure Log MySQL
|
||||
####################################
|
||||
msg_debug "Configure Log"
|
||||
mkdir -p /home/gameserver/log/mysql || exit 2
|
||||
chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Install Database
|
||||
####################################
|
||||
msg_debug "Install Database"
|
||||
/usr/bin/mysql_install_db --user=gameserver --skip-name-resolve || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Start Database
|
||||
####################################
|
||||
# Start the MySQL daemon in the background.
|
||||
msg_debug "Start database"
|
||||
/usr/sbin/mysqld &
|
||||
mysql_pid=$!
|
||||
|
||||
# Wait mysql start
|
||||
msg_debug "Check database is started"
|
||||
until /usr/bin/mysqladmin ping >/dev/null 2>&1
|
||||
do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
echo ""
|
||||
|
||||
####################################
|
||||
# Update root password (mysql)
|
||||
####################################
|
||||
# Initialize password root (to empty)
|
||||
msg_debug "configure password root for database"
|
||||
/usr/bin/mysqladmin -u root password '' || exit 2
|
||||
|
||||
mysql -u root -e "GRANT ALL PRIVILEGES on *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '"$(awk '{if($1 == "password"){print $3;exit 0}}' /etc/mysql/debian.cnf)"' WITH GRANT OPTION; FLUSH PRIVILEGES;" || exit 2
|
||||
|
||||
####################################
|
||||
# Stop Database
|
||||
####################################
|
||||
# Stop MySQL
|
||||
msg_debug "Stop database"
|
||||
/usr/bin/mysqladmin shutdown
|
||||
|
||||
# Wait MySQL stop
|
||||
wait $mysql_pid
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
376
dist/docker/server/debian/common/servercontainer_configure_patch.sh
vendored
Executable file
376
dist/docker/server/debian/common/servercontainer_configure_patch.sh
vendored
Executable file
|
@ -0,0 +1,376 @@
|
|||
#!/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 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
#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) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
####################################
|
||||
# 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
|
||||
|
||||
if [[ ! -f /home/gameserver/.bashrc ]]
|
||||
then
|
||||
msg_error "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 "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[@]}"
|
||||
|
||||
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 "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-data-client/data" "$PATCH_CLIENT_SYSTEM/dataserver" || exit 2
|
||||
#create_recursive_link "$KHANAT_HOME/ext/khanat-data-client/data" "$PATCH_CLIENT_SYSTEM/dataserver/data" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Copy Language
|
||||
####################################
|
||||
msg_info "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 "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 "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"
|
||||
wait_all_job || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# prepare package kh
|
||||
####################################
|
||||
msg_info "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-data-client/data/kh/*
|
||||
do
|
||||
filename=$(basename "$dir")
|
||||
msg_debug "filename:$filename"
|
||||
launch_job "(cd $KHANAT_HOME/ext/khanat-data-client/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 "Prepare package kh_shard"
|
||||
init_job
|
||||
for dir in $KHANAT_HOME/ext/khanat-data-client/data/kh_shard/*
|
||||
do
|
||||
filename=$(basename "$dir")
|
||||
msg_debug "filename:$filename"
|
||||
launch_job "(cd $KHANAT_HOME/ext/khanat-data-client/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 "Prepare package ryz"
|
||||
init_job
|
||||
for dir in $KHANAT_HOME/ext/khanat-data-client/data/ryz/*
|
||||
do
|
||||
filename=$(basename "$dir")
|
||||
msg_debug "filename:$filename"
|
||||
launch_job "(cd $KHANAT_HOME/ext/khanat-data-client/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 "Prepare package patch_client"
|
||||
init_job
|
||||
for dir in $KHANAT_HOME/ext/khanat-data-client/client/*
|
||||
do
|
||||
filename=$(basename "$dir")
|
||||
msg_debug "filename:$filename"
|
||||
launch_job "(cd $KHANAT_HOME/ext/khanat-data-client/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 "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 "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 == "</_Category>") {
|
||||
found = 2;
|
||||
print "'"$ADDREF"'";
|
||||
print $0;
|
||||
} else if(found == 2 && $1 == "</_Categories>") {
|
||||
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 "CLIENT VERSION: $KHANAT_CLIENT_VERSION"
|
||||
echo -n "$KHANAT_CLIENT_VERSION" > $PATCH_CLIENT_SYSTEM/patch_game/Lirria.version
|
||||
|
||||
####################################
|
||||
# prepare patch
|
||||
####################################
|
||||
msg_info "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"
|
||||
|
||||
# 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)
|
||||
|
||||
msg_info "CLIENT VERSION: $REALVERSION"
|
||||
cat << EOF > $PATCH_CLIENT_SYSTEM/patch_game/patch/index.php
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<h1>New test data - Release $REALVERSION</h1>
|
||||
<p>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!!
|
||||
</body>
|
||||
</html>
|
||||
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/smokey_linux64.tar.gz ]]
|
||||
then
|
||||
msg_info "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-data-client/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
|
||||
#(cd $PATCH_HOME/..; 7z a smokey_linux64.7z $DIRCLIENT)
|
||||
if [[ ! -f $HOME_CLIENT/smokey_linux64.tar.gz ]]
|
||||
then
|
||||
msg_info "Generate package"
|
||||
(cd $HOME_PREPARE_CLIENT/..; tar cfz $HOME_CLIENT/smokey_linux64.tar.gz $DIRCLIENT)
|
||||
fi
|
||||
|
||||
####################################
|
||||
# Create web page to present this package
|
||||
####################################
|
||||
msg_info "create index.html for client"
|
||||
cat << EOF > $HOME_CLIENT/index.html
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>KHANAT CLIENT</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>You can download khanat client - release $KHANAT_CLIENT_VERSION</h1>
|
||||
<a href="smokey_linux64.tar.gz">khanat client</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
279
dist/docker/server/debian/common/servercontainer_configure_world.sh
vendored
Executable file
279
dist/docker/server/debian/common/servercontainer_configure_world.sh
vendored
Executable file
|
@ -0,0 +1,279 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Configure MySQL
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
declare DEBUG=0
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
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
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/ext/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
DEBUG=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
msg_error "Missing /home/gameserver/.bashrc"
|
||||
exit 2
|
||||
fi
|
||||
source /home/gameserver/.bashrc
|
||||
|
||||
|
||||
####################################
|
||||
# Start mysql & apache
|
||||
####################################
|
||||
msg_debug "Start mysql"
|
||||
# start/restart service mysql & apache
|
||||
sudo service mysql start || exit 2
|
||||
|
||||
# Wait mysql start
|
||||
msg_debug "Check database is started"
|
||||
until /usr/bin/mysqladmin ping >/dev/null 2>&1
|
||||
do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
echo ""
|
||||
|
||||
msg_debug "start apache"
|
||||
sudo service apache2 start || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Create account
|
||||
####################################
|
||||
msg_debug "Create account"
|
||||
# Create account shard on MySQL
|
||||
mysql -u root -e "CREATE USER 'shard'@'localhost' IDENTIFIED BY '';" || exit 2
|
||||
mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'shard'@'localhost' WITH GRANT OPTION;" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# launch web configuration for khanat
|
||||
####################################
|
||||
msg_debug "launch web configuration for khanat"
|
||||
curl 'http://localhost:40916/setup/install.php' \
|
||||
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
|
||||
-H 'Accept-Language: en-US' \
|
||||
-H 'Connection: keep-alive' \
|
||||
-H 'Cookie: PHPSESSID=9jr1ssig58929bp777nrj2fa92' \
|
||||
-H 'DNT: 1' \
|
||||
-H 'Host: localhost:40916' \
|
||||
-H 'Referer: http://localhost:40916/setup/install.php' \
|
||||
-H 'Upgrade-Insecure-Requests: 1' \
|
||||
-H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data 'roleService=on'\
|
||||
'&roleSupport=on'\
|
||||
'&roleDomain=on'\
|
||||
'&privatePhpDirectory=..%2Fprivate_php%2F'\
|
||||
'&nelSetupPassword=admin'\
|
||||
'&nelSqlHostname=localhost'\
|
||||
'&nelSqlUsername=root'\
|
||||
'&nelSqlPassword='\
|
||||
'&nelDatabase=nel'\
|
||||
'&toolDatabase=nel_tool'\
|
||||
'&toolsAdminUsername=admin'\
|
||||
'&toolsAdminPassword=admin'\
|
||||
'&amsSqlHostname=localhost'\
|
||||
'&amsSqlUsername=root'\
|
||||
'&amsSqlPassword='\
|
||||
'&amsDatabase=nel_ams'\
|
||||
'&amsLibDatabase=nel_ams_lib'\
|
||||
'&amsAdminUsername=admin'\
|
||||
'&amsAdminPassword=admin'\
|
||||
'&nelDomainName=Lirria'\
|
||||
'&domainDatabase=ring_mini01'\
|
||||
'&submit=Configure' \
|
||||
-o $KHANAT_HOME/log/configure/world_setup.html || exit 2
|
||||
|
||||
chown_gameserver $KHANAT_HOME/log/configure/world_setup.html
|
||||
|
||||
# Check account is create
|
||||
grep "Domain role successfully installed" $KHANAT_HOME/log/configure/world_setup.html >/dev/null || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Get IP ADDRESS
|
||||
####################################
|
||||
msg_debug "Get IP ADDRESS"
|
||||
tmp=$(hostname -I)
|
||||
export addressip=${tmp//[[:blank:]]/}
|
||||
|
||||
|
||||
####################################
|
||||
## Configure Domain
|
||||
####################################
|
||||
msg_debug "Configure Domain"
|
||||
mysql -u root -e "use nel;
|
||||
INSERT INTO nel.domain (domain_id, domain_name, status, patch_version, backup_patch_url, patch_urls, login_address, session_manager_address, ring_db_name, web_host, web_host_php, description) VALUES ('12', 'Lirria', 'ds_open', '$KHANAT_CLIENT_VERSION', '$addressip:23001', '$addressip/patch', '$addressip:49998', '$addressip:49999', 'ring_mini01', '$addressip:30000', '$addressip:40916', NULL);" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Configure nel.shard
|
||||
####################################
|
||||
msg_debug "Configure nel.shard"
|
||||
mysql -u root -e "use nel;
|
||||
INSERT INTO nel.shard (ShardId, domain_id, WsAddr, NbPlayers, Name, Online, Version, FixedSessionId, State, MOTD) VALUES ('302', '12', '$addressip:', '0', 'Lirria shard', '0', '', '0', 'ds_open', '');" || exit 2
|
||||
|
||||
####################################
|
||||
# Configure nel_tool.neltool_domains
|
||||
####################################
|
||||
msg_debug "Configure nel_tool.neltool_domains"
|
||||
mysql -u root -e "use nel;
|
||||
INSERT INTO nel_tool.neltool_domains (domain_id, domain_name, domain_as_host, domain_as_port, domain_rrd_path, domain_las_admin_path, domain_las_local_path, domain_application, domain_sql_string, domain_hd_check, domain_mfs_web, domain_cs_sql_string) VALUES ('12', 'Lirria', '$addressip', '46700', '/home/gameserver/khanat/server/save_shard/rrd_graphs', '', '', 'ryzom_open', '', '0', NULL, NULL);" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# configure nel_tool.neltool_shards
|
||||
####################################
|
||||
msg_debug "Configure nel_tool.neltool_shards"
|
||||
mysql -u root -e "use nel;
|
||||
INSERT INTO nel_tool.neltool_shards (shard_id, shard_name, shard_as_id, shard_domain_id, shard_lang, shard_restart) VALUES ('302', 'open', 'open', '12', 'fr', '0');" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# configure nel_tool.neltool_user_domains
|
||||
####################################
|
||||
msg_debug "Configure nel_tool.neltool_user_domains"
|
||||
mysql -u root -e "use nel;
|
||||
INSERT INTO nel_tool.neltool_user_domains (user_domain_id, user_domain_user_id, user_domain_domain_id) VALUES ('1', '1', '12');" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# configure nel_tool.neltool_user_shards
|
||||
####################################
|
||||
msg_debug "Configure nel_tool.neltool_user_shards"
|
||||
mysql -u root -e "use nel;
|
||||
INSERT INTO nel_tool.neltool_user_shards (user_shard_id, user_shard_user_id, user_shard_shard_id, user_shard_domain_id) VALUES ('1', '1', '302', '12');" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# configure ring_mini01.sessions
|
||||
####################################
|
||||
msg_debug "Configure ring_mini01.sessions"
|
||||
mysql -u root -e "use ring_mini01;
|
||||
INSERT INTO ring_mini01.sessions (session_id, session_type, title, owner, plan_date, start_date, description, orientation, level, rule_type, access_type, state, host_shard_id, subscription_slots, reserved_slots, free_slots, estimated_duration, final_duration, folder_id, lang, icone, anim_mode, race_filter, religion_filter, guild_filter, shard_filter, level_filter, subscription_closed, newcomer) VALUES ('302', 'st_mainland', '', '0', '2005-09-21 12:41:33.000000', '2005-08-31 00:00:00.000000', '', 'so_other', 'sl_a', 'rt_strict', 'at_private', 'ss_planned', '0', '0', '0', '0', 'et_short', '0', '0', '', '', 'am_dm', '', '', 'gf_only_my_guild', 'sf_shard00,sf_shard01,sf_shard02,sf_shard03,sf_shard04,sf_shard05,sf_shard06,sf_shard07,sf_shard08,sf_shard09,sf_shard10,sf_shard11,sf_shard12,sf_shard13,sf_shard14,sf_shard15,sf_shard16,sf_shard17,sf_shard18,sf_shard19,sf_shard20,sf_shard21,sf_shard22,sf_shard23,sf_shard24,sf_shard25,sf_shard26,sf_shard27,sf_shard28,sf_shard29,sf_shard30', 'lf_a,lf_b,lf_c,lf_d,lf_e,lf_f', '0', '0');" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
## Create one user 'tester' (password : tester)
|
||||
####################################
|
||||
msg_debug "Create one user"
|
||||
declare accountuser="tester"
|
||||
declare passworduser="tester"
|
||||
curl 'http://localhost:40916/ams/index.php' \
|
||||
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' \
|
||||
-H 'Accept-Language: en-US' \
|
||||
-H 'Connection: keep-alive' \
|
||||
-H 'Cookie: PHPSESSID=lsoumn9f0ljgm3vo3hgjdead03' \
|
||||
-H 'DNT: 1' \
|
||||
-H 'Host: localhost:40916' \
|
||||
-H 'Referer: http://localhost:40916/ams/index.php?page=register' \
|
||||
-H 'Upgrade-Insecure-Requests: 1' \
|
||||
-H 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:6.0) Gecko/20100101 Firefox/6.0' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data 'Username='"$accountuser"'&Password='"$passworduser"'&ConfirmPass=tester&Email=tester%40khaganat.net&TaC=on&function=add_user' \
|
||||
-o $KHANAT_HOME/log/configure/world_account_tester.log || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# configure nel.permission
|
||||
####################################
|
||||
msg_debug "Create nel.permission"
|
||||
mysql -u root -e "use nel;
|
||||
UPDATE nel.permission SET AccessPrivilege = 'OPEN,DEV,RESTRICTED';
|
||||
" || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# Stop Database & apache
|
||||
####################################
|
||||
msg_debug "Stop Database & apache"
|
||||
# start/restart service mysql & apache
|
||||
sudo service apache2 stop || exit 2
|
||||
sudo service mysql stop || exit 2
|
||||
|
||||
# Change right for file mysql
|
||||
# TODO - remove creation of this file
|
||||
chown_gameserver "$KHANAT_HOME/database/mysql_upgrade_info"
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
230
dist/docker/server/debian/common/servercontainer_function.sh
vendored
Executable file
230
dist/docker/server/debian/common/servercontainer_function.sh
vendored
Executable file
|
@ -0,0 +1,230 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Function use in preparation & configuration
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
######################
|
||||
# Write output
|
||||
######################
|
||||
declare -i DEBUG=0
|
||||
|
||||
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 set_debug()
|
||||
{
|
||||
if [[ -n "$1" ]]
|
||||
then
|
||||
DEBUG=$1
|
||||
else
|
||||
DEBUG=0
|
||||
fi
|
||||
}
|
||||
|
||||
######################
|
||||
# function to change owner for gameserver
|
||||
######################
|
||||
function chown_gameserver()
|
||||
{
|
||||
# gameserver:$(id -g -n gameserver)
|
||||
chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
|
||||
}
|
||||
|
||||
######################
|
||||
# function duplicate/link file
|
||||
######################
|
||||
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_gameserver "$1" || exit 2
|
||||
}
|
||||
|
||||
function create_link()
|
||||
{
|
||||
if [[ -z "$1" ]]
|
||||
then
|
||||
msg_error "Missing 1st argument (source)"
|
||||
exit 2
|
||||
fi
|
||||
if [[ -z "$2" ]]
|
||||
then
|
||||
msg_error "Missing 2nd argument (destination)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
filename_l=$(basename "$1")
|
||||
|
||||
msg_debug "create link $2/$filename_l"
|
||||
if [ -e "$2/$filename_l" ]
|
||||
then
|
||||
rm "$2/$filename_l" || exit 2
|
||||
elif [ -h "$2/$filename_l" ]
|
||||
then
|
||||
rm "$2/$filename_l" || exit 2
|
||||
fi
|
||||
if [[ (! -e "$1") && (! -h "$1") ]]
|
||||
then
|
||||
msg_error "Missing source : '$1'"
|
||||
exit 2
|
||||
fi
|
||||
ln -s "$1" "$2/$filename_l" || exit 2
|
||||
chown --no-dereference $UIDGAMESERVER:$GIDGAMESERVER "$2/$filename_l" || exit 2
|
||||
}
|
||||
|
||||
function create_recursive_link()
|
||||
{
|
||||
if [[ -z "$1" ]]
|
||||
then
|
||||
msg_error "Missing 1st argument (source)"
|
||||
exit 2
|
||||
fi
|
||||
if [[ -z "$2" ]]
|
||||
then
|
||||
msg_error "Missing 2nd argument (destination)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
msg_debug "link $1 -> $2"
|
||||
for file in $1/*
|
||||
do
|
||||
if [ -d "$file" ]
|
||||
then
|
||||
filename=$(basename "$file")
|
||||
msg_debug "create dir $2/$filename"
|
||||
if [ ! -f "$2/$filename" ]
|
||||
then
|
||||
mkdir -p "$2/$filename" || exit 2
|
||||
fi
|
||||
chown $UIDGAMESERVER:$GIDGAMESERVER "$2/$filename" || exit 2
|
||||
create_recursive_link "$file" "$2/$filename" || exit 2
|
||||
else
|
||||
create_link "$file" "$2" || exit 2
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function create_link_2nd_level()
|
||||
{
|
||||
# Function to create link
|
||||
if [[ -z "$1" ]]
|
||||
then
|
||||
msg_error "Missing 1st argument (source)"
|
||||
exit 2
|
||||
fi
|
||||
if [[ -z "$2" ]]
|
||||
then
|
||||
msg_error "Missing 2nd argument (destination)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
for file in $1
|
||||
do
|
||||
create_link "$file" "$2" || exit 2
|
||||
done
|
||||
}
|
||||
|
||||
function create_dir_gameserver()
|
||||
{
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
msg_error "Missing 1st argument (source)"
|
||||
exit 2
|
||||
fi
|
||||
mkdir -p "$1" || exit 2
|
||||
chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
|
||||
}
|
||||
|
||||
function create_file_gameserver()
|
||||
{
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
msg_error "Missing 1st argument (source)"
|
||||
exit 2
|
||||
fi
|
||||
touch "$1" || exit 2
|
||||
chown $UIDGAMESERVER:$GIDGAMESERVER "$1" || exit 2
|
||||
}
|
||||
|
||||
######################
|
||||
### Manage multi process
|
||||
######################
|
||||
declare -A JOBS
|
||||
declare -A COMMENTJOBS
|
||||
|
||||
function init_job()
|
||||
{
|
||||
unset JOBS
|
||||
unset COMMENTJOBS
|
||||
}
|
||||
|
||||
function launch_job()
|
||||
{
|
||||
msg_debug "Launch job '$2'"
|
||||
eval $1 &
|
||||
JOBS[$!]="$1"
|
||||
COMMENTJOBS[$!]="$2"
|
||||
}
|
||||
|
||||
function wait_all_job()
|
||||
{
|
||||
local cmd
|
||||
local code=0
|
||||
for pid in ${!JOBS[@]}
|
||||
do
|
||||
msg_debug "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}']"
|
||||
fi
|
||||
done
|
||||
return $code
|
||||
}
|
||||
|
||||
######################
|
||||
#
|
||||
######################
|
221
dist/docker/server/debian/common/servercontainer_init_apache.sh
vendored
Executable file
221
dist/docker/server/debian/common/servercontainer_init_apache.sh
vendored
Executable file
|
@ -0,0 +1,221 @@
|
|||
#!/bin/bash
|
||||
# Prepare/Configure Apache
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
|
||||
####################################
|
||||
# Configure apache log / Account use by apache
|
||||
####################################
|
||||
msg_debug "Configure apache log / Account use by apache"
|
||||
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
|
||||
sed -i -r 's/^LogLevel[[:space:]]+warn/LogLevel debug/g' /etc/apache2/apache2.conf || exit 2
|
||||
|
||||
|
||||
|
||||
####################################
|
||||
# configure phpmyadmin
|
||||
####################################
|
||||
msg_debug "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
|
||||
awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2
|
||||
|
||||
|
||||
####################################
|
||||
# configure phpmyadmin
|
||||
####################################
|
||||
msg_debug "configure apache"
|
||||
# configure apache
|
||||
cat << EOF > /etc/apache2/sites-available/000-default.conf
|
||||
# Default
|
||||
<VirtualHost *:80>
|
||||
<Directory "/home/gameserver/khanat/khanatweb/">
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
DirectoryIndex index.php
|
||||
AddType text/html .php .phps
|
||||
AddHandler application/x-httpd-php .php
|
||||
AddHandler application/x-httpd-php-source .phps
|
||||
</Directory>
|
||||
ServerName lirria.khaganat.net
|
||||
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /home/gameserver/khanat/khanatweb/public_php/
|
||||
|
||||
ErrorLog \${APACHE_LOG_DIR}/error.log
|
||||
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
|
||||
# Khanat Server Web
|
||||
<VirtualHost *:40916>
|
||||
<Directory "/home/gameserver/khanat/khanatweb/">
|
||||
Options Indexes FollowSymLinks
|
||||
AllowOverride None
|
||||
Require all granted
|
||||
</Directory>
|
||||
ServerName lirria.khaganat.net
|
||||
|
||||
ServerAdmin admin@localhost
|
||||
DocumentRoot /home/gameserver/khanat/khanatweb/public_php
|
||||
|
||||
ErrorLog \${APACHE_LOG_DIR}/error.log
|
||||
CustomLog \${APACHE_LOG_DIR}/access.log combined
|
||||
</VirtualHost>
|
||||
|
||||
# Patch Server
|
||||
<VirtualHost *:43435>
|
||||
ServerName lirria.khaganat.net
|
||||
DocumentRoot /home/gameserver/khanat/patch_service/patch_game/patch/
|
||||
|
||||
<Directory "/home/gameserver/khanat/patch_service/patch_game/patch">
|
||||
Options -Indexes
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
EOF
|
||||
|
||||
# Open port use by apache
|
||||
cat << EOF > /etc/apache2/ports.conf
|
||||
# If you just change the port or add more ports here, you will likely also
|
||||
# have to change the VirtualHost statement in
|
||||
# /etc/apache2/sites-enabled/000-default.conf
|
||||
|
||||
Listen 80
|
||||
Listen 40916
|
||||
Listen 43435
|
||||
|
||||
<IfModule ssl_module>
|
||||
Listen 443
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_gnutls.c>
|
||||
Listen 443
|
||||
</IfModule>
|
||||
|
||||
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
|
||||
EOF
|
||||
|
||||
|
||||
# Activate php - strange beacause we have only index.php (without php code !)
|
||||
cat << EOF > /etc/apache2/conf-available/patch_service.conf
|
||||
Alias /patch /home/gameserver/khanat/patch_service/patch_game/patch
|
||||
<Directory /home/gameserver/khanat/patch_service/patch_game/patch>
|
||||
Options FollowSymLinks
|
||||
DirectoryIndex index.php
|
||||
|
||||
Require all granted
|
||||
|
||||
<IfModule mod_php5.c>
|
||||
<IfModule mod_mime.c>
|
||||
AddType application/x-httpd-php .php
|
||||
</IfModule>
|
||||
<FilesMatch ".+\.php$">
|
||||
SetHandler application/x-httpd-php
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
</Directory>
|
||||
EOF
|
||||
|
||||
# Configuration de la page client
|
||||
cat << EOF > /etc/apache2/conf-available/client_service.conf
|
||||
Alias /client /home/gameserver/khanat/client_service
|
||||
<Directory /home/gameserver/khanat/client_service>
|
||||
Options FollowSymLinks
|
||||
DirectoryIndex index.html
|
||||
|
||||
Require all granted
|
||||
<IfModule mod_php5.c>
|
||||
<IfModule mod_mime.c>
|
||||
AddType application/tar .tar.gz
|
||||
</IfModule>
|
||||
<FilesMatch ".+\.php$">
|
||||
SetHandler application/tar
|
||||
</FilesMatch>
|
||||
</IfModule>
|
||||
</Directory>
|
||||
EOF
|
||||
|
||||
####################################
|
||||
# Activate web site
|
||||
####################################
|
||||
|
||||
msg_info "Activate patch service"
|
||||
# Activate & deploy new configuration
|
||||
a2enconf patch_service.conf
|
||||
|
||||
msg_info "Activate client service"
|
||||
# Activate & deploy new configuration
|
||||
a2enconf client_service.conf
|
||||
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Install all package we need to prepare and install khanat server
|
||||
#
|
||||
# Configure environment
|
||||
#
|
||||
# Copyright (C) 2017 AleaJactaEst
|
||||
#
|
||||
|
@ -16,52 +17,129 @@
|
|||
# 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 "Start Basic"
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
####################################
|
||||
# Install some package for server (apache, mysql, screen)
|
||||
####################################
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server
|
||||
apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick rrdtool screen mcrypt php5-mcrypt
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
####################################
|
||||
# Initialize database
|
||||
####################################
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
/usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
|
||||
|
||||
# Start the MySQL daemon in the background.
|
||||
/usr/sbin/mysqld &
|
||||
mysql_pid=$!
|
||||
|
||||
# Wait mysql start
|
||||
until /usr/bin/mysqladmin ping >/dev/null 2>&1
|
||||
while test $# -gt 0
|
||||
do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Initialize password root (to empty)
|
||||
/usr/bin/mysqladmin -u root password '' || exit 2
|
||||
msg_info "configure shard.sh"
|
||||
|
||||
# Adding phpmyadmin
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
||||
####################################
|
||||
# configure shard.sh
|
||||
####################################
|
||||
cat << EOF > /opt/shard.sh
|
||||
# bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
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
|
||||
awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2
|
||||
# You may uncomment the following lines if you want 'ls' to be colorized:
|
||||
export SHELL=/bin/bash
|
||||
export LS_OPTIONS='--color=auto'
|
||||
eval "\`dircolors\`"
|
||||
alias ls='ls \$LS_OPTIONS'
|
||||
alias ll='ls \$LS_OPTIONS -l'
|
||||
alias l='ls \$LS_OPTIONS -lA'
|
||||
|
||||
# Some more alias to avoid making mistakes:
|
||||
# alias rm='rm -i'
|
||||
# alias cp='cp -i'
|
||||
# alias mv='mv -i'
|
||||
|
||||
# Autocompletion
|
||||
if [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
|
||||
export KHANAT_HOME=/home/gameserver
|
||||
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 PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT"
|
||||
export CLIENT_DIR="khanat/client_service"
|
||||
export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR"
|
||||
export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR"
|
||||
EOF
|
||||
|
||||
|
||||
# Stop MySQL
|
||||
/usr/bin/mysqladmin shutdown
|
||||
####################################
|
||||
# Initialize bashrc gameserver
|
||||
####################################
|
||||
msg_info "configure bashrc"
|
||||
cat << EOF > /home/gameserver/.bashrc
|
||||
# bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
# Wait MySQL stop
|
||||
wait $mysql_pid
|
||||
# You may uncomment the following lines if you want 'ls' to be colorized:
|
||||
export SHELL=/bin/bash
|
||||
export LS_OPTIONS='--color=auto'
|
||||
eval "\`dircolors\`"
|
||||
alias ls='ls \$LS_OPTIONS'
|
||||
alias ll='ls \$LS_OPTIONS -l'
|
||||
alias l='ls \$LS_OPTIONS -lA'
|
||||
|
||||
# Some more alias to avoid making mistakes:
|
||||
# alias rm='rm -i'
|
||||
# alias cp='cp -i'
|
||||
# alias mv='mv -i'
|
||||
|
||||
# Autocompletion
|
||||
if [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
|
||||
export KHANAT_HOME=/home/gameserver
|
||||
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 PREPARE_CLIENT_DIR="khanat/prepare_client/\$DIRCLIENT"
|
||||
export CLIENT_DIR="khanat/client_service"
|
||||
export HOME_PREPARE_CLIENT="\$KHANAT_HOME/\$PREPARE_CLIENT_DIR"
|
||||
export HOME_CLIENT="\$KHANAT_HOME/\$CLIENT_DIR"
|
||||
|
||||
EOF
|
||||
chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc
|
||||
|
||||
|
||||
# load environment
|
||||
source /home/gameserver/.bashrc
|
||||
|
||||
####################################
|
||||
# Initialize bashrc (for root)
|
||||
####################################
|
||||
msg_debug "Configure bashrc (for root)"
|
||||
cat << EOF > /root/.bashrc
|
||||
# bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
|
@ -84,37 +162,12 @@ if [ -f /etc/bash_completion ]; then
|
|||
fi
|
||||
EOF
|
||||
|
||||
####################################
|
||||
# Initialize bashrc (for gameserver)
|
||||
####################################
|
||||
cat << EOF > /home/gameserver/.bashrc
|
||||
# bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
# You may uncomment the following lines if you want 'ls' to be colorized:
|
||||
export SHELL=/bin/bash
|
||||
export LS_OPTIONS='--color=auto'
|
||||
eval "\`dircolors\`"
|
||||
alias ls='ls \$LS_OPTIONS'
|
||||
alias ll='ls \$LS_OPTIONS -l'
|
||||
alias l='ls \$LS_OPTIONS -lA'
|
||||
|
||||
# Some more alias to avoid making mistakes:
|
||||
# alias rm='rm -i'
|
||||
# alias cp='cp -i'
|
||||
# alias mv='mv -i'
|
||||
|
||||
# Autocompletion
|
||||
if [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
EOF
|
||||
chown gameserver:gameserver /home/gameserver/.bashrc
|
||||
|
||||
####################################
|
||||
# Adding sudo command
|
||||
####################################
|
||||
|
||||
# Update sudo rule (you can execute all command as root)
|
||||
msg_debug "Configure sudo"
|
||||
cat << EOF > /etc/sudoers.d/gameserver
|
||||
# User privilege specification
|
||||
gameserver ALL=NOPASSWD: ALL
|
||||
|
@ -126,6 +179,7 @@ EOF
|
|||
# Message see when connect on ssh
|
||||
|
||||
# Before login
|
||||
msg_debug "Configure message login"
|
||||
cat << EOF > /etc/issue.net
|
||||
*********************
|
||||
* KHANAT SERVER DEV *
|
||||
|
@ -137,6 +191,7 @@ password khanat
|
|||
EOF
|
||||
|
||||
# After Login
|
||||
msg_debug "Configure banner"
|
||||
cat << EOF > /etc/motd
|
||||
***************************************************
|
||||
connect to root use gameserver account and launch sudo command
|
||||
|
@ -152,9 +207,14 @@ log khanat server : /home/gameserver/khanat/server/log/log.log
|
|||
EOF
|
||||
|
||||
# Activate banner
|
||||
msg_debug "Activate banner"
|
||||
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
|
||||
|
||||
|
||||
# Initialize ssh
|
||||
/etc/init.d/ssh restart
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
echo "End Basic"
|
||||
msg_info "$(basename $0) => END"
|
82
dist/docker/server/debian/common/servercontainer_init_create_account.sh
vendored
Executable file
82
dist/docker/server/debian/common/servercontainer_init_create_account.sh
vendored
Executable file
|
@ -0,0 +1,82 @@
|
|||
#!/bin/bash
|
||||
# Create account gameserver
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
create account gameserver
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
####################################
|
||||
# Configure account gameserver
|
||||
####################################
|
||||
msg_debug "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
|
||||
msg_debug "group : $(id -g -n gameserver)"
|
||||
|
||||
create_dir_gameserver '/home/gameserver/ext'
|
||||
create_dir_gameserver '/home/gameserver/khanat'
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
90
dist/docker/server/debian/common/servercontainer_init_mysql.sh
vendored
Executable file
90
dist/docker/server/debian/common/servercontainer_init_mysql.sh
vendored
Executable file
|
@ -0,0 +1,90 @@
|
|||
#!/bin/bash
|
||||
# Prepare/Configure MySQL
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
msg_debug "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
|
||||
sed -i -r 's/^log_error[[:space:]]+=[[:space:]]+(.*)/log_error = \/home\/gameserver\/log\/mysql\/error\.log/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)general_log_file[[:space:]]+=(.*)/general_log_file = \/home\/gameserver\/log\/mysql\/mysql\.log/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)general_log[[:space:]]+=(.*)/general_log = 1/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)slow_query_log_file[[:space:]]+=(.*)/slow_query_log_file = \/home\/gameserver\/log\/mysql\/mysql-slow\.log/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' /etc/mysql/my.cnf || exit 2
|
||||
|
||||
mkdir -p /home/gameserver/database/ || exit 2
|
||||
chown gameserver:$(id -g -n gameserver) /home/gameserver/database/ || exit 2
|
||||
|
||||
mkdir -p /home/gameserver/log/mysql || exit 2
|
||||
chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
|
||||
|
||||
chown gameserver:$(id -g -n gameserver) /var/run/mysqld/ || exit 2
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
66
dist/docker/server/debian/common/servercontainer_init_package.sh
vendored
Executable file
66
dist/docker/server/debian/common/servercontainer_init_package.sh
vendored
Executable file
|
@ -0,0 +1,66 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Install binary and data
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
prepare mysql (create directory, update configuration)
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
#####################
|
||||
# MAIN
|
||||
#####################
|
||||
source /opt/servercontainer_function.sh
|
||||
msg_info "$(basename $0) => START"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
set_debug 1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# install new package
|
||||
cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || exit 2
|
||||
# Install data ref (web server, ...)
|
||||
cd /opt; tar xzf khanat-ref-ressources.tar.gz || exit 2
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "$(basename $0) => END"
|
||||
|
267
dist/docker/server/debian/common/servercontainer_launch_auto.sh
vendored
Executable file
267
dist/docker/server/debian/common/servercontainer_launch_auto.sh
vendored
Executable file
|
@ -0,0 +1,267 @@
|
|||
#!/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 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
Prepare and launch server khanat
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
--start-khanat-with-screen : start with screen
|
||||
--show-khanat-log : Show khanat log (after start)
|
||||
--show-all-log : Show all log (after start) [apache, mysql, khanat]
|
||||
--show-status-nagios : show status (ater start)
|
||||
--show-status : show status (ater start)
|
||||
--bash-after-start : command bash after start
|
||||
EOF
|
||||
}
|
||||
|
||||
status_program()
|
||||
{
|
||||
pid=$(cat /home/gameserver/khanat/server/$1/$1.pid)
|
||||
ps -p $pid >/dev/null
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
pidstate="ok"
|
||||
else
|
||||
pidstate="ko"
|
||||
fi
|
||||
state=$(cat /home/gameserver/khanat/server/$1/$1.state)
|
||||
echo "$1 $2 [$state] pid:$pid => $pidstate"
|
||||
}
|
||||
|
||||
status_all()
|
||||
{
|
||||
# aes : admin_executor_service.log
|
||||
status_program 'aes' 'ryzom_admin_service'
|
||||
|
||||
# bms_master : backup_service.log
|
||||
status_program 'bms_master' 'ryzom_backup_service'
|
||||
|
||||
# bms_pd_master
|
||||
# status_program 'bms_pd_master' 'ryzom_backup_service'
|
||||
|
||||
# egs : entities_game_service.log
|
||||
status_program 'egs' 'ryzom_entities_game_service'
|
||||
|
||||
# gpms : gpm_service.log
|
||||
status_program 'gpms' 'ryzom_gpm_service'
|
||||
|
||||
# ios : input_output_service.log
|
||||
status_program 'ios' 'ryzom_ios_service'
|
||||
|
||||
# rns : naming_service.log
|
||||
status_program 'rns' 'ryzom_naming_service'
|
||||
|
||||
# rws : welcome_service.log
|
||||
status_program 'rws' 'ryzom_welcome_service'
|
||||
|
||||
# ts : tick_service.log
|
||||
status_program 'ts' 'ryzom_tick_service'
|
||||
|
||||
# ms : mirror_service.log
|
||||
status_program 'ms' 'ryzom_mirror_service'
|
||||
|
||||
# ais_newbyland : ai_service.log
|
||||
status_program 'ais_newbyland' 'ryzom_ai_service'
|
||||
|
||||
# mfs : mail_forum_service.log
|
||||
status_program 'mfs' 'ryzom_mail_forum_service'
|
||||
|
||||
# su : shard_unifier_service.log
|
||||
status_program 'su' 'ryzom_shard_unifier_service'
|
||||
|
||||
# fes : frontend_service.log
|
||||
status_program 'fes' 'ryzom_frontend_service'
|
||||
|
||||
# sbs : session_browser_server.log
|
||||
status_program 'sbs' 'ryzom_session_browser_service'
|
||||
|
||||
# lgs : logger_service.log
|
||||
status_program 'lgs' 'ryzom_logger_service'
|
||||
|
||||
# mos
|
||||
# status_program 'mos' 'ryzom_monitor_service'
|
||||
|
||||
# pdss
|
||||
#status_program 'pdss' 'ryzom_pd_support_service'
|
||||
|
||||
# ras : admin_service.log
|
||||
status_program 'ras' 'ryzom_admin_service'
|
||||
}
|
||||
|
||||
#####################
|
||||
# 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
|
||||
;;
|
||||
--start-khanat-with-screen)
|
||||
METHOD_START=0
|
||||
shift
|
||||
;;
|
||||
--show-khanat-log)
|
||||
METHOD_START=1
|
||||
shift
|
||||
;;
|
||||
--show-all-log)
|
||||
METHOD_START=3
|
||||
shift
|
||||
;;
|
||||
--show-status-nagios)
|
||||
METHOD_START=2
|
||||
shift
|
||||
;;
|
||||
--show-status)
|
||||
METHOD_START=4
|
||||
shift
|
||||
;;
|
||||
--bash-after-start)
|
||||
METHOD_START=5
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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:]]/}
|
||||
sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
|
||||
|
||||
|
||||
#####################
|
||||
# Reconfigure database
|
||||
#####################
|
||||
msg_debug "Reconfigure database"
|
||||
## Configure Domain
|
||||
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
|
||||
mysql -u root -e "use nel;
|
||||
UPDATE nel.shard
|
||||
SET WsAddr = '$addressip:'
|
||||
WHERE ShardId = 302;" || exit 2
|
||||
|
||||
# Configure nel_tool.neltool_domains
|
||||
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"
|
||||
if [[ $METHOD_START -eq 0 ]]
|
||||
then
|
||||
source /home/gameserver/.bashrc; export RYZOM_PATH=$KHANAT_PATH; echo ".$RYZOM_PATH."; $KHANAT_HOME/khanat/tools/scripts/linux/shard start
|
||||
elif [[ $METHOD_START -eq 1 ]]
|
||||
then
|
||||
su -c /opt/ext/servercontainer_launch_service.sh gameserver
|
||||
sleep 10
|
||||
tail -n+0 -f /home/gameserver/log/khanat/log.log
|
||||
elif [[ $METHOD_START -eq 2 ]]
|
||||
then
|
||||
su -c /opt/ext/servercontainer_launch_service.sh gameserver
|
||||
sleep 10
|
||||
watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
|
||||
elif [[ $METHOD_START -eq 3 ]]
|
||||
then
|
||||
su -c /opt/ext/servercontainer_launch_service.sh gameserver
|
||||
sleep 10
|
||||
tail -n+0 -f /home/gameserver/log/apache2/* /home/gameserver/log/mysql/* /home/gameserver/log/khanat/*
|
||||
elif [[ $METHOD_START -eq 4 ]]
|
||||
then
|
||||
su -c /opt/ext/servercontainer_launch_service.sh gameserver
|
||||
sleep 10
|
||||
watch /opt/ext/servercontainer_launch_status.sh --no-color
|
||||
elif [[ $METHOD_START -eq 5 ]]
|
||||
then
|
||||
#su -c /opt/ext/servercontainer_launch_service.sh gameserver
|
||||
#sleep 10
|
||||
bash
|
||||
else
|
||||
msg_error 'Bad option'
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
######################
|
||||
#
|
||||
######################
|
168
dist/docker/server/debian/common/servercontainer_launch_service.sh
vendored
Executable file
168
dist/docker/server/debian/common/servercontainer_launch_service.sh
vendored
Executable file
|
@ -0,0 +1,168 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to launch khaganat
|
||||
# (see shard.screen.rc)
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
Script to launch khaganat
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
EOF
|
||||
}
|
||||
|
||||
function start_stop()
|
||||
{
|
||||
nameservice=$1
|
||||
printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
|
||||
chown_gameserver /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
|
||||
nohup $2
|
||||
printf STOPPED > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
|
||||
}
|
||||
|
||||
function launch_service()
|
||||
{
|
||||
nameservice=$1
|
||||
|
||||
create_dir_gameserver "/home/gameserver/khanat/server/${nameservice}"
|
||||
create_file_gameserver "/home/gameserver/khanat/server/$1/$1.pid"
|
||||
create_file_gameserver "/home/gameserver/log/khanat/$nameservice.out"
|
||||
create_file_gameserver "/home/gameserver/log/khanat/$nameservice.err"
|
||||
|
||||
start_stop "$1" "$2" 1>/home/gameserver/log/khanat/$nameservice.out 2>/home/gameserver/log/khanat/$nameservice.err &
|
||||
echo "$!" > /home/gameserver/khanat/server/$1/$1.pid
|
||||
#nohup $2 1>/dev/null 2>&1 &
|
||||
#echo "$!" > /home/gameserver/khanat/server/$1.pid
|
||||
#printf RUNNING > /home/gameserver/khanat/server/${nameservice}/${nameservice}.state
|
||||
}
|
||||
|
||||
#####################
|
||||
# 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
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
|
||||
####################################
|
||||
# Load Environment
|
||||
####################################
|
||||
create_dir_gameserver '/home/gameserver/log/khanat'
|
||||
cd /home/gameserver/log/khanat
|
||||
|
||||
# aes : admin_executor_service.log
|
||||
launch_service 'aes' 'ryzom_admin_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --fulladminname=admin_executor_service --shortadminname=AES'
|
||||
|
||||
# bms_master : backup_service.log
|
||||
launch_service 'bms_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -P49990'
|
||||
|
||||
# bms_pd_master
|
||||
# launch_service 'bms_pd_master' 'ryzom_backup_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -P49992'
|
||||
|
||||
# egs : entities_game_service.log
|
||||
launch_service 'egs' 'ryzom_entities_game_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# gpms : gpm_service.log
|
||||
launch_service 'gpms' 'ryzom_gpm_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# ios : input_output_service.log
|
||||
launch_service 'ios' 'ryzom_ios_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# rns : naming_service.log
|
||||
launch_service 'rns' 'ryzom_naming_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# rws : welcome_service.log
|
||||
launch_service 'rws' 'ryzom_welcome_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# ts : tick_service.log
|
||||
launch_service 'ts' 'ryzom_tick_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# ms : mirror_service.log
|
||||
launch_service 'ms' 'ryzom_mirror_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# ais_newbyland : ai_service.log
|
||||
launch_service 'ais_newbyland' 'ryzom_ai_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid -mCommon:Newbieland:Post'
|
||||
|
||||
# mfs : mail_forum_service.log
|
||||
launch_service 'mfs' 'ryzom_mail_forum_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# su : shard_unifier_service.log
|
||||
launch_service 'su' 'ryzom_shard_unifier_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# fes : frontend_service.log
|
||||
launch_service 'fes' 'ryzom_frontend_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# sbs : session_browser_server.log
|
||||
launch_service 'sbs' 'ryzom_session_browser_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# lgs : logger_service.log
|
||||
launch_service 'lgs' 'ryzom_logger_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# mos
|
||||
# launch_service 'mos' 'ryzom_monitor_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# pdss
|
||||
#launch_service 'pdss' 'ryzom_pd_support_service -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
# ras : admin_service.log
|
||||
launch_service 'ras' 'ryzom_admin_service --fulladminname=admin_service --shortadminname=AS -A/home/gameserver/khanat/server -C/home/gameserver/khanat/server -L/home/gameserver/log/khanat --nobreak --writepid'
|
||||
|
||||
|
||||
######################
|
||||
#
|
||||
######################
|
175
dist/docker/server/debian/common/servercontainer_launch_status.sh
vendored
Executable file
175
dist/docker/server/debian/common/servercontainer_launch_status.sh
vendored
Executable file
|
@ -0,0 +1,175 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to get status all process khanat
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
declare NOCOLOR=0
|
||||
declare RED=""
|
||||
declare GREEN=""
|
||||
declare NORMAL=""
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
Script to launch khaganat
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
-n, --no-color : disable color
|
||||
EOF
|
||||
}
|
||||
|
||||
status_program()
|
||||
{
|
||||
name=$1
|
||||
printf "%15s %-30s" "$1" "$2"
|
||||
color=""
|
||||
color2=""
|
||||
|
||||
pid=$(cat /home/gameserver/khanat/server/$1/$1.pid 2>/dev/null)
|
||||
if [[ -n "$pid" ]]
|
||||
then
|
||||
ps -p $pid >/dev/null
|
||||
if [[ $? -eq 0 ]]
|
||||
then
|
||||
pidstate=" ok "
|
||||
color=$GREEN
|
||||
else
|
||||
pidstate="*ko*"
|
||||
color=$RED
|
||||
fi
|
||||
else
|
||||
pidstate="*ko*"
|
||||
color=$RED
|
||||
fi
|
||||
printf " pid:%-8s %4s" "$pid" "${color}${pidstate}${NORMAL}"
|
||||
|
||||
state=$(cat /home/gameserver/khanat/server/$1/$1.state 2>/dev/null)
|
||||
if [[ -n "$state" ]]
|
||||
then
|
||||
if [[ "$state" == "RUNNING" ]]
|
||||
then
|
||||
color2=$GREEN
|
||||
else
|
||||
color2=$RED
|
||||
fi
|
||||
else
|
||||
state="NOT STARTED"
|
||||
color2=$RED
|
||||
fi
|
||||
printf " %s\n" "${color2}[${state}]${NORMAL}"
|
||||
}
|
||||
|
||||
status_all()
|
||||
{
|
||||
# aes : admin_executor_service.log
|
||||
status_program 'aes' 'ryzom_admin_service'
|
||||
|
||||
# bms_master : backup_service.log
|
||||
status_program 'bms_master' 'ryzom_backup_service'
|
||||
|
||||
# bms_pd_master
|
||||
# status_program 'bms_pd_master' 'ryzom_backup_service'
|
||||
|
||||
# egs : entities_game_service.log
|
||||
status_program 'egs' 'ryzom_entities_game_service'
|
||||
|
||||
# gpms : gpm_service.log
|
||||
status_program 'gpms' 'ryzom_gpm_service'
|
||||
|
||||
# ios : input_output_service.log
|
||||
status_program 'ios' 'ryzom_ios_service'
|
||||
|
||||
# rns : naming_service.log
|
||||
status_program 'rns' 'ryzom_naming_service'
|
||||
|
||||
# rws : welcome_service.log
|
||||
status_program 'rws' 'ryzom_welcome_service'
|
||||
|
||||
# ts : tick_service.log
|
||||
status_program 'ts' 'ryzom_tick_service'
|
||||
|
||||
# ms : mirror_service.log
|
||||
status_program 'ms' 'ryzom_mirror_service'
|
||||
|
||||
# ais_newbyland : ai_service.log
|
||||
status_program 'ais_newbyland' 'ryzom_ai_service'
|
||||
|
||||
# mfs : mail_forum_service.log
|
||||
status_program 'mfs' 'ryzom_mail_forum_service'
|
||||
|
||||
# su : shard_unifier_service.log
|
||||
status_program 'su' 'ryzom_shard_unifier_service'
|
||||
|
||||
# fes : frontend_service.log
|
||||
status_program 'fes' 'ryzom_frontend_service'
|
||||
|
||||
# sbs : session_browser_server.log
|
||||
status_program 'sbs' 'ryzom_session_browser_service'
|
||||
|
||||
# lgs : logger_service.log
|
||||
status_program 'lgs' 'ryzom_logger_service'
|
||||
|
||||
# mos
|
||||
# status_program 'mos' 'ryzom_monitor_service'
|
||||
|
||||
# pdss
|
||||
#status_program 'pdss' 'ryzom_pd_support_service'
|
||||
|
||||
# ras : admin_service.log
|
||||
status_program 'ras' 'ryzom_admin_service'
|
||||
}
|
||||
|
||||
#####################
|
||||
# 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
|
||||
;;
|
||||
-n|--no-color)
|
||||
NOCOLOR=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $NOCOLOR -eq 0 ]]
|
||||
then
|
||||
RED=$(tput setaf 1)
|
||||
GREEN=$(tput setaf 2)
|
||||
NORMAL=$(tput sgr0)
|
||||
fi
|
||||
status_all
|
||||
|
28
dist/docker/server/debian/common/servercontainer_update_auto.sh
vendored
Executable file
28
dist/docker/server/debian/common/servercontainer_update_auto.sh
vendored
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to update khanat server
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
/opt/ext/servercontainer_configure_link.sh || exit 2
|
||||
#/opt/ext/servercontainer_configure_mysql.sh || exit 2
|
||||
#/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 -d' gameserver || exit 2
|
||||
|
||||
exit 0
|
||||
|
|
@ -28,7 +28,7 @@ tmp=$(hostname -I)
|
|||
export addressip=${tmp//[[:blank:]]/}
|
||||
sed -i -r 's/(FSListenHost)(.*)(=)(.*)(;)/FSListenHost = "'"$addressip"'";/g' $KHANAT_PATH/server/frontend_service.cfg || exit 2
|
||||
|
||||
/opt/prepare_start_server.sh || exit 2
|
||||
/opt/serverimage_prepare_start_server.sh || exit 2
|
||||
|
||||
if [[ $METHOD_START -eq 1 ]]
|
||||
then
|
||||
|
@ -36,11 +36,11 @@ then
|
|||
/home/gameserver/khanat/tools/scripts/linux/shard start
|
||||
elif [[ $METHOD_START -eq 2 ]]
|
||||
then
|
||||
bash /opt/launch_services.sh
|
||||
bash /opt/serverimage_launch_services.sh
|
||||
sleep 10
|
||||
tail -n+0 -f /home/gameserver/khanat/server/log/log.log
|
||||
else
|
||||
bash /opt/launch_services.sh
|
||||
bash /opt/serverimage_launch_services.sh
|
||||
sleep 10
|
||||
watch cat /home/gameserver/khanat/server/aes_nagios_report.txt
|
||||
fi
|
289
dist/docker/server/debian/common/serverimage_init_basic.sh
vendored
Executable file
289
dist/docker/server/debian/common/serverimage_init_basic.sh
vendored
Executable file
|
@ -0,0 +1,289 @@
|
|||
#!/bin/bash
|
||||
# Install all package we need to prepare and install khanat server
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
declare DEBUG=0
|
||||
declare MYSQL_GAMESERVER=0
|
||||
declare APACHE_GAMESERVER=0
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
script to intialize server
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
-m, --mysql-gameserver : create database on gameserver account
|
||||
-a, --apache-gameserver : configure apache to use gameserver account
|
||||
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
|
||||
}
|
||||
|
||||
msg_info "Start Basic"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
DEBUG=1
|
||||
shift
|
||||
;;
|
||||
-m|--mysql-gameserver)
|
||||
MYSQL_GAMESERVER=1
|
||||
shift
|
||||
;;
|
||||
-a|--apache-gameserver)
|
||||
APACHE_GAMESERVER=1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
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
|
||||
|
||||
####################################
|
||||
# Configure account gameserver
|
||||
####################################
|
||||
if [[ $APACHE_GAMESERVER -ne 0 ]]
|
||||
then
|
||||
msg_debug "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"
|
||||
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
|
||||
|
||||
####################################
|
||||
# Initialize apache
|
||||
####################################
|
||||
if [[ $APACHE_GAMESERVER -ne 0 ]]
|
||||
then
|
||||
msg_debug "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
|
||||
mkdir -p /home/gameserver/log/apache2 || exit 2
|
||||
chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
|
||||
fi
|
||||
|
||||
####################################
|
||||
# Initialize database
|
||||
####################################
|
||||
|
||||
if [[ $MYSQL_GAMESERVER -ne 0 ]]
|
||||
then
|
||||
msg_debug "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
|
||||
sed -i -r 's/^log_error[[:space:]]+=[[:space:]]+(.*)/log_error = \/home\/gameserver\/log\/mysql\/error\.log/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)general_log_file[[:space:]]+=(.*)/general_log_file = \/home\/gameserver\/log\/mysql\/mysql\.log/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)general_log[[:space:]]+=(.*)/general_log = 1/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)slow_query_log_file[[:space:]]+=(.*)/slow_query_log_file = \/home\/gameserver\/log\/mysql\/mysql-slow\.log/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)slow_query_log[[:space:]]+=(.*)/slow_query_log = 1/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)long_query_time[[:space:]]+=(.*)/long_query_time = 2/g' /etc/mysql/my.cnf || exit 2
|
||||
sed -i -r 's/^(#*)log_queries_not_using_indexes(.*)/log_queries_not_using_indexes/g' /etc/mysql/my.cnf || exit 2
|
||||
|
||||
mkdir -p /home/gameserver/database/ || exit 2
|
||||
chown gameserver:$(id -g -n gameserver) /home/gameserver/database/ || exit 2
|
||||
|
||||
mkdir -p /home/gameserver/log/mysql || exit 2
|
||||
chown -R gameserver:$(id -g -n gameserver) /home/gameserver/log || exit 2
|
||||
|
||||
/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"
|
||||
/usr/bin/mysql_install_db --user=mysql --skip-name-resolve || exit 2
|
||||
fi
|
||||
|
||||
# Start the MySQL daemon in the background.
|
||||
msg_debug "Start database"
|
||||
/usr/sbin/mysqld &
|
||||
mysql_pid=$!
|
||||
|
||||
# Wait mysql start
|
||||
msg_debug "Check database is started"
|
||||
until /usr/bin/mysqladmin ping >/dev/null 2>&1
|
||||
do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Initialize password root (to empty)
|
||||
msg_debug "configure password root for database"
|
||||
/usr/bin/mysqladmin -u root password '' || exit 2
|
||||
|
||||
msg_debug "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
|
||||
awk '{if($0 ~ /AllowNoPassword/){$1="";}; print $0;}' /etc/phpmyadmin/config.inc.php.ref > /etc/phpmyadmin/config.inc.php || exit 2
|
||||
|
||||
|
||||
# Stop MySQL
|
||||
msg_debug "Stop database"
|
||||
/usr/bin/mysqladmin shutdown
|
||||
|
||||
# Wait MySQL stop
|
||||
wait $mysql_pid
|
||||
|
||||
####################################
|
||||
# Initialize bashrc (for root)
|
||||
####################################
|
||||
msg_debug "Configure bashrc (for root)"
|
||||
cat << EOF > /root/.bashrc
|
||||
# bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
# You may uncomment the following lines if you want 'ls' to be colorized:
|
||||
export SHELL=/bin/bash
|
||||
export LS_OPTIONS='--color=auto'
|
||||
eval "\`dircolors\`"
|
||||
alias ls='ls \$LS_OPTIONS'
|
||||
alias ll='ls \$LS_OPTIONS -l'
|
||||
alias l='ls \$LS_OPTIONS -lA'
|
||||
|
||||
# Some more alias to avoid making mistakes:
|
||||
# alias rm='rm -i'
|
||||
# alias cp='cp -i'
|
||||
# alias mv='mv -i'
|
||||
|
||||
# Autocompletion
|
||||
if [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
EOF
|
||||
|
||||
####################################
|
||||
# Initialize bashrc (for gameserver)
|
||||
####################################
|
||||
msg_debug "Configure bashrc (for gameserver)"
|
||||
cat << EOF > /home/gameserver/.bashrc
|
||||
# bashrc: executed by bash(1) for non-login shells.
|
||||
|
||||
# You may uncomment the following lines if you want 'ls' to be colorized:
|
||||
export SHELL=/bin/bash
|
||||
export LS_OPTIONS='--color=auto'
|
||||
eval "\`dircolors\`"
|
||||
alias ls='ls \$LS_OPTIONS'
|
||||
alias ll='ls \$LS_OPTIONS -l'
|
||||
alias l='ls \$LS_OPTIONS -lA'
|
||||
|
||||
# Some more alias to avoid making mistakes:
|
||||
# alias rm='rm -i'
|
||||
# alias cp='cp -i'
|
||||
# alias mv='mv -i'
|
||||
|
||||
# Autocompletion
|
||||
if [ -f /etc/bash_completion ]; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
EOF
|
||||
chown gameserver:$(id -g -n gameserver) /home/gameserver/.bashrc
|
||||
|
||||
####################################
|
||||
# Adding sudo command
|
||||
####################################
|
||||
|
||||
# Update sudo rule (you can execute all command as root)
|
||||
msg_debug "Configure sudo"
|
||||
cat << EOF > /etc/sudoers.d/gameserver
|
||||
# User privilege specification
|
||||
gameserver ALL=NOPASSWD: ALL
|
||||
EOF
|
||||
|
||||
####################################
|
||||
# LOGING HEADER
|
||||
####################################
|
||||
# Message see when connect on ssh
|
||||
|
||||
# Before login
|
||||
msg_debug "Configure message login"
|
||||
cat << EOF > /etc/issue.net
|
||||
*********************
|
||||
* KHANAT SERVER DEV *
|
||||
*********************
|
||||
|
||||
account gameserver
|
||||
password khanat
|
||||
|
||||
EOF
|
||||
|
||||
# After Login
|
||||
msg_debug "Configure banner"
|
||||
cat << EOF > /etc/motd
|
||||
***************************************************
|
||||
connect to root use gameserver account and launch sudo command
|
||||
like :
|
||||
|
||||
sudo bash
|
||||
|
||||
---------------------------------------------------
|
||||
mysql : account root (no password)
|
||||
---------------------------------------------------
|
||||
log khanat server : /home/gameserver/khanat/server/log/log.log
|
||||
***************************************************
|
||||
EOF
|
||||
|
||||
# Activate banner
|
||||
msg_debug "Activate banner"
|
||||
sed -i 's/#Banner/Banner/g' /etc/ssh/sshd_config
|
||||
|
||||
####################################
|
||||
# End
|
||||
####################################
|
||||
msg_info "End Basic"
|
||||
|
|
@ -18,13 +18,14 @@
|
|||
|
||||
# /opt/dist/docker/server/init-khanat.sh
|
||||
|
||||
/opt/configure_environment.sh || exit 2
|
||||
/opt/install_package.sh || exit 2
|
||||
/opt/configure_apache.sh || exit 2
|
||||
/opt/configure_database.sh || exit 2
|
||||
/opt/initialize_khanat_server.sh || exit 2
|
||||
/opt/initialize_patch_server.sh || exit 2
|
||||
/opt/prepare_khanat_client.sh || exit 2
|
||||
/opt/serverimage_init_basic.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
|
||||
/opt/serverimage_initialize_khanat_server.sh || exit 2
|
||||
/opt/serverimage_initialize_patch_server.sh || exit 2
|
||||
/opt/serverimage_prepare_khanat_client.sh || exit 2
|
||||
|
||||
|
||||
#
|
|
@ -20,10 +20,10 @@
|
|||
echo "INITIALIZE PATCH SERVER"
|
||||
|
||||
#######################
|
||||
# GET PARAM ENVIRONMENT
|
||||
# GET ENVIRONMENT
|
||||
#######################
|
||||
source /etc/apache2/envvars
|
||||
export KHANAT_CLIENT_VERSION=1
|
||||
|
||||
if [[ ! -f /home/gameserver/.bashrc ]]
|
||||
then
|
||||
echo "ERROR - missing /home/gameserver/.bashrc"
|
||||
|
@ -146,7 +146,7 @@ do
|
|||
done
|
||||
mv kh_server.bnp $PATCH_CLIENT_SYSTEM/patch_game/bnp/ || exit 2
|
||||
|
||||
chown -R gameserver:www-data $PATCH_HOME/patch_service || exit 2
|
||||
chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service || exit 2
|
||||
|
||||
echo "PREPARE PATCH"
|
||||
#
|
||||
|
@ -205,7 +205,7 @@ cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/index.php
|
|||
</body>
|
||||
</html>
|
||||
EOF
|
||||
chown gameserver:www-data $PATCH_HOME/patch_service/patch_game/patch/index.php
|
||||
chown gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service/patch_game/patch/index.php
|
||||
|
||||
# TODO - Strange, we need update patch - to be check
|
||||
cat << EOF > $PATCH_HOME/patch_service/patch_game/patch/Lirria.version
|
||||
|
@ -213,6 +213,6 @@ $KHANAT_CLIENT_VERSION $KHANAT_CLIENT_VERSION
|
|||
EOF
|
||||
|
||||
# configure right (apache can read files)
|
||||
chown -R gameserver:www-data $PATCH_HOME/patch_service
|
||||
chown -R gameserver:$APACHE_RUN_GROUP $PATCH_HOME/patch_service
|
||||
chmod g+w -R $PATCH_HOME/patch_service
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
echo "INSTALL PACKAGE"
|
||||
|
||||
# Load Environment
|
||||
source /etc/apache2/envvars
|
||||
export KHANAT_CLIENT_VERSION=1
|
||||
if [[ ! -f /home/gameserver/.bashrc ]]
|
||||
then
|
||||
|
@ -39,7 +40,7 @@ mkdir -p $KHANAT_PATH || exit 2
|
|||
# install web khanat
|
||||
cp -r /opt/code/web $KHANAT_PATH/khanatweb || exit 2
|
||||
chmod -R a+w $KHANAT_PATH/khanatweb || exit 2
|
||||
chown -R www-data:www-data $KHANAT_PATH/khanatweb || exit 2
|
||||
chown -R $APACHE_RUN_USER:$APACHE_RUN_GROUP $KHANAT_PATH/khanatweb || exit 2
|
||||
|
||||
# Get Ressource
|
||||
mkdir -p $KHANAT_DATA/ressources
|
36
dist/docker/server/debian/common/serverimage_install_package_static.sh
vendored
Executable file
36
dist/docker/server/debian/common/serverimage_install_package_static.sh
vendored
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Install binary and data
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
echo "INSTALL PACKAGE"
|
||||
|
||||
# Load Environment
|
||||
source /etc/apache2/envvars
|
||||
export KHANAT_CLIENT_VERSION=1
|
||||
if [[ ! -f /home/gameserver/.bashrc ]]
|
||||
then
|
||||
echo "ERROR - missing /home/gameserver/.bashrc"
|
||||
exit 2
|
||||
fi
|
||||
source /home/gameserver/.bashrc
|
||||
|
||||
# install new package
|
||||
cd /; tar xzf /opt/ryzomcore.tar.gz --strip 1 || exit 2
|
||||
cd /opt; tar xzf khanat-ref-ressources.tar.gz || exit 2
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
echo "PREPARE PACKAGE KHANAT CLIENT"
|
||||
|
||||
# Load Environment
|
||||
source /etc/apache2/envvars
|
||||
export KHANAT_CLIENT_VERSION=1
|
||||
if [[ ! -f /home/gameserver/.bashrc ]]
|
||||
then
|
||||
|
@ -73,7 +74,7 @@ cat << EOF > $HOME_CLIENT/index.html
|
|||
</body>
|
||||
</html>
|
||||
EOF
|
||||
chown -R gameserver:www-data $HOME_CLIENT
|
||||
chown -R gameserver:$APACHE_RUN_GROUP $HOME_CLIENT
|
||||
|
||||
#################################
|
||||
#
|
|
@ -21,19 +21,14 @@ MAINTAINER AleaJactaEst
|
|||
|
||||
ENV HOSTNAME basic_server
|
||||
|
||||
RUN apt-get update
|
||||
RUN apt-get dist-upgrade -y
|
||||
|
||||
RUN apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx
|
||||
RUN apt-get install -y openssh-server sudo net-tools
|
||||
RUN apt-get install -y lzma xdelta p7zip p7zip-full
|
||||
|
||||
# adding account gameserver, password khanat
|
||||
RUN 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
|
||||
|
||||
COPY dist/docker/server/debian/common/init-basic.sh /opt/
|
||||
|
||||
RUN /opt/init-basic.sh
|
||||
RUN apt-get update ; \
|
||||
apt-get dist-upgrade -y ; \
|
||||
apt-get install -y curl nano vim less bash-completion cron logrotate bsd-mailx ; \
|
||||
apt-get install -y openssh-server sudo net-tools ; \
|
||||
apt-get install -y lzma xdelta p7zip p7zip-full ; \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y mysql-server ; \
|
||||
apt-get install -y apache2 php5 libapache2-mod-php5 php5-mysql apache2-utils php5-gd php5-imagick rrdtool screen mcrypt php5-mcrypt ; \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin
|
||||
|
||||
|
||||
|
||||
|
|
33
dist/docker/server/debian/jessie/x86_64/Dockerfile.khanat.container
vendored
Normal file
33
dist/docker/server/debian/jessie/x86_64/Dockerfile.khanat.container
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
# Dockerfile - Build for server debian
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
FROM server_generic_debian_jessie_x86_64
|
||||
MAINTAINER AleaJactaEst
|
||||
|
||||
ENV HOSTNAME khanat_server
|
||||
|
||||
COPY dist/docker/server/debian/common/servercontainer_function.sh /opt/
|
||||
COPY dist/docker/server/debian/common/servercontainer_init_* /opt/
|
||||
|
||||
COPY output/khanat_debian_jessie_x86_64/khanat_config.sh /opt/khanat_config.sh
|
||||
|
||||
RUN /opt/servercontainer_init_create_account.sh
|
||||
RUN /opt/servercontainer_init_mysql.sh
|
||||
RUN /opt/servercontainer_init_apache.sh
|
||||
RUN /opt/servercontainer_init_configure_envi.sh
|
||||
|
|
@ -22,23 +22,12 @@ MAINTAINER AleaJactaEst
|
|||
ENV HOSTNAME khanat_server
|
||||
|
||||
COPY todelete.sh /opt/khanat_config.sh
|
||||
COPY dist/docker/server/debian/common/init-khanat.sh /opt/
|
||||
COPY dist/docker/server/debian/common/autostart.sh /opt/
|
||||
COPY dist/docker/server/debian/common/launch_services.sh /opt/
|
||||
|
||||
COPY dist/docker/server/debian/common/configure_environment.sh /opt/
|
||||
COPY dist/docker/server/debian/common/install_package.sh /opt/
|
||||
COPY dist/docker/server/debian/common/configure_apache.sh /opt/
|
||||
COPY dist/docker/server/debian/common/configure_database.sh /opt/
|
||||
COPY dist/docker/server/debian/common/initialize_khanat_server.sh /opt/
|
||||
COPY dist/docker/server/debian/common/initialize_patch_server.sh /opt/
|
||||
COPY dist/docker/server/debian/common/prepare_start_server.sh /opt/
|
||||
COPY dist/docker/server/debian/common/prepare_khanat_client.sh /opt/
|
||||
COPY dist/docker/server/debian/common/ /opt/
|
||||
|
||||
COPY ryzomcore.tar.gz /opt/
|
||||
COPY ryzom-ressources.tar.gz /opt/
|
||||
COPY khanat-ressources.tar.gz /opt/
|
||||
COPY khanat-data-client.tar.gz /opt/
|
||||
|
||||
RUN /opt/init-khanat.sh
|
||||
RUN /opt/serverimage_init_khanat.sh
|
||||
|
504
dist/docker/server/debian/jessie/x86_64/server-container.sh
vendored
Executable file
504
dist/docker/server/debian/jessie/x86_64/server-container.sh
vendored
Executable file
|
@ -0,0 +1,504 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Script to start khanat server (with docker)
|
||||
# All data are include on host
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
declare -i REMOVE=0
|
||||
declare -i IMAGE=1
|
||||
declare -i BASICSERVER=0
|
||||
declare -i KHANATSERVER=0
|
||||
declare -i CONFIGUREKHANATSERVER=0
|
||||
declare -i KHANATRESSOURCES=0
|
||||
declare -i KHANATDATACLIENT=0
|
||||
declare -i RYZOMRESSOURCES=0
|
||||
declare -i LAUNCHKHANAT=1
|
||||
declare -i UPDATEDATA=0
|
||||
declare -i DEBUG=0
|
||||
declare -i AUTODETEC=1
|
||||
declare -i STOPKHANAT=0
|
||||
declare -i CLEANCONTAINERKHANAT=0
|
||||
declare -i CONNECTSSHKHANAT=0
|
||||
declare -i KHANAT_CLIENT_VERSION=1
|
||||
declare -i SHOWIPKHANATSERVER=0
|
||||
declare METHODSTARTSERVER="--start-khanat-with-screen"
|
||||
declare -i CLEANIMAGENONE=0
|
||||
declare DOCKERBUILDOPT=""
|
||||
|
||||
declare IMAGEGENERICSERVER="server_generic_debian_jessie_x86_64"
|
||||
declare IMAGEKHANATSERVER="servercontainer_khanat_debian_jessie_x86_64"
|
||||
declare LOCALBUILDDIR="build/builder_khanat_debian_jessie_x86_64"
|
||||
declare DIROUTPUT="output/khanat_debian_jessie_x86_64"
|
||||
declare PACKAGEBIN="$DIROUTPUT/package/ryzomcore_jessie_x86_64.tar.gz"
|
||||
declare PACKAGEREF="$DIROUTPUT/package/khanat-ref-ressources.tar.gz"
|
||||
declare ROOTDATAKHANAT="$DIROUTPUT/gameserver"
|
||||
declare DIRLOG="$ROOTDATAKHANAT/log"
|
||||
declare DIRDATABASE="$ROOTDATAKHANAT/database"
|
||||
declare ENVIFILE="$DIROUTPUT/khanat_config.sh"
|
||||
declare DIRKHANAT="$ROOTDATAKHANAT/khanat"
|
||||
declare KHANAT_RESSOURCES_DIR=""
|
||||
declare KHANAT_DATA_CLIENT_DIR=""
|
||||
|
||||
usage()
|
||||
{
|
||||
cat << EOF
|
||||
usage:$0 [options]
|
||||
script to build under docker
|
||||
|
||||
Step:
|
||||
1) create image basic server
|
||||
2) create image khanat server
|
||||
3) configure khagant server
|
||||
4) launch khagant server
|
||||
|
||||
options:
|
||||
-h, --help : Show this help
|
||||
-d, --debug : Show debug message
|
||||
-r, --remove : Remove directory data khanat
|
||||
-b, --force-basic : Force create/recreate image basic server
|
||||
-k, --force-khanat : Force create/recreate image khanat server
|
||||
-u, --update-data : generate a new patch (client & update server)
|
||||
-g, --configure-khanat : Force configure khanat server
|
||||
-n, --no-launch-khanat : Doesn't launch khanat server
|
||||
-s, --stop-server : Stop server khanat
|
||||
-c, --clean-container-khanat : Remove old server khanat (stopped)
|
||||
-w, --clean-images-none : Remove images docker (with name 'none')
|
||||
-i, --show-ip-khanat-server : show ip address for khanat server (launch under docker)
|
||||
--option-docker-build=[STRING] : you can add option in "docker build"
|
||||
--khanat-ressources-dir : localization khanat-ressources
|
||||
--khanat-data-client-dir : localization khanat-data-client
|
||||
--start-khanat-with-screen : start with screen
|
||||
--start-khanat-with-khanat-log : start server khanat and show khanat log
|
||||
--start-khanat-with-full-log : start server khanat and show full log
|
||||
--start-khanat-with-watch-state : start server khanat and show state (loop)
|
||||
--start-khanat-with-watch-state-nagios : start server khanat and show state [nagios format] (loop)
|
||||
--start-khanat-with-bash-after : start server khanat and launch bash
|
||||
--ssh : connect on khanat server (with ssh) [Exclusive action, can't execute other action]
|
||||
--client-version=[INTEGER] : version client khanat (we need to communicate with our server)
|
||||
|
||||
Example :
|
||||
cd [root Khanat directory]
|
||||
./server.sh
|
||||
./server.sh -k
|
||||
./server.sh --ssh
|
||||
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
|
||||
}
|
||||
|
||||
#
|
||||
# MAIN
|
||||
#
|
||||
|
||||
#msg_info "START"
|
||||
|
||||
calldir="$(dirname $0)"
|
||||
basedir=$(cd $calldir; pwd)
|
||||
rootdir="$(dirname $(dirname $(dirname $(dirname $(dirname $(dirname ${basedir}))))))"
|
||||
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
|
||||
dataclientdir="$(dirname ${rootdir})/khanat-data-client"
|
||||
|
||||
while test $# -gt 0
|
||||
do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
-d|--debug)
|
||||
DEBUG=1
|
||||
shift
|
||||
;;
|
||||
--ssh)
|
||||
CONNECTSSHKHANAT=1
|
||||
shift
|
||||
;;
|
||||
-r|--remove)
|
||||
REMOVE=1
|
||||
shift
|
||||
;;
|
||||
-c|--clean-container-khanat)
|
||||
CLEANCONTAINERKHANAT=1
|
||||
shift
|
||||
;;
|
||||
-s|--stop-server)
|
||||
STOPKHANAT=1
|
||||
shift
|
||||
;;
|
||||
-b|--force-basic)
|
||||
BASICSERVER=1
|
||||
shift
|
||||
;;
|
||||
-n|--no-launch-khanat)
|
||||
LAUNCHKHANAT=0
|
||||
shift
|
||||
;;
|
||||
-k|--force-khanat)
|
||||
KHANATSERVER=1
|
||||
shift
|
||||
;;
|
||||
-g|--configure-khanat)
|
||||
CONFIGUREKHANATSERVER=1
|
||||
shift
|
||||
;;
|
||||
-i|--show-ip-khanat-server)
|
||||
SHOWIPKHANATSERVER=1
|
||||
shift
|
||||
;;
|
||||
--start-khanat-with-screen)
|
||||
METHODSTARTSERVER="--start-khanat-with-screen"
|
||||
shift
|
||||
;;
|
||||
--start-khanat-with-khanat-log)
|
||||
METHODSTARTSERVER="--show-khanat-log"
|
||||
shift
|
||||
;;
|
||||
--start-khanat-with-full-log)
|
||||
METHODSTARTSERVER="--show-all-log"
|
||||
shift
|
||||
;;
|
||||
--start-khanat-with-watch-state)
|
||||
METHODSTARTSERVER="--show-status"
|
||||
shift
|
||||
;;
|
||||
--start-khanat-with-watch-state-nagios)
|
||||
METHODSTARTSERVER="--show-status-nagios"
|
||||
shift
|
||||
;;
|
||||
--start-khanat-with-bash-after)
|
||||
METHODSTARTSERVER="--bash-after-start"
|
||||
shift
|
||||
;;
|
||||
--client-version*)
|
||||
KHANAT_CLIENT_VERSION="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--khanat-ressources-dir*)
|
||||
KHANAT_RESSOURCES_DIR="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
--khanat-data-client-dir*)
|
||||
KHANAT_DATA_CLIENT_DIR="${1#*=}"
|
||||
shift
|
||||
;;
|
||||
-w|--clean-images-none)
|
||||
CLEANIMAGENONE=1
|
||||
shift
|
||||
;;
|
||||
-u|--update-data)
|
||||
UPDATEDATA=1
|
||||
shift
|
||||
;;
|
||||
--option-docker-build)
|
||||
DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
function chrashed()
|
||||
{
|
||||
msg_error "BUILD FAILED (code:$?)"
|
||||
exit 2
|
||||
}
|
||||
|
||||
trap chrashed EXIT
|
||||
|
||||
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
|
||||
then
|
||||
msg_info "START"
|
||||
fi
|
||||
|
||||
msg_debug "prg: $0"
|
||||
|
||||
docker -v 1>/dev/null
|
||||
if [[ $? -ne 0 ]]
|
||||
then
|
||||
msg_error "docker not installed"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
case "$(uname -m)" in
|
||||
x86_64)
|
||||
;;
|
||||
i686)
|
||||
msg_error "Bad Archi"
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
msg_error "Unknown archi : $(uname -m)"
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ $REMOVE -ne 0 ]]
|
||||
then
|
||||
msg_info "REMOVE DATA KHANAT : $ROOTDATAKHANAT"
|
||||
if [[ -n "$ROOTDATAKHANAT" ]]
|
||||
then
|
||||
rm -rf ${ROOTDATAKHANAT}/* || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
msg_debug "Create directory on host ($ROOTDATAKHANAT)"
|
||||
mkdir -p $ROOTDATAKHANAT || exit 2
|
||||
chmod g+s $ROOTDATAKHANAT
|
||||
|
||||
|
||||
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
|
||||
then
|
||||
msg_debug "clean container"
|
||||
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
|
||||
if [[ ${#listcontainer[@]} -eq 1 ]]
|
||||
then
|
||||
ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]})
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $SHOWIPKHANATSERVER -ne 0 ]]
|
||||
then
|
||||
trap '' EXIT
|
||||
echo "$ipaddress"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $CONNECTSSHKHANAT -ne 0 ]]
|
||||
then
|
||||
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no gameserver@$ipaddress
|
||||
trap '' EXIT
|
||||
msg_info "END SSH"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ $AUTODETEC -ne 0 ]]
|
||||
then
|
||||
msg_debug "Autodetect state"
|
||||
if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]]
|
||||
then
|
||||
BASICSERVER=1
|
||||
fi
|
||||
if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]]
|
||||
then
|
||||
KHANATSERVER=1
|
||||
fi
|
||||
if [[ -z "$KHANAT_RESSOURCES_DIR" ]]
|
||||
then
|
||||
KHANAT_RESSOURCES_DIR="$(dirname $rootdir)/khanat-ressources"
|
||||
fi
|
||||
if [[ -z "$KHANAT_DATA_CLIENT_DIR" ]]
|
||||
then
|
||||
KHANAT_DATA_CLIENT_DIR="$(dirname $rootdir)/khanat-data-client"
|
||||
fi
|
||||
fi
|
||||
|
||||
DIRBUILD="${rootdir}/code/${LOCALBUILDDIR}"
|
||||
|
||||
msg_debug "calldir: $calldir"
|
||||
msg_debug "basedir: $basedir"
|
||||
msg_debug "rootdir: $rootdir"
|
||||
msg_debug "ressourcedir: $ressourcedir"
|
||||
msg_debug "generate basic image: $BASICSERVER"
|
||||
msg_debug "generate tar khanat ressources: $KHANATRESSOURCES"
|
||||
msg_debug "generate tar khanat data client: $KHANATDATACLIENT"
|
||||
msg_debug "generate tar ryzom ressources: $RYZOMRESSOURCES"
|
||||
msg_debug "localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}"
|
||||
msg_debug "localization khanat-data-client : ${KHANAT_DATA_CLIENT_DIR}"
|
||||
msg_debug "generate khanat image: $KHANATSERVER"
|
||||
msg_debug "launch khanat: $LAUNCHKHANAT"
|
||||
msg_debug "stop khanat: $STOPKHANAT"
|
||||
|
||||
msg_info "check package ($(basename ${PACKAGEBIN}))"
|
||||
if [[ ! -f ${rootdir}/${PACKAGEBIN} ]]
|
||||
then
|
||||
msg_error "Missing package ($(basename ${PACKAGEBIN}))"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
msg_info "check package (khanat-ref-ressources.tar.gz)"
|
||||
if [[ ! -f ${rootdir}/${PACKAGEREF} ]]
|
||||
then
|
||||
msg_error "Missing package ($(basename ${PACKAGEREF}))"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
msg_info "check khanat-ressources"
|
||||
if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]]
|
||||
then
|
||||
msg_error "Missing directory khanat-ressources [${KHANAT_RESSOURCES_DIR}]"
|
||||
cat << EOF
|
||||
You need clone repo khanat-ressource.
|
||||
|
||||
cd $(dirname ${KHANAT_RESSOURCES_DIR})
|
||||
git clone https://git.khanat.net/khanat/khanat-ressources.git
|
||||
|
||||
EOF
|
||||
exit 2
|
||||
fi
|
||||
|
||||
|
||||
msg_info "check khanat-data-client"
|
||||
if [[ ! -d ${KHANAT_DATA_CLIENT_DIR} ]]
|
||||
then
|
||||
msg_error "Missing directory khanat-data-client [${KHANAT_DATA_CLIENT_DIR}]"
|
||||
cat << EOF
|
||||
You need clone repo khanat-data-client.
|
||||
|
||||
cd $(dirname ${KHANAT_DATA_CLIENT_DIR})
|
||||
git clone https://git.khanat.net/khanat/khanat-data-client.git
|
||||
|
||||
EOF
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ $STOPKHANAT -ne 0 ]]
|
||||
then
|
||||
msg_info "STOP SERVER KHANAT"
|
||||
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
|
||||
msg_debug "CONTAINER KHANAT UP : ${listcontainer[@]}"
|
||||
if [[ -n "$listcontainer" ]]
|
||||
then
|
||||
docker stop "$listcontainer" || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
|
||||
then
|
||||
msg_info "CLEAN CONTAINER KHANAT"
|
||||
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
|
||||
msg_debug "CONTAINER KHANAT EXITED : ${listcontainer[@]}"
|
||||
if [[ -n "${listcontainer[@]}" ]]
|
||||
then
|
||||
docker rm --force "${listcontainer[@]}" || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $CLEANIMAGENONE -ne 0 ]]
|
||||
then
|
||||
msg_info "CLEAN IMAGE DOCKER 'NONE'"
|
||||
listimages=( $(docker images | awk '{if ($1=="<none>")print $3}') )
|
||||
|
||||
msg_debug "IMAGES NONE : ${listimages[@]}"
|
||||
if [[ -n "${listimages[@]}" ]]
|
||||
then
|
||||
docker rmi --force "${listimages[@]}" || exit 2
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $BASICSERVER -ne 0 ]]
|
||||
then
|
||||
msg_info "GENERATE DOCKER IMAGE BASIC SERVER"
|
||||
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEGENERICSERVER} \
|
||||
--file "${basedir}/Dockerfile" || exit 2
|
||||
fi
|
||||
|
||||
if [[ $KHANATSERVER -ne 0 ]]
|
||||
then
|
||||
msg_info "GENERATE DOCKER IMAGE 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
|
||||
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
|
||||
--file "${basedir}/Dockerfile.khanat.container" || exit 2
|
||||
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 \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
|
||||
-v ${rootdir}/code/web/:/home/gameserver/ext/khanatweb:ro \
|
||||
-v ${rootdir}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
|
||||
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
|
||||
-v ${KHANAT_DATA_CLIENT_DIR}:/home/gameserver/ext/khanat-data-client:ro \
|
||||
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
|
||||
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
|
||||
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
|
||||
-v ${rootdir}/dist/docker/server/debian/common/:/opt/ext:ro \
|
||||
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2
|
||||
fi
|
||||
|
||||
if [[ $UPDATEDATA -ne 0 ]]
|
||||
then
|
||||
cd $rootdir; docker run -it --hostname=khanat \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
|
||||
-v ${rootdir}/code/web/:/home/gameserver/ext/khanatweb:ro \
|
||||
-v ${rootdir}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
|
||||
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
|
||||
-v ${KHANAT_DATA_CLIENT_DIR}:/home/gameserver/ext/khanat-data-client:ro \
|
||||
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
|
||||
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
|
||||
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
|
||||
-v ${rootdir}/dist/docker/server/debian/common/:/opt/ext:ro \
|
||||
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh
|
||||
fi
|
||||
|
||||
if [[ $LAUNCHKHANAT -ne 0 ]]
|
||||
then
|
||||
msg_info "START KHANAT SERVER"
|
||||
cd $rootdir; docker run -it --hostname=khanat \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
|
||||
-v ${rootdir}/code/web/:/home/gameserver/ext/khanatweb:ro \
|
||||
-v ${rootdir}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
|
||||
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
|
||||
-v ${KHANAT_DATA_CLIENT_DIR}:/home/gameserver/ext/khanat-data-client:ro \
|
||||
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
|
||||
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
|
||||
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
|
||||
-v ${rootdir}/dist/docker/server/debian/common/:/opt/ext:ro \
|
||||
${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER
|
||||
fi
|
||||
|
||||
trap '' EXIT
|
||||
msg_info "END"
|
|
@ -37,7 +37,7 @@ declare -i CLEANIMAGENONE=0
|
|||
declare DOCKERBUILDOPT=""
|
||||
|
||||
declare IMAGEGENERICSERVER="server_generic_debian_jessie_x86_64"
|
||||
declare IMAGEKHANATSERVER="server_khanat_debian_jessie_x86_64"
|
||||
declare IMAGEKHANATSERVER="serverimage_khanat_debian_jessie_x86_64"
|
||||
declare LOCALBUILDDIR="build/builder_khanat_debian_jessie_x86_64"
|
||||
|
||||
usage()
|
||||
|
@ -66,6 +66,7 @@ options:
|
|||
-c, --clean-container-khanat : Remove old server khanat (stopped)
|
||||
-w, --clean-images-none : Remove images docker (with name 'none')
|
||||
-i, --show-ip-khanat-server : show ip address for khanat server (launch under docker)
|
||||
--option-docker-build=[STRING] : you can add option in "docker build"
|
||||
--start-khanat-with-screen : [default] start khanat with screen
|
||||
--start-khanat-with-full-log : start server khanat and show full log
|
||||
--start-khanat-with-watch-state : start server khanat and show state (loop)
|
||||
|
@ -135,7 +136,6 @@ do
|
|||
;;
|
||||
-b|--force-basic)
|
||||
BASICSERVER=1
|
||||
DOCKERBUILDOPT="$DOCKERBUILDOPT --no-cache"
|
||||
shift
|
||||
;;
|
||||
-n|--no-launch-khanat)
|
||||
|
@ -182,6 +182,10 @@ do
|
|||
CLEANIMAGENONE=1
|
||||
shift
|
||||
;;
|
||||
--option-docker-build)
|
||||
DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
msg_error "options '$1' not recoginze"
|
||||
usage
|
||||
|
@ -391,15 +395,17 @@ then
|
|||
# Temporary file, use only to send some information on build docker
|
||||
export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION
|
||||
EOF
|
||||
cd $rootdir; docker build . -t ${IMAGEKHANATSERVER} \
|
||||
--file "${basedir}/Dockerfile.khanat" || exit 2
|
||||
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
|
||||
--file "${basedir}/Dockerfile.khanat.image" || exit 2
|
||||
rm $rootdir/todelete.sh
|
||||
fi
|
||||
|
||||
if [[ $LAUNCHKHANAT -ne 0 ]]
|
||||
then
|
||||
msg_info "START KHANAT SERVER"
|
||||
cd $rootdir; docker run -it --hostname=khanat ${IMAGEKHANATSERVER} /opt/autostart.sh $METHODSTARTSERVER
|
||||
cd $rootdir; docker run -it --hostname=khanat \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
${IMAGEKHANATSERVER} /opt/serverimage_autostart.sh $METHODSTARTSERVER
|
||||
clear
|
||||
fi
|
||||
|
Loading…
Reference in a new issue