remove jessie builder/server, update script prepare_environment_container_64.sh

This commit is contained in:
AleaJactaEst 2018-07-09 21:48:03 +02:00
parent bda0ee307c
commit 2fc85bbcf5
19 changed files with 9 additions and 3120 deletions

View file

@ -1,101 +0,0 @@
# Dockerfile - Build environment to compile 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
FROM i386/debian:8
MAINTAINER AleaJactaEst
ENV HOSTNAME builder
RUN apt-get update ; \
apt-get dist-upgrade -y ; \
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 \
git \
libcurl4-openssl-dev \
libluabind-dev \
libfreetype6-dev \
libx11-dev \
libgl1-mesa-dev \
libxxf86vm-dev \
libxrandr-dev \
libxrender-dev \
libopenal-dev \
libogg-dev \
libvorbis-dev \
libxml2-dev \
cmake \
build-essential \
libpng12-dev \
libjpeg62-turbo-dev \
rrdtool \
bison \
libxmu-dev \
autoconf \
automake \
libmysqlclient-dev \
libgif-dev \
cpputest \
libssl-dev \
liblzma-dev \
unzip \
zlib1g-dev \
libssh-dev \
libboost-all-dev \
libopenal-dev \
libgl1-mesa-dev \
libogg-dev \
mercurial \
wget \
python3 \
python3-setuptools
## Build & Install cpptest
# Impossible to build release 1.1.0, 1.1.1, 1.1.2
RUN apt-get install -y wget autogen autoconf automake libtool libtool-bin
RUN mkdir -p /opt/src
RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz
RUN rm -rf /opt/src/cpptest
RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1
RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install
## Build & Install squish
RUN mkdir -p /opt/src
RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip
RUN cd /opt/src; unzip squish-1.11.zip
COPY builder/common/squish-limit.patch /opt/squish-limit.patch
RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch
RUN cd /opt/src/squish-1.11; make
RUN cd /opt/src/squish-1.11; make install
## Build & Install CURL - 7.46.0
#RUN hg clone http://hg.kervala.net/packaging/
#RUN mkdir -p packaging/curl/build
#RUN cd packaging/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a ..
#RUN cd packaging/curl/build; make
#RUN cd packaging/curl/build; make install
RUN wget -q https://curl.haxx.se/download/curl-7.46.0.tar.gz -O /opt/src/curl.tar.gz
RUN mkdir -p /opt/src/curl/build
RUN tar xvf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1
RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a ..
RUN cd /opt/src/curl/build; make
RUN cd /opt/src/curl/build; make install

View file

@ -1,70 +0,0 @@
#!/bin/bash
# Script to build Khaganat binary (executed in docker)
#
# Copyright (C) 2017 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
declare DIRBUILD="/opt/build/"
if [[ -n "$1" ]]
then
DIRBUILD="$1"
fi
declare LOGFILE="${DIRBUILD}/build.log"
function chrashed()
{
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
msg_info "LOAD ENVIRONMENT"
source ${DIRBUILD}/envi.sh
fi
msg_info "PREPARE BUILD"
# on 32bit, we need add option '-DWITH_SSE2=OFF'
cd ${DIRBUILD}; cmake -DWITH_NEL=ON \
-DWITH_STATIC=ON \
-DWITH_STATIC_DRIVERS=ON \
-DWITH_STATIC_EXTERNAL=ON \
-DWITH_SYMBOLS=ON \
-DWITH_LUA52=ON \
-DWITH_RYZOM_PATCH=ON \
-DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \
${CMAKEOPTS} \
/opt/code 1>>$LOGFILE 2>&1 || exit 2
msg_info "BUILD START"
cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2
msg_info "GENERATE PACKAGE"
cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2
trap '' EXIT
msg_info "BUILD END"

View file

@ -1,300 +0,0 @@
#!/bin/bash
#
# Script to build khaganat server
#
# Copyright (C) 2017 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
declare -i REMOVE=0
declare -i IMAGE=0
declare -i BUILD=1
declare -i PACKAGE=0
declare -i DEBUG=0
declare JOBS=""
declare CMAKEOPTS=""
declare DOCKEROPTS=""
declare DIRBUILD=""
declare CLEANDOCKER=0
declare -i CLEANIMAGENONE=0
declare -i AUTODETEC=1
declare DOCKERBUILDOPT=""
declare IMAGEDOCKER="opennel/builder_debian_jessie_i686"
declare LOCALBUILDDIR="build/$IMAGEDOCKER"
declare LOCALSRC="debian/jessie/i686"
declare DIRPACKAGE="output/OpenNel_debian_jessie_i686/package"
declare PACKAGEBIN="$DIRPACKAGE/ryzomcore_jessie_i686.tar.gz"
declare PACKAGEREF="$DIRPACKAGE/khanat-ref-ressources.tar.gz"
usage()
{
cat << EOF
usage:$0 [options]
script to build under docker
Step:
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 and clean docker images NONE
options:
-h, --help : Show this help
-d, --debug : Show debug message
-r, --remove : Remove old build repository
-f, --force-create-image : force to create docker image (use to build khanat) - default autodetec.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build)
-c, --clean-container : remove all container in state Exited
-w, --clean-images-none : Remove images docker (with name 'none')
-m OPTS, --add-opts-docker=OPTS : Adding options on docker command (when build)
--only-build-server : adding option to build only server
-p, --package : generate package
--code-source=[DIR] : localization source OpenNel code
Example :
cd [root Khanat directory]
./build.sh -c -r -m '-m 20g'
./build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' -m '-m 20g' -d
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
#
calldir="$(dirname $0)"
basedir=$(cd $calldir; pwd)
rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))"
codesource="$(dirname ${rootdir})/khanat-opennel-code"
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
shift
;;
-c|--clean-container)
CLEANDOCKER=1
shift
;;
-r|--remove)
REMOVE=1
shift
;;
-f|--force-create-image)
IMAGE=1
shift
;;
-p|--package)
PACKAGE=1
shift
;;
-j)
shift
# search next argument is value or new argument
if [[ ${1:0:1} == "-" ]]
then
JOBS="-j"
else
JOBS="-j $1"
shift
fi
;;
--jobs*)
if [[ ${1#*=} == "" ]]
then
JOBS="-j"
else
JOBS="-j ${1#*=}"
fi
shift
;;
-a)
shift
CMAKEOPTS="$CMAKEOPTS $1"
shift
;;
--add-opts-cmake=*)
CMAKEOPTS="$CMAKEOPTS ${1#*=}"
shift
;;
-m)
shift
DOCKEROPTS="$DOCKEROPTS $1"
shift
;;
--add-opts-docker=*)
DOCKEROPTS="$DOCKEROPTS ${1#*=}"
shift
;;
--only-build-server)
CMAKEOPTS="$CMAKEOPTS -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
;;
--code-source=*)
codesource="${1#*=}"
shift
;;
*)
msg_error "options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
msg_debug "prg: $0"
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
echo "*** ERROR docker not installed"
exit 2
fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]]
then
IMAGE=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "calldir: $calldir"
msg_debug "basedir: $basedir"
msg_debug "rootdir: $rootdir"
msg_debug "codesource: $codesource"
msg_debug "JOBS: '$JOBS'"
msg_debug "CMAKEOPTS: '$CMAKEOPTS'"
msg_debug "DOCKEROPTS: '$DOCKEROPTS'"
if [ ! -d "${codesource}/code" ]
then
msg_error "Missing OpenNel source (${codesource})"
exit 2
fi
mkdir -p "${DIRBUILD}"
if [[ $REMOVE -ne 0 ]]
then
msg_info "REMOVE OLD BUILD"
rm -rf ${DIRBUILD}/* || exit 2
fi
echo "$(date "+%Y/%m/%d %H:%M:%S") LAUNCH BUILD" > ${DIRBUILD}/build.log
cat << EOF > ${DIRBUILD}/envi.sh
#!/bin/bash
export MAKEOPTS="$JOBS"
export CMAKEOPTS="$CMAKEOPTS"
EOF
if [[ $IMAGE -ne 0 ]]
then
echo "$(date "+%Y/%m/%d %H:%M:%S") GENERATE DOCKER IMAGE" > ${DIRBUILD}/build.log
msg_info "GENERATE DOCKER IMAGE"
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t "${IMAGEDOCKER}" \
--file "${basedir}/Dockerfile" || exit 2
fi
if [[ $BUILD -ne 0 ]]
then
msg_info "BUILD"
cd $rootdir; docker run -it \
--hostname=builder \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v ${rootdir}/builder:/opt/builder:ro \
-v ${codesource}/code:/opt/code:ro \
-v ${rootdir}/build:/opt/build \
-v /etc/localtime:/etc/localtime:ro \
${DOCKEROPTS} \
${IMAGEDOCKER} \
/opt/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2
fi
if [[ $PACKAGE -ne 0 ]]
then
msg_info "COPY PACKAGES"
mkdir -p "$rootdir/$DIRPACKAGE"
cd ${rootdir}; tar czf ${PACKAGEREF} \
${codesource}/code/ryzom/server/shard.screen.rc \
${codesource}/code/ryzom/common/* \
${codesource}/code/ryzom/client/* \
${codesource}/code/ryzom/server/* \
${codesource}/code/web/* || exit 2
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2
fi
if [[ $CLEANDOCKER -ne 0 ]]
then
msg_info "CLEAN CONTAINER"
docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
trap '' EXIT
msg_info "END"

View file

@ -1,102 +0,0 @@
# Dockerfile - Build environment to compile 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM amd64/debian:8
MAINTAINER AleaJactaEst
ENV HOSTNAME builder
RUN apt-get update ; \
apt-get dist-upgrade -y ; \
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 \
git \
libcurl4-openssl-dev \
libluabind-dev \
libfreetype6-dev \
libx11-dev \
libgl1-mesa-dev \
libxxf86vm-dev \
libxrandr-dev \
libxrender-dev \
libopenal-dev \
libogg-dev \
libvorbis-dev \
libxml2-dev \
cmake \
build-essential \
libpng12-dev \
libjpeg62-turbo-dev \
rrdtool \
bison \
libxmu-dev \
autoconf \
automake \
libmysqlclient-dev \
libgif-dev \
cpputest \
libssl-dev \
liblzma-dev \
unzip \
zlib1g-dev \
libssh-dev \
libboost-all-dev \
libopenal-dev \
libgl1-mesa-dev \
libogg-dev \
mercurial \
wget \
python3 \
python3-setuptools
## Build & Install cpptest
# Impossible to build release 1.1.0, 1.1.1, 1.1.2
RUN apt-get install -y wget autogen autoconf automake libtool libtool-bin
RUN mkdir -p /opt/src
RUN wget -q https://github.com/cpptest/cpptest/archive/1.0.5.tar.gz -O /opt/src/cpptest.tar.gz
RUN rm -rf /opt/src/cpptest
RUN tar xvf /opt/src/cpptest.tar.gz -C /opt/src --strip 1
RUN cd /opt/src/cpptest && ./autogen.sh && ./configure && make && make install
## Build & Install squish
RUN mkdir -p /opt/src
RUN cd /opt/src; wget -c https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/libsquish/squish-1.11.zip
RUN cd /opt/src; unzip squish-1.11.zip
COPY builder/common/squish-limit.patch /opt/squish-limit.patch
RUN cd /opt/src/squish-1.11; patch -i /opt/squish-limit.patch
RUN cd /opt/src/squish-1.11; make
RUN cd /opt/src/squish-1.11; make install
## Build & Install CURL - 7.46.0
#RUN hg clone http://hg.kervala.net/packaging/
#RUN mkdir -p packaging/curl/build
#RUN cd packaging/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a ..
#RUN cd packaging/curl/build; make
#RUN cd packaging/curl/build; make install
RUN wget -q https://curl.haxx.se/download/curl-7.46.0.tar.gz -O /opt/src/curl.tar.gz
RUN mkdir -p /opt/src/curl/build
RUN tar xvf /opt/src/curl.tar.gz -C /opt/src/curl --strip 1
RUN cd /opt/src/curl/build; cmake -DCMAKE_BUILD_TYPE=Release -DCURL_ZLIB=ON -DBUILD_CURL_EXE=OFF -DBUILD_CURL_TESTS=OFF -DCURL_STATICLIB=ON -DHTTP_ONLY=ON -DENABLE_IPV6=ON -DCMAKE_USE_OPENSSL=ON -DOPENSSL_SSL_LIBRARIES=/usr/lib/libssl.a -DOPENSSL_CRYPTO_LIBRARIES=/usr/lib/libcrypto.a -DCMAKE_USE_LIBSSH2=OFF -DZLIB_LIBRARY=/usr/lib/x86_64-linux-gnu/libz.a ..
RUN cd /opt/src/curl/build; make
RUN cd /opt/src/curl/build; make install

View file

@ -1,69 +0,0 @@
#!/bin/bash
# Script to build Khaganat binary (executed in docker)
#
# Copyright (C) 2017 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
declare DIRBUILD="/opt/build/"
if [[ -n "$1" ]]
then
DIRBUILD="$1"
fi
declare LOGFILE="${DIRBUILD}/build.log"
function chrashed()
{
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
msg_info "LOAD ENVIRONMENT"
source ${DIRBUILD}/envi.sh
fi
msg_info "PREPARE BUILD"
cd ${DIRBUILD}; cmake -DWITH_NEL=ON \
-DWITH_STATIC=ON \
-DWITH_STATIC_DRIVERS=ON \
-DWITH_STATIC_EXTERNAL=ON \
-DWITH_SYMBOLS=ON \
-DWITH_LUA52=ON \
-DWITH_RYZOM_PATCH=ON \
-DWITH_RYZOM_CUSTOM_PATCH_SERVER=ON \
${CMAKEOPTS} \
/opt/code 1>>$LOGFILE 2>&1 || exit 2
msg_info "BUILD START"
cd ${DIRBUILD}; make $MAKEOPTS 1>>$LOGFILE 2>&1 || exit 2
msg_info "GENERATE PACKAGE"
cd ${DIRBUILD}; make package 1>>$LOGFILE 2>&1 || exit 2
trap '' EXIT
msg_info "BUILD END"

View file

@ -1,300 +0,0 @@
#!/bin/bash
#
# Script to build khaganat server
#
# Copyright (C) 2017 AleaJactaEst
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
declare -i REMOVE=0
declare -i IMAGE=0
declare -i BUILD=1
declare -i PACKAGE=0
declare -i DEBUG=0
declare JOBS=""
declare CMAKEOPTS=""
declare DOCKEROPTS=""
declare DIRBUILD=""
declare CLEANDOCKER=0
declare -i CLEANIMAGENONE=0
declare -i AUTODETEC=1
declare DOCKERBUILDOPT=""
declare IMAGEDOCKER="opennel/builder_debian_jessie_x86_64"
declare LOCALBUILDDIR="build/$IMAGEDOCKER"
declare LOCALSRC="debian/jessie/x86_64"
declare DIRPACKAGE="output/OpenNel_debian_jessie_x86_64/package"
declare PACKAGEBIN="$DIRPACKAGE/ryzomcore_jessie_x86_64.tar.gz"
declare PACKAGEREF="$DIRPACKAGE/khanat-ref-ressources.tar.gz"
usage()
{
cat << EOF
usage:$0 [options]
script to build under docker
Step:
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 and clean docker images NONE
options:
-h, --help : Show this help
-d, --debug : Show debug message
-r, --remove : Remove old build repository
-f, --force-create-image : force to create docker image (use to build khanat) - default autodetec.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-a OPTS, --add-opts-cmake=OPTS : Adding options on cmake command (before build)
-c, --clean-container : remove all container in state Exited
-w, --clean-images-none : Remove images docker (with name 'none')
-m OPTS, --add-opts-docker=OPTS : Adding options on docker command (when build)
--only-build-server : adding option to build only server
-p, --package : generate package
--code-source=[DIR] : localization source OpenNel code
Example :
cd [root Khanat directory]
./build.sh -c -r -m '-m 20g'
./build.sh -c -r -j 4 -a '-DWITH_SYMBOLS=ON' -a '-DWITH_RYZOM_TOOLS=OFF' -a '-DWITH_NEL_TOOLS=OFF' -m '-m 20g' -d
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
#
calldir="$(dirname $0)"
basedir=$(cd $calldir; pwd)
rootdir="$(dirname $(dirname $(dirname $(dirname ${basedir}))))"
codesource="$(dirname ${rootdir})/khanat-opennel-code"
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
shift
;;
-c|--clean-container)
CLEANDOCKER=1
shift
;;
-r|--remove)
REMOVE=1
shift
;;
-f|--force-create-image)
IMAGE=1
shift
;;
-p|--package)
PACKAGE=1
shift
;;
-j)
shift
# search next argument is value or new argument
if [[ ${1:0:1} == "-" ]]
then
JOBS="-j"
else
JOBS="-j $1"
shift
fi
;;
--jobs*)
if [[ ${1#*=} == "" ]]
then
JOBS="-j"
else
JOBS="-j ${1#*=}"
fi
shift
;;
-a)
shift
CMAKEOPTS="$CMAKEOPTS $1"
shift
;;
--add-opts-cmake=*)
CMAKEOPTS="$CMAKEOPTS ${1#*=}"
shift
;;
-m)
shift
DOCKEROPTS="$DOCKEROPTS $1"
shift
;;
--add-opts-docker=*)
DOCKEROPTS="$DOCKEROPTS ${1#*=}"
shift
;;
--only-build-server)
CMAKEOPTS="$CMAKEOPTS -DWITH_NEL_TESTS=OFF -DWITH_RYZOM_CLIENT=OFF -DWITH_DRIVER_OPENGL=OFF -DWITH_DRIVER_OPENAL=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_SOUND=OFF"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
;;
--code-source=*)
codesource="${1#*=}"
shift
;;
*)
msg_error "options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
msg_debug "prg: $0"
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
echo "*** ERROR docker not installed"
exit 2
fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEDOCKER" | wc -l) -lt 2 ]]
then
IMAGE=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "calldir: $calldir"
msg_debug "basedir: $basedir"
msg_debug "rootdir: $rootdir"
msg_debug "codesource: $codesource"
msg_debug "JOBS: '$JOBS'"
msg_debug "CMAKEOPTS: '$CMAKEOPTS'"
msg_debug "DOCKEROPTS: '$DOCKEROPTS'"
if [ ! -d "${codesource}/code" ]
then
msg_error "Missing OpenNel source (${codesource})"
exit 2
fi
mkdir -p "${DIRBUILD}"
if [[ $REMOVE -ne 0 ]]
then
msg_info "REMOVE OLD BUILD"
rm -rf ${DIRBUILD}/* || exit 2
fi
echo "$(date "+%Y/%m/%d %H:%M:%S") LAUNCH BUILD" > ${DIRBUILD}/build.log
cat << EOF > ${DIRBUILD}/envi.sh
#!/bin/bash
export MAKEOPTS="$JOBS"
export CMAKEOPTS="$CMAKEOPTS"
EOF
if [[ $IMAGE -ne 0 ]]
then
echo "$(date "+%Y/%m/%d %H:%M:%S") GENERATE DOCKER IMAGE" > ${DIRBUILD}/build.log
msg_info "GENERATE DOCKER IMAGE"
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t "${IMAGEDOCKER}" \
--file "${basedir}/Dockerfile" || exit 2
fi
if [[ $BUILD -ne 0 ]]
then
msg_info "BUILD"
cd $rootdir; docker run -it \
--hostname=builder \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v ${rootdir}/builder:/opt/builder:ro \
-v ${codesource}/code:/opt/code:ro \
-v ${rootdir}/build:/opt/build \
-v /etc/localtime:/etc/localtime:ro \
${DOCKEROPTS} \
${IMAGEDOCKER} \
/opt/builder/${LOCALSRC}/build-under-docker.sh "/opt/${LOCALBUILDDIR}" || exit 2
fi
if [[ $PACKAGE -ne 0 ]]
then
msg_info "COPY PACKAGES"
mkdir -p "$rootdir/$DIRPACKAGE"
cd ${rootdir}; tar czf ${PACKAGEREF} \
${codesource}/code/ryzom/server/shard.screen.rc \
${codesource}/code/ryzom/common/* \
${codesource}/code/ryzom/client/* \
${codesource}/code/ryzom/server/* \
${codesource}/code/web/* || exit 2
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${PACKAGEBIN} || exit 2
fi
if [[ $CLEANDOCKER -ne 0 ]]
then
msg_info "CLEAN CONTAINER"
docker rm --force `docker ps -qf 'status=exited' -f "ancestor=${IMAGEDOCKER}"` || exit 2
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
trap '' EXIT
msg_info "END"

View file

@ -1,33 +1,22 @@
#!/bin/bash
declare IMAGEKHANATSERVER="opennel/servercontainer_debian_stretch_x86_64"
# Script to download khanat docker package
mkdir -p $HOME/Public
echo "$(date "+%Y/%m/%d %H:%M:%S") Get ip address server khanat"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
if [[ ${#listcontainer[@]} -eq 1 ]]
then
ipaddress=$(docker inspect --format="{{ .NetworkSettings.IPAddress }}" ${listcontainer[@]})
fi
ipaddress="<?php print getHostByName(gethostname());?>"
echo "$(date "+%Y/%m/%d %H:%M:%S") get client package"
wget http://$ipaddress/client/smokey_linux64.tar.gz -O smokey_linux64.tar.gz
echo "$(date "+%Y/%m/%d %H:%M:%S") clean old client"
if [[ -d Khanat_Linux64 ]]
then
rm -rf Khanat_Linux64 || exit 2
fi
echo "$(date "+%Y/%m/%d %H:%M:%S") install new client"
#7z x -y $SRCKHANATCLIENT || exit 2
#7z x -y -oKhanat_Linux64 $SRCKHANATCLIENTDEBUG || exit 2
tar xvzf smokey_linux64.tar.gz || exit 2
echo "$(date "+%Y/%m/%d %H:%M:%S") configure client"
sed -i 's/lirria.khaganat.net/'$ipaddress'/g' Khanat_Linux64/client_default.cfg
sed -i 's/lirria.khaganat.net/'"$ipaddress"'/g' Khanat_Linux64/client_default.cfg
echo -en "Client khanat installed & configured\nGo to Khanat_Linux64 directory and launch client\n"
echo -en "(cd Khanat_Linux64;./khanat_client)\n"

View file

@ -109,6 +109,7 @@ cat << EOF > /etc/apache2/sites-available/000-default.conf
AddType text/html .php .phps
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
AddHandler application/x-httpd-php .sh
</Directory>
ServerName lirria.khaganat.net

View file

@ -75,7 +75,6 @@ msg_debug "group : $(id -g -n gameserver)"
create_dir_gameserver '/home/gameserver/ext'
create_dir_gameserver '/home/gameserver/khanat'
create_dir_gameserver '/home/gameserver/khanat/rootweb'
####################################
# End

View file

@ -1,34 +0,0 @@
# Dockerfile - Build image to prepare 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM i386/debian:8
MAINTAINER AleaJactaEst
ENV HOSTNAME basic_server
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 python3 ; \
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin

View file

@ -1,33 +0,0 @@
# 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM opennel/server_generic_debian_jessie_i686
MAINTAINER AleaJactaEst
ENV HOSTNAME khanat_server
COPY server/debian/common/servercontainer_function.sh /opt/
COPY server/debian/common/servercontainer_init_* /opt/
COPY output/opennel_debian_jessie_i686/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

View file

@ -1,33 +0,0 @@
# 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM opennel/server_generic_debian_jessie_i686
MAINTAINER AleaJactaEst
ENV HOSTNAME khanat_server
COPY todelete.sh /opt/khanat_config.sh
COPY server/debian/common/ /opt/
COPY output/extra/ryzomcore.tar.gz /opt/
COPY output/extra/ryzom-ressources.tar.gz /opt/
COPY output/extra/khanat-ressources.tar.gz /opt/
COPY output/extra/khanat-client-data.tar.gz /opt/
RUN /opt/serverimage_init_khanat.sh

View file

@ -1,537 +0,0 @@
#!/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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
declare -i REMOVE=0
declare -i IMAGE=1
declare -i BASICSERVER=0
declare -i KHANATSERVER=0
declare -i CONFIGUREKHANATSERVER=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="opennel/server_generic_debian_jessie_i686"
declare IMAGEKHANATSERVER="opennel/servercontainer_debian_jessie_i686"
declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_i686"
declare DIROUTPUT="output/opennel_debian_jessie_i686"
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_CLIENT_DATA_DIR=""
declare OPENNEL_CODE_DIR=""
declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok"
declare DIRCLIENT="Khanat_Linux32"
declare PACKAGECLIENT="smokey_linux32"
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=[DIR] : localization khanat-ressources
--khanat-client-data-dir=[DIR] : localization khanat-client-data
--opennel-code-dir=[DIR] : localization opennel-code
--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
--start-with-manager : start khanat with manager
--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 ${basedir}))))"
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
dataclientdir="$(dirname ${rootdir})/khanat-client-data"
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
CONFIGUREKHANATSERVER=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
;;
--start-with-manager)
METHODSTARTSERVER="--start-with-manager"
shift
;;
--client-version*)
KHANAT_CLIENT_VERSION="${1#*=}"
shift
;;
--khanat-ressources-dir=*)
KHANAT_RESSOURCES_DIR="${1#*=}"
shift
;;
--khanat-client-data-dir=*)
KHANAT_CLIENT_DATA_DIR="${1#*=}"
shift
;;
--opennel-code-dir=*)
OPENNEL_CODE_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 "[$(basename $0):$LINENO] options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "[$(basename $0):$LINENO] BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
then
msg_info "[$(basename $0):$LINENO] START"
fi
msg_debug "[$(basename $0):$LINENO] prg: $0"
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
msg_error "[$(basename $0):$LINENO] docker not installed"
exit 2
fi
case "$(uname -m)" in
x86_64)
;;
i686)
;;
*)
msg_error "[$(basename $0):$LINENO] Unknown archi : $(uname -m)"
exit 2
;;
esac
if [[ $REMOVE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] REMOVE DATA KHANAT : $ROOTDATAKHANAT"
if [[ -n "$ROOTDATAKHANAT" ]]
then
rm -rf ${ROOTDATAKHANAT}/* || exit 2
fi
fi
msg_debug "[$(basename $0):$LINENO] Create directory on host ($ROOTDATAKHANAT)"
mkdir -p $ROOTDATAKHANAT || exit 2
chmod g+s $ROOTDATAKHANAT
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
then
msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] END SSH"
exit 0
fi
if [[ $AUTODETEC -ne 0 ]]
then
msg_debug "[$(basename $0):$LINENO] 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_CLIENT_DATA_DIR" ]]
then
KHANAT_CLIENT_DATA_DIR="$(dirname $rootdir)/khanat-client-data"
fi
if [[ -z "$OPENNEL_CODE_DIR" ]]
then
OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code"
fi
if [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]]
then
CONFIGUREKHANATSERVER=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] ressourcedir: $ressourcedir"
msg_debug "[$(basename $0):$LINENO] generate basic image: $BASICSERVER"
msg_debug "[$(basename $0):$LINENO] localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}"
msg_debug "[$(basename $0):$LINENO] localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}"
msg_debug "[$(basename $0):$LINENO] localization opennel-code-client : ${OPENNEL_CODE_DIR}"
msg_debug "[$(basename $0):$LINENO] generate khanat image: $KHANATSERVER"
msg_debug "[$(basename $0):$LINENO] launch khanat: $LAUNCHKHANAT"
msg_debug "[$(basename $0):$LINENO] stop khanat: $STOPKHANAT"
msg_info "[$(basename $0):$LINENO] check khanat-ressources"
if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-ressources [${KHANAT_RESSOURCES_DIR}]"
cat << EOF
You need clone repo khanat-ressource.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git
EOF
exit 2
fi
msg_info "[$(basename $0):$LINENO] check khanat-client-data"
if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-client-data [${KHANAT_CLIENT_DATA_DIR}]"
cat << EOF
You need clone repo khanat-client-data.
cd $(dirname ${KHANAT_CLIENT_DATA_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git
EOF
exit 2
fi
if [[ ! -d ${OPENNEL_CODE_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory opennel-code [${OPENNEL_CODE_DIR}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
if [[ $STOPKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] STOP SERVER KHANAT"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT UP : ${listcontainer[@]}"
if [[ -n "$listcontainer" ]]
then
docker stop "$listcontainer" || exit 2
fi
fi
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN CONTAINER KHANAT"
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT EXITED : ${listcontainer[@]}"
if [[ -n "${listcontainer[@]}" ]]
then
docker rm --force "${listcontainer[@]}" || exit 2
fi
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "[$(basename $0):$LINENO] IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
if [[ $BASICSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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)
export DIRCLIENT="$DIRCLIENT"
export PACKAGECLIENT="$PACKAGECLIENT"
EOF
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
--file "${basedir}/Dockerfile.khanat.container" || exit 2
fi
if [[ $CONFIGUREKHANATSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CONFIGURE KHANAT SERVER"
mkdir -p $DIRLOG || exit 2
mkdir -p $DIRDATABASE || exit 2
msg_debug "[$(basename $0):$LINENO] command : cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2
fi
if [[ $UPDATEDATA -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] UPDATE KHANAT SERVER"
msg_debug "[$(basename $0):$LINENO] command: cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh
fi
if [[ $LAUNCHKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] START KHANAT SERVER"
cd $rootdir; docker run -it --hostname=khanat \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d
fi
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END"

View file

@ -1,443 +0,0 @@
#!/bin/bash
#
# Script to start 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
declare -i IMAGE=1
declare -i BASICSERVER=0
declare -i KHANATSERVER=0
declare -i KHANATRESSOURCES=0
declare -i KHANATDATACLIENT=0
declare -i RYZOMRESSOURCES=0
declare -i LAUNCHKHANAT=1
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 -i METHODSTARTSERVER=1
declare -i CLEANIMAGENONE=0
declare DOCKERBUILDOPT=""
declare OPENNEL_CODE_DIR=""
declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_i686"
declare IMAGEKHANATSERVER="opennel/serverimage_debian_jessie_i686"
declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_i686"
declare DIRCLIENT="Khanat_Linux32"
declare PACKAGECLIENT="smokey_linux32"
declare DIROUTPUT="output/extra"
usage()
{
cat << EOF
usage:$0 [options]
script to build under docker
Step:
1) generate tar with khanat-ressources
2) generate tar with ryzom-ressources
3) create image basic server
4) create image khanat server
5) launch khanat server
options:
-h, --help : Show this help
-d, --debug : Show debug message
-b, --force-basic : Force create/recreate image basic server
-t, --force-tar-ressources : Generate TAR.GZ for khanat-ressources (look directory ../khanat-ressources)
-q, --force-tar-client-data : Generate TAR.GZ for khanat-client-data (look directory ../khanat-client-data)
-z, --force-tar-ryzom-ressources : Generate TAR.GZ in data khanat-code
-k, --force-khanat : Force create/recreate image 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"
--opennel-code-dir=[DIR] : localization opennel-code
--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)
--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 ${basedir}))))"
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
dataclientdir="$(dirname ${rootdir})/khanat-client-data"
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
shift
;;
--ssh)
CONNECTSSHKHANAT=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
;;
-t|--force-tar-ressources)
KHANATRESSOURCES=1
shift
;;
-q|--force-tar-client-data)
KHANATDATACLIENT=1
shift
;;
-z|--force-tar-ryzom-ressources)
RYZOMRESSOURCES=1
shift
;;
-k|--force-khanat)
KHANATSERVER=1
shift
;;
-i|--show-ip-khanat-server)
SHOWIPKHANATSERVER=1
shift
;;
--start-khanat-with-screen)
METHODSTARTSERVER=1
shift
;;
--start-khanat-with-full-log)
METHODSTARTSERVER=2
shift
;;
--start-khanat-with-watch-state)
METHODSTARTSERVER=3
shift
;;
--client-version*)
KHANAT_CLIENT_VERSION="${1#*=}"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
;;
--option-docker-build)
DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}"
shift
;;
--opennel-code-dir=*)
OPENNEL_CODE_DIR="${1#*=}"
shift
;;
*)
msg_error "[$(basename $0):$LINENO] options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "[$(basename $0):$LINENO] BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
then
msg_info "[$(basename $0):$LINENO] START"
fi
msg_debug "[$(basename $0):$LINENO] prg: $0"
extradir="${rootdir}/${DIROUTPUT}"
mkdir -p ${extradir} || exit 2
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
msg_error "[$(basename $0):$LINENO] docker not installed"
exit 2
fi
case "$(uname -m)" in
x86_64)
;;
i686)
;;
*)
msg_error "[$(basename $0):$LINENO] Unknown archi : $(uname -m)"
exit 2
;;
esac
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
then
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 "[$(basename $0):$LINENO] END SSH"
exit 0
fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]]
then
BASICSERVER=1
fi
if [[ ! -f ${extradir}/khanat-ressources.tar.gz ]]
then
KHANATRESSOURCES=1
fi
if [[ ! -f ${extradir}/khanat-client-data.tar.gz ]]
then
KHANATDATACLIENT=1
fi
if [[ ! -f ${extradir}/ryzom-ressources.tar.gz ]]
then
RYZOMRESSOURCES=1
fi
if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]]
then
KHANATSERVER=1
fi
if [[ -z "$OPENNEL_CODE_DIR" ]]
then
OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code"
fi
if [[ -f ${extradir}/ryzomcore.tar.gz ]]
then
sumsrc=$(md5sum ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz | awk '{print $1}')
sumdst=$(md5sum ${extradir}/ryzomcore.tar.gz | awk '{print $1}')
else
sumsrc=1
sumdsr=2
fi
msg_debug "[$(basename $0):$LINENO] ryzomcore checksum src:$sumsrc dst:$sumdst"
if [[ "$sumsrc" != "$sumdst" ]]
then
msg_debug "[$(basename $0):$LINENO] copy ryzomcore"
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${extradir}/ryzomcore.tar.gz || exit 2
KHANATSERVER=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] ressourcedir: $ressourcedir"
msg_debug "[$(basename $0):$LINENO] generate basic image: $BASICSERVER"
msg_debug "[$(basename $0):$LINENO] generate tar khanat ressources: $KHANATRESSOURCES"
msg_debug "[$(basename $0):$LINENO] generate tar khanat data client: $KHANATDATACLIENT"
msg_debug "[$(basename $0):$LINENO] generate tar ryzom ressources: $RYZOMRESSOURCES"
msg_debug "[$(basename $0):$LINENO] generate khanat image: $KHANATSERVER"
msg_debug "[$(basename $0):$LINENO] launch khanat: $LAUNCHKHANAT"
msg_debug "[$(basename $0):$LINENO] stop khanat: $STOPKHANAT"
if [[ ! -d ${OPENNEL_CODE_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory opennel-code [${OPENNEL_CODE_DIR}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
if [[ $KHANATRESSOURCES -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with KHANAT Ressources"
if [[ ! -d ${ressourcedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-ressources directory ($ressourcedir)"
exit 2
fi
(cd $ressourcedir; tar --exclude='.git' -czf ${extradir}/khanat-ressources.tar.gz .) || exit 2
fi
if [[ $KHANATDATACLIENT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with KHANAT DATA CLIENT"
if [[ ! -d ${dataclientdir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-client-data directory ($dataclientdir)"
exit 2
fi
(cd $dataclientdir; tar --exclude='.git' -czf ${extradir}/khanat-client-data.tar.gz .) || exit 2
fi
if [[ $RYZOMRESSOURCES -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with RYZOM Ressources"
if [[ ! -d ${ressourcedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-ressources directory ($ressourcedir)"
exit 2
fi
cd ${OPENNEL_CODE_DIR}; tar czf ${extradir}/ryzom-ressources.tar.gz \
code/ryzom/server/shard.screen.rc \
code/ryzom/common/* \
code/ryzom/client/* \
code/ryzom/server/* \
code/ryzom/tools/scripts/linux/* \
code/web/* || exit 2
fi
if [[ $STOPKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] STOP SERVER KHANAT"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT UP : ${listcontainer[@]}"
if [[ -n "$listcontainer" ]]
then
docker stop "$listcontainer" || exit 2
fi
fi
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN CONTAINER KHANAT"
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT EXITED : ${listcontainer[@]}"
if [[ -n "${listcontainer[@]}" ]]
then
docker rm --force "${listcontainer[@]}" || exit 2
fi
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "[$(basename $0):$LINENO] IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
if [[ $BASICSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] GENERATE DOCKER IMAGE KHANAT SERVER"
cat << EOF > $rootdir/todelete.sh
#!/bin/bash
# Temporary file, use only to send some information on build docker
export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION
export DIRCLIENT="$DIRCLIENT"
export PACKAGECLIENT="$PACKAGECLIENT"
EOF
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
--file "${basedir}/Dockerfile.khanat.image" || exit 2
rm $rootdir/todelete.sh
fi
if [[ $LAUNCHKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] START KHANAT SERVER"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
${IMAGEKHANATSERVER} /opt/serverimage_autostart.sh $METHODSTARTSERVER
clear
fi
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END"

View file

@ -1,34 +0,0 @@
# Dockerfile - Build image to prepare 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM amd64/debian:8
MAINTAINER AleaJactaEst
ENV HOSTNAME basic_server
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 python3 ; \
DEBIAN_FRONTEND=noninteractive apt-get install -y phpmyadmin

View file

@ -1,33 +0,0 @@
# 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM opennel/server_generic_debian_jessie_x86_64
MAINTAINER AleaJactaEst
ENV HOSTNAME khanat_server
COPY server/debian/common/servercontainer_function.sh /opt/
COPY server/debian/common/servercontainer_init_* /opt/
COPY output/opennel_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

View file

@ -1,33 +0,0 @@
# 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
FROM opennel/server_generic_debian_jessie_x86_64
MAINTAINER AleaJactaEst
ENV HOSTNAME khanat_server
COPY todelete.sh /opt/khanat_config.sh
COPY server/debian/common/ /opt/
COPY output/extra/ryzomcore.tar.gz /opt/
COPY output/extra/ryzom-ressources.tar.gz /opt/
COPY output/extra/khanat-ressources.tar.gz /opt/
COPY output/extra/khanat-client-data.tar.gz /opt/
RUN /opt/serverimage_init_khanat.sh

View file

@ -1,537 +0,0 @@
#!/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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
declare -i REMOVE=0
declare -i IMAGE=1
declare -i BASICSERVER=0
declare -i KHANATSERVER=0
declare -i CONFIGUREKHANATSERVER=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="opennel/server_generic_debian_jessie_x86_64"
declare IMAGEKHANATSERVER="opennel/servercontainer_debian_jessie_x86_64"
declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_x86_64"
declare DIROUTPUT="output/opennel_debian_jessie_x86_64"
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_CLIENT_DATA_DIR=""
declare OPENNEL_CODE_DIR=""
declare STEP_CONFIGURE_OK="$ROOTDATAKHANAT/khanat/step_configure.ok"
declare DIRCLIENT="Khanat_Linux64"
declare PACKAGECLIENT="smokey_linux64"
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=[DIR] : localization khanat-ressources
--khanat-client-data-dir=[DIR] : localization khanat-client-data
--opennel-code-dir=[DIR] : localization opennel-code
--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
--start-with-manager : start khanat with manager
--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 ${basedir}))))"
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
dataclientdir="$(dirname ${rootdir})/khanat-client-data"
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
CONFIGUREKHANATSERVER=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
;;
--start-with-manager)
METHODSTARTSERVER="--start-with-manager"
shift
;;
--client-version*)
KHANAT_CLIENT_VERSION="${1#*=}"
shift
;;
--khanat-ressources-dir=*)
KHANAT_RESSOURCES_DIR="${1#*=}"
shift
;;
--khanat-client-data-dir=*)
KHANAT_CLIENT_DATA_DIR="${1#*=}"
shift
;;
--opennel-code-dir=*)
OPENNEL_CODE_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 "[$(basename $0):$LINENO] options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "[$(basename $0):$LINENO] BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
then
msg_info "[$(basename $0):$LINENO] START"
fi
msg_debug "[$(basename $0):$LINENO] prg: $0"
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
msg_error "[$(basename $0):$LINENO] docker not installed"
exit 2
fi
case "$(uname -m)" in
x86_64)
;;
i686)
;;
*)
msg_error "[$(basename $0):$LINENO] Unknown archi : $(uname -m)"
exit 2
;;
esac
if [[ $REMOVE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] REMOVE DATA KHANAT : $ROOTDATAKHANAT"
if [[ -n "$ROOTDATAKHANAT" ]]
then
rm -rf ${ROOTDATAKHANAT}/* || exit 2
fi
fi
msg_debug "[$(basename $0):$LINENO] Create directory on host ($ROOTDATAKHANAT)"
mkdir -p $ROOTDATAKHANAT || exit 2
chmod g+s $ROOTDATAKHANAT
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
then
msg_debug "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] END SSH"
exit 0
fi
if [[ $AUTODETEC -ne 0 ]]
then
msg_debug "[$(basename $0):$LINENO] 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_CLIENT_DATA_DIR" ]]
then
KHANAT_CLIENT_DATA_DIR="$(dirname $rootdir)/khanat-client-data"
fi
if [[ -z "$OPENNEL_CODE_DIR" ]]
then
OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code"
fi
if [[ ! (-f $rootdir/$STEP_CONFIGURE_OK) ]]
then
CONFIGUREKHANATSERVER=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] ressourcedir: $ressourcedir"
msg_debug "[$(basename $0):$LINENO] generate basic image: $BASICSERVER"
msg_debug "[$(basename $0):$LINENO] localization khanat-ressources : ${KHANAT_RESSOURCES_DIR}"
msg_debug "[$(basename $0):$LINENO] localization khanat-client-data: ${KHANAT_CLIENT_DATA_DIR}"
msg_debug "[$(basename $0):$LINENO] localization opennel-code-client : ${OPENNEL_CODE_DIR}"
msg_debug "[$(basename $0):$LINENO] generate khanat image: $KHANATSERVER"
msg_debug "[$(basename $0):$LINENO] launch khanat: $LAUNCHKHANAT"
msg_debug "stop khanat: $STOPKHANAT"
msg_info "[$(basename $0):$LINENO] check khanat-ressources"
if [[ ! -d ${KHANAT_RESSOURCES_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-ressources [${KHANAT_RESSOURCES_DIR}]"
cat << EOF
You need clone repo khanat-ressource.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-ressources.git
EOF
exit 2
fi
msg_info "[$(basename $0):$LINENO] check khanat-client-data"
if [[ ! -d ${KHANAT_CLIENT_DATA_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory khanat-client-data [${KHANAT_CLIENT_DATA_DIR}]"
cat << EOF
You need clone repo khanat-client-data.
cd $(dirname ${KHANAT_CLIENT_DATA_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-client-data.git
EOF
exit 2
fi
if [[ ! -d ${OPENNEL_CODE_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory opennel-code [${OPENNEL_CODE_DIR}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
if [[ $STOPKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] STOP SERVER KHANAT"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT UP : ${listcontainer[@]}"
if [[ -n "$listcontainer" ]]
then
docker stop "$listcontainer" || exit 2
fi
fi
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN CONTAINER KHANAT"
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT EXITED : ${listcontainer[@]}"
if [[ -n "${listcontainer[@]}" ]]
then
docker rm --force "${listcontainer[@]}" || exit 2
fi
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "[$(basename $0):$LINENO] IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
if [[ $BASICSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] 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)
export DIRCLIENT="$DIRCLIENT"
export PACKAGECLIENT="$PACKAGECLIENT"
EOF
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
--file "${basedir}/Dockerfile.khanat.container" || exit 2
fi
if [[ $CONFIGUREKHANATSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CONFIGURE KHANAT SERVER"
mkdir -p $DIRLOG || exit 2
mkdir -p $DIRDATABASE || exit 2
msg_debug "[$(basename $0):$LINENO] command : cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_configure_auto.sh || exit 2
fi
if [[ $UPDATEDATA -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] UPDATE KHANAT SERVER"
msg_debug "[$(basename $0):$LINENO] command: cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_update_auto.sh
fi
if [[ $LAUNCHKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] START KHANAT SERVER"
cd $rootdir; docker run -it --hostname=khanat \
-u "$(id -u $USERNAME):$(id -g $USERNAME)" \
-v /etc/localtime:/etc/localtime:ro \
-v ${rootdir}/${LOCALBUILDDIR}/bin:/usr/local/bin:ro \
-v ${OPENNEL_CODE_DIR}/code/web/:/home/gameserver/ext/khanatweb:ro \
-v ${OPENNEL_CODE_DIR}/code/ryzom:/home/gameserver/ext/ryzom-ressources:ro \
-v ${KHANAT_RESSOURCES_DIR}:/home/gameserver/ext/khanat-ressources:ro \
-v ${KHANAT_CLIENT_DATA_DIR}:/home/gameserver/ext/khanat-client-data:ro \
-v ${rootdir}/$DIRLOG:/home/gameserver/log:rw \
-v ${rootdir}/$DIRDATABASE:/home/gameserver/database:rw \
-v ${rootdir}/$DIRKHANAT:/home/gameserver/khanat:rw \
-v ${rootdir}/server/debian/common/:/opt/ext:ro \
${IMAGEKHANATSERVER} /opt/ext/servercontainer_launch_auto.sh $METHODSTARTSERVER -d
fi
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END"

View file

@ -1,441 +0,0 @@
#!/bin/bash
#
# Script to start 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 Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
declare -i IMAGE=1
declare -i BASICSERVER=0
declare -i KHANATSERVER=0
declare -i KHANATRESSOURCES=0
declare -i KHANATDATACLIENT=0
declare -i RYZOMRESSOURCES=0
declare -i LAUNCHKHANAT=1
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 -i METHODSTARTSERVER=1
declare -i CLEANIMAGENONE=0
declare DOCKERBUILDOPT=""
declare IMAGEGENERICSERVER="opennel/server_generic_debian_jessie_x86_64"
declare IMAGEKHANATSERVER="opennel/serverimage_debian_jessie_x86_64"
declare LOCALBUILDDIR="build/opennel/builder_debian_jessie_x86_64"
declare DIRCLIENT="Khanat_Linux64"
declare PACKAGECLIENT="smokey_linux64"
declare DIROUTPUT="output/extra"
usage()
{
cat << EOF
usage:$0 [options]
script to build under docker
Step:
1) generate tar with khanat-ressources
2) generate tar with ryzom-ressources
3) create image basic server
4) create image khanat server
5) launch khanat server
options:
-h, --help : Show this help
-d, --debug : Show debug message
-b, --force-basic : Force create/recreate image basic server
-t, --force-tar-ressources : Generate TAR.GZ for khanat-ressources (look directory ../khanat-ressources)
-q, --force-tar-client-data : Generate TAR.GZ for khanat-client-data (look directory ../khanat-client-data)
-z, --force-tar-ryzom-ressources : Generate TAR.GZ in data khanat-code
-k, --force-khanat : Force create/recreate image 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"
--opennel-code-dir=[DIR] : localization opennel-code
--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)
--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 ${basedir}))))"
ressourcedir="$(dirname ${rootdir})/khanat-ressources"
dataclientdir="$(dirname ${rootdir})/khanat-client-data"
while test $# -gt 0
do
case "$1" in
-h|--help)
usage
exit 1
;;
-d|--debug)
DEBUG=1
shift
;;
--ssh)
CONNECTSSHKHANAT=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
;;
-t|--force-tar-ressources)
KHANATRESSOURCES=1
shift
;;
-q|--force-tar-client-data)
KHANATDATACLIENT=1
shift
;;
-z|--force-tar-ryzom-ressources)
RYZOMRESSOURCES=1
shift
;;
-k|--force-khanat)
KHANATSERVER=1
shift
;;
-i|--show-ip-khanat-server)
SHOWIPKHANATSERVER=1
shift
;;
--start-khanat-with-screen)
METHODSTARTSERVER=1
shift
;;
--start-khanat-with-full-log)
METHODSTARTSERVER=2
shift
;;
--start-khanat-with-watch-state)
METHODSTARTSERVER=3
shift
;;
--client-version*)
KHANAT_CLIENT_VERSION="${1#*=}"
shift
;;
-w|--clean-images-none)
CLEANIMAGENONE=1
shift
;;
--option-docker-build)
DOCKERBUILDOPT="$DOCKERBUILDOPT ${1#*=}"
shift
;;
--opennel-code-dir=*)
OPENNEL_CODE_DIR="${1#*=}"
shift
;;
*)
msg_error "options '$1' not recognize"
usage
exit 1
;;
esac
done
function chrashed()
{
msg_error "BUILD FAILED (code:$?)"
exit 2
}
trap chrashed EXIT
if [[ $SHOWIPKHANATSERVER -eq 0 ]]
then
msg_info "[$(basename $0):$LINENO] START"
fi
msg_debug "[$(basename $0):$LINENO] prg: $0"
extradir="${rootdir}/${DIROUTPUT}"
mkdir -p ${extradir} || exit 2
docker -v 1>/dev/null
if [[ $? -ne 0 ]]
then
msg_error "[$(basename $0):$LINENO] docker not installed"
exit 2
fi
case "$(uname -m)" in
x86_64)
;;
i686)
;;
*)
msg_error "[$(basename $0):$LINENO] Unknown archi : $(uname -m)"
exit 2
;;
esac
if [[ ($CONNECTSSHKHANAT -ne 0) || ($SHOWIPKHANATSERVER -ne 0) ]]
then
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 "[$(basename $0):$LINENO] END SSH"
exit 0
fi
if [[ $AUTODETEC -ne 0 ]]
then
if [[ $(docker images -f "reference=$IMAGEGENERICSERVER" | wc -l) -lt 2 ]]
then
BASICSERVER=1
fi
if [[ ! -f ${extradir}/khanat-ressources.tar.gz ]]
then
KHANATRESSOURCES=1
fi
if [[ ! -f ${extradir}/khanat-client-data.tar.gz ]]
then
KHANATDATACLIENT=1
fi
if [[ ! -f ${extradir}/ryzom-ressources.tar.gz ]]
then
RYZOMRESSOURCES=1
fi
if [[ $(docker images -f "reference=$IMAGEKHANATSERVER" | wc -l) -lt 2 ]]
then
KHANATSERVER=1
fi
if [[ -z "$OPENNEL_CODE_DIR" ]]
then
OPENNEL_CODE_DIR="$(dirname $rootdir)/khanat-opennel-code"
fi
if [[ -f ${extradir}/ryzomcore.tar.gz ]]
then
sumsrc=$(md5sum ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz | awk '{print $1}')
sumdst=$(md5sum ${extradir}/ryzomcore.tar.gz | awk '{print $1}')
else
sumsrc=1
sumdsr=2
fi
msg_debug "[$(basename $0):$LINENO] ryzomcore checksum src:$sumsrc dst:$sumdst"
if [[ "$sumsrc" != "$sumdst" ]]
then
msg_debug "[$(basename $0):$LINENO] copy ryzomcore"
cp ${rootdir}/${LOCALBUILDDIR}/ryzomcore-0.12.0..tar.gz ${extradir}/ryzomcore.tar.gz || exit 2
KHANATSERVER=1
fi
fi
DIRBUILD="${rootdir}/${LOCALBUILDDIR}"
msg_debug "[$(basename $0):$LINENO] calldir: $calldir"
msg_debug "[$(basename $0):$LINENO] basedir: $basedir"
msg_debug "[$(basename $0):$LINENO] rootdir: $rootdir"
msg_debug "[$(basename $0):$LINENO] ressourcedir: $ressourcedir"
msg_debug "[$(basename $0):$LINENO] generate basic image: $BASICSERVER"
msg_debug "[$(basename $0):$LINENO] generate tar khanat ressources: $KHANATRESSOURCES"
msg_debug "[$(basename $0):$LINENO] generate tar khanat data client: $KHANATDATACLIENT"
msg_debug "[$(basename $0):$LINENO] generate tar ryzom ressources: $RYZOMRESSOURCES"
msg_debug "[$(basename $0):$LINENO] generate khanat image: $KHANATSERVER"
msg_debug "[$(basename $0):$LINENO] launch khanat: $LAUNCHKHANAT"
msg_debug "[$(basename $0):$LINENO] stop khanat: $STOPKHANAT"
if [[ ! -d ${OPENNEL_CODE_DIR} ]]
then
msg_error "[$(basename $0):$LINENO] Missing directory opennel-code [${OPENNEL_CODE_DIR}]"
cat << EOF
You need clone repo khanat-opennel-code.
cd $(dirname ${KHANAT_RESSOURCES_DIR})
git clone https://git.khaganat.net/khaganat/mmorpg_khanat/khanat-opennel-code.git
EOF
exit 2
fi
if [[ $KHANATRESSOURCES -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with KHANAT Ressources"
if [[ ! -d ${ressourcedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-ressources directory ($ressourcedir)"
exit 2
fi
(cd $ressourcedir; tar --exclude='.git' -czf ${extradir}/khanat-ressources.tar.gz .) || exit 2
fi
if [[ $KHANATDATACLIENT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with KHANAT DATA CLIENT"
if [[ ! -d ${dataclientdir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-client-data directory ($dataclientdir)"
exit 2
fi
(cd $dataclientdir; tar --exclude='.git' -czf ${extradir}/khanat-client-data.tar.gz .) || exit 2
fi
if [[ $RYZOMRESSOURCES -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CREATE TAR with RYZOM Ressources"
if [[ ! -d ${ressourcedir} ]]
then
msg_error "[$(basename $0):$LINENO] Missing khanat-ressources directory ($ressourcedir)"
exit 2
fi
cd ${OPENNEL_CODE_DIR}; tar czf ${extradir}/ryzom-ressources.tar.gz \
code/ryzom/server/shard.screen.rc \
code/ryzom/common/* \
code/ryzom/client/* \
code/ryzom/server/* \
code/ryzom/tools/scripts/linux/* \
code/web/* || exit 2
fi
if [[ $STOPKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] STOP SERVER KHANAT"
listcontainer="$(docker ps -qf 'status=running' -f 'ancestor='"${IMAGEKHANATSERVER}"'')"
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT UP : ${listcontainer[@]}"
if [[ -n "$listcontainer" ]]
then
docker stop "$listcontainer" || exit 2
fi
fi
if [[ $CLEANCONTAINERKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN CONTAINER KHANAT"
listcontainer=( $(docker ps -qf 'status=exited' -f 'ancestor='"${IMAGEKHANATSERVER}"'') )
msg_debug "[$(basename $0):$LINENO] CONTAINER KHANAT EXITED : ${listcontainer[@]}"
if [[ -n "${listcontainer[@]}" ]]
then
docker rm --force "${listcontainer[@]}" || exit 2
fi
fi
if [[ $CLEANIMAGENONE -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] CLEAN IMAGE DOCKER 'NONE'"
listimages=( $(docker images --filter "dangling=true" --format "{{.ID}}") )
msg_debug "[$(basename $0):$LINENO] IMAGES NONE : ${listimages[@]}"
if [[ -n "${listimages[@]}" ]]
then
docker rmi --force "${listimages[@]}" || exit 2
fi
fi
if [[ $BASICSERVER -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] 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 "[$(basename $0):$LINENO] GENERATE DOCKER IMAGE KHANAT SERVER"
cat << EOF > $rootdir/todelete.sh
#!/bin/bash
# Temporary file, use only to send some information on build docker
export KHANAT_CLIENT_VERSION=$KHANAT_CLIENT_VERSION
export DIRCLIENT="$DIRCLIENT"
export PACKAGECLIENT="$PACKAGECLIENT"
EOF
cd $rootdir; docker build . ${DOCKERBUILDOPT} -t ${IMAGEKHANATSERVER} \
--file "${basedir}/Dockerfile.khanat.image" || exit 2
rm $rootdir/todelete.sh
fi
if [[ $LAUNCHKHANAT -ne 0 ]]
then
msg_info "[$(basename $0):$LINENO] START KHANAT SERVER"
cd $rootdir; docker run -it --hostname=khanat \
-v /etc/localtime:/etc/localtime:ro \
${IMAGEKHANATSERVER} /opt/serverimage_autostart.sh $METHODSTARTSERVER
clear
fi
trap '' EXIT
msg_info "[$(basename $0):$LINENO] END"