Fixed a lot of syntax error in entrypoint.sh and tmserver

This commit is contained in:
Hendrik Boll 2019-05-11 23:06:03 +02:00
parent ebb664cd37
commit 50dd3690ee
3 changed files with 81 additions and 48 deletions

View File

@ -1,7 +1,9 @@
FROM fanyx/php:5.6 FROM fanyx/php:5.6
COPY tmserver/ /opt/ RUN mkdir /opt/tmserver /opt/xaseco
COPY xaseco/ /opt/
COPY tmserver/ /opt/tmserver/
COPY xaseco/ /opt/xaseco/
COPY ./entrypoint.sh / COPY ./entrypoint.sh /
RUN apt update \ RUN apt update \
@ -14,4 +16,4 @@ RUN chown trackmania:trackmania /entrypoint.sh
USER trackmania USER trackmania
WORKDIR /opt/tmserver WORKDIR /opt/tmserver
CMD ["/bin/bash", "/entrypoint.sh", "start", "tmserver"] CMD ["bash"]

View File

@ -62,25 +62,28 @@ fi
#Xaseco files #Xaseco files
cd /opt/xaseco cd /opt/xaseco
pwd
sed -i -e "s/--\$SERVER_SA_PASSWORD--/\${SERVER_SA_PASSWORD}/" /opt/xaseco/config.xml sed -i -e "s/--\$SERVER_SA_PASSWORD--/$SERVER_SA_PASSWORD/" /opt/xaseco/config.xml
sed -i -e "s/--\$DB_HOST--/\${DB_HOST}/" \ sed -i -e "s/--\$DB_HOST--/$DB_HOST/" \
-e "s/--\$DB_LOGIN--/\${DB_LOGIN}/" \ -e "s/--\$DB_LOGIN--/$DB_LOGIN/" \
-e "s/--\$DB_LOGIN_PASSWORD--/\${DB_LOGIN_PASSWORD}/" \ -e "s/--\$DB_LOGIN_PASSWORD--/$DB_LOGIN_PASSWORD/" \
-e "s/--\$DB_NAME--/\${DB_NAME}/" \ -e "s/--\$DB_NAME--/$DB_NAME/" \
/opt/xaseco/localdatabase.xml /opt/xaseco/localdatabase.xml
#Trackmania Files #Trackmania Files
cd /opt/tmserver cd /opt/tmserver
pwd
sed -i -e "s/--\$SERVER_SA_PASSWORD--/\${SERVER_SA_PASSWORD}/" \ sed -i -e "s/--\$SERVER_SA_PASSWORD--/$SERVER_SA_PASSWORD/" \
-e "s/--\$SERVER_ADM_PASSWORD--\/${SERVER_ADM_PASSWORD}/" \ -e "s/--\$SERVER_ADM_PASSWORD--/$SERVER_ADM_PASSWORD/" \
-e "s/--\$SERVER_LOGIN--/\${SERVER_LOGIN}/" \ -e "s/--\$SERVER_LOGIN--/$SERVER_LOGIN/" \
-e "s/--\$SERVER_LOGIN_PASSWORD--/\${SERVER_LOGIN_PASSWORD}/" \ -e "s/--\$SERVER_LOGIN_PASSWORD--/$SERVER_LOGIN_PASSWORD/" \
-e "s/--\$SERVER_NAME--/\${SERVER_NAME}/" \ -e "s/--\$SERVER_NAME--/$SERVER_NAME/" \
-e "s/--\$SERVER_COMMENT--/\${SERVER_COMMENT}/" \ -e "s/--\$SERVER_COMMENT--/$SERVER_COMMENT/" \
-e "s/--\$SERVER_PASSWORD--/\${SERVER_PASSWORD}/" \ -e "s/--\$SERVER_PASSWORD--/$SERVER_PASSWORD/" \
-e "s/--\$SERVER_PORT--/\${SERVER_PORT}/" \ -e "s/--\$SERVER_PORT--/$SERVER_PORT/" \
-e "s/--\$SERVER_P2P_PORT--/\${SERVER_P2P_PORT}/" \ -e "s/--\$SERVER_P2P_PORT--/$SERVER_P2P_PORT/" \
/opt/tmserver/GameData/Config/default.txt /opt/tmserver/GameData/Config/default.txt

View File

@ -14,7 +14,8 @@ DEDICATED_CFG="${DEDICATED_CFG:-default.txt}"
set -e set -e
if [[ "$1" = 'start' ]] && [[ "$(id -u)" = '0']]; then if [[ "$1" = "start" && "$(id -u)" = "0" ]]
then
chown -R trackmania:trackmania /opt/tmserver chown -R trackmania:trackmania /opt/tmserver
chown -R trackmania:trackmania /opt/xaseco chown -R trackmania:trackmania /opt/xaseco
su trackmania "$0" "$@" su trackmania "$0" "$@"
@ -25,8 +26,10 @@ case "$1" in
case "$2" in case "$2" in
tmserver) tmserver)
cd $TMDIR cd $TMDIR
if [[ -e tmserver.pid ]]; then if [[ -e tmserver.pid ]]
if ( kill -0 $(cat tmserver.pid) 2> /dev/null ); then then
if ( kill -0 $(cat tmserver.pid) 2> /dev/null )
then
echo "The server is already running, try restart or stop." echo "The server is already running, try restart or stop."
exit 1 exit 1
else else
@ -35,28 +38,34 @@ case "$1" in
rm tmserver.pid rm tmserver.pid
fi fi
fi fi
if [[ "$(id -u)" = "0" ]]; then if [[ "$(id -u)" = "0" ]]
then
echo "WARNING! For security reasons i don't advise to run the server as ROOT!" echo "WARNING! For security reasons i don't advise to run the server as ROOT!"
fi fi
echo "Starting the Trackmania server" echo "Starting the Trackmania server"
if [[ -e "./TrackmaniaServer" ]]; then if [[ -e "./TrackmaniaServer" ]]
if [[ ! -x "./TrackmaniaServer" ]]; then then
if [[ ! -x "./TrackmaniaServer" ]]
then
echo "TrackmaniaServer is not executable, trying to set +x" echo "TrackmaniaServer is not executable, trying to set +x"
chmod u+x "./TrackmaniaServer" chmod u+x "./TrackmaniaServer"
fi fi
if [[ -x "./TrackmaniaServer" ]]; then if [[ -x "./TrackmaniaServer" ]]
then
cd $ASECODIR cd $ASECODIR
if [[ -e aseco.pid ]]; then if [[ -e aseco.pid ]]
then
echo "Stopping Xaseco in case it was running." echo "Stopping Xaseco in case it was running."
echo "Xaseco cannot be running when starting the Trackmania server." echo "Xaseco cannot be running when starting the Trackmania server."
"$0" "stop" "xaseco" "$0" "stop" "xaseco"
fi fi
cd $TMDIR
"./TrackmaniaServer /internet /game_settings=${GAME_SETTINGS} /dedicated_cfg=${DEDICATED_CFG}" & ./TrackmaniaServer /internet /game_settings=${GAME_SETTINGS} /dedicated_cfg=${DEDICATED_CFG} &
PID=$! PID=$!
ps -p ${PID} > /dev/null 2>&1 ps -p ${PID} > /dev/null 2>&1
if [[ "$?" -ne "0" ]]; then if [[ "$?" -ne "0" ]]
then
echo "Trackmania server could not start" echo "Trackmania server could not start"
else else
echo "Trackmania server started" echo "Trackmania server started"
@ -75,8 +84,10 @@ case "$1" in
;; ;;
xaseco) xaseco)
cd $ASECODIR cd $ASECODIR
if [[ -e aseco.pid ]]; then if [[ -e aseco.pid ]]
if ( kill -0 $(cat aseco.pid) 2> /dev/null ); then then
if ( kill -0 $(cat aseco.pid) 2> /dev/null )
then
echo "Xaseco is already running." echo "Xaseco is already running."
exit 1 exit 1
else else
@ -85,15 +96,18 @@ case "$1" in
rm aseco.pid rm aseco.pid
fi fi
fi fi
if [[ "$(id -u)" = "0" ]]; then if [[ "$(id -u)" = "0" ]]
then
echo "WARNING! For security reasons i don't advise to run the server as ROOT!" echo "WARNING! For security reasons i don't advise to run the server as ROOT!"
fi fi
echo "Starting the Xaseco service" echo "Starting the Xaseco service"
if [[ -e "./aseco.php" ]]; then if [[ -e "./aseco.php" ]]
"php aseco.php TMF </dev/null >aseco.log 2>&1" & then
php ./aseco.php TMF </dev/null >aseco.log 2>&1 &
PID=$! PID=$!
ps -p ${PID} > /dev/null 2>&1 ps -p ${PID} > /dev/null 2>&1
if [[ "$?" -ne "0" ]]; then if [[ "$?" -ne "0" ]]
then
echo "Xaseco could not start" echo "Xaseco could not start"
else else
echo "Xaseco started. Please test the functionality ingame." echo "Xaseco started. Please test the functionality ingame."
@ -115,12 +129,16 @@ case "$1" in
case "$2" in case "$2" in
tmserver) tmserver)
cd $TMDIR cd $TMDIR
if [[ -e tmserver.pid ]]; then if [[ -e tmserver.pid ]]
then
echo -n "Stopping the Trackmania server" echo -n "Stopping the Trackmania server"
if ( kill -TERM $(cat tmserver.pid) 2> /dev/null ); then if ( kill -TERM $(cat tmserver.pid) 2> /dev/null )
then
c=1 c=1
while [[ "$c" -le 120 ]]; do while [[ "$c" -le 120 ]]
if (kill -0 $(cat tmserver.pid) 2> /dev/null); then do
if (kill -0 $(cat tmserver.pid) 2> /dev/null)
then
echo -n "." echo -n "."
sleep 1 sleep 1
else else
@ -129,7 +147,8 @@ case "$1" in
c=$(($c+1)) c=$(($c+1))
done done
fi fi
if ( kill -0 $(cat tmserver.pid) 2> /dev/null ); then if ( kill -0 $(cat tmserver.pid) 2> /dev/null )
then
echo "Server is not shutting down cleanly - killing the process" echo "Server is not shutting down cleanly - killing the process"
kill -KILL $(cat tmserver.pid) kill -KILL $(cat tmserver.pid)
else else
@ -145,12 +164,16 @@ case "$1" in
;; ;;
xaseco) xaseco)
cd $ASECODIR cd $ASECODIR
if [[ -e aseco.pid ]]; then if [[ -e aseco.pid ]]
then
echo -n "Stopping the Xaseco service" echo -n "Stopping the Xaseco service"
if ( kill -TERM $(cat aseco.pid) 2> /dev/null ); then if ( kill -TERM $(cat aseco.pid) 2> /dev/null )
then
c=1 c=1
while [[ "$c" -le 120 ]]; do while [[ "$c" -le 120 ]]
if (kill -0 $(cat aseco.pid) 2> /dev/null ); then do
if (kill -0 $(cat aseco.pid) 2> /dev/null )
then
echo -n "." echo -n "."
sleep 1 sleep 1
else else
@ -159,7 +182,8 @@ case "$1" in
c=$(($c+1)) c=$(($c+1))
done done
fi fi
if (kill -0 $(cat aseco.pid) 2> /dev/null ); then if (kill -0 $(cat aseco.pid) 2> /dev/null )
then
echo "Xaseco is not shutting down cleanly - killing the process" echo "Xaseco is not shutting down cleanly - killing the process"
kill -KILL $(cat aseco.pid) kill -KILL $(cat aseco.pid)
else else
@ -195,8 +219,10 @@ case "$1" in
case "$2" in case "$2" in
tmserver) tmserver)
cd $TMDIR cd $TMDIR
if [[ -e tmserver.pid ]]; then if [[ -e tmserver.pid ]]
if (kill -0 $(cat tmserver.pid) 2> /dev/null ); then then
if (kill -0 $(cat tmserver.pid) 2> /dev/null )
then
echo "Trackmania server is up and running." echo "Trackmania server is up and running."
echo "In case of connectivity problems, try restarting your client" echo "In case of connectivity problems, try restarting your client"
echo "If nothing helps use ./tmservser restart tmserver" echo "If nothing helps use ./tmservser restart tmserver"
@ -209,8 +235,10 @@ case "$1" in
;; ;;
xaseco) xaseco)
cd $ASECODIR cd $ASECODIR
if [[ -e aseco.pid]]; then if [[ -e aseco.pid ]]
if (kill -0 $(cat aseco.pid) 2> /dev/null ); then then
if (kill -0 $(cat aseco.pid) 2> /dev/null )
then
echo "Xaseco is up and running." echo "Xaseco is up and running."
echo "In case of missing features ingame, try restarting the whole server." echo "In case of missing features ingame, try restarting the whole server."
echo "Use ./tmserver restart tmserver" echo "Use ./tmserver restart tmserver"