Fixed a lot of syntax error in entrypoint.sh and tmserver
This commit is contained in:
parent
ebb664cd37
commit
50dd3690ee
|
@ -1,7 +1,9 @@
|
|||
FROM fanyx/php:5.6
|
||||
|
||||
COPY tmserver/ /opt/
|
||||
COPY xaseco/ /opt/
|
||||
RUN mkdir /opt/tmserver /opt/xaseco
|
||||
|
||||
COPY tmserver/ /opt/tmserver/
|
||||
COPY xaseco/ /opt/xaseco/
|
||||
COPY ./entrypoint.sh /
|
||||
|
||||
RUN apt update \
|
||||
|
@ -14,4 +16,4 @@ RUN chown trackmania:trackmania /entrypoint.sh
|
|||
|
||||
USER trackmania
|
||||
WORKDIR /opt/tmserver
|
||||
CMD ["/bin/bash", "/entrypoint.sh", "start", "tmserver"]
|
||||
CMD ["bash"]
|
||||
|
|
|
@ -62,25 +62,28 @@ fi
|
|||
|
||||
#Xaseco files
|
||||
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}/" \
|
||||
-e "s/--\$DB_LOGIN--/\${DB_LOGIN}/" \
|
||||
-e "s/--\$DB_LOGIN_PASSWORD--/\${DB_LOGIN_PASSWORD}/" \
|
||||
-e "s/--\$DB_NAME--/\${DB_NAME}/" \
|
||||
sed -i -e "s/--\$DB_HOST--/$DB_HOST/" \
|
||||
-e "s/--\$DB_LOGIN--/$DB_LOGIN/" \
|
||||
-e "s/--\$DB_LOGIN_PASSWORD--/$DB_LOGIN_PASSWORD/" \
|
||||
-e "s/--\$DB_NAME--/$DB_NAME/" \
|
||||
/opt/xaseco/localdatabase.xml
|
||||
|
||||
#Trackmania Files
|
||||
cd /opt/tmserver
|
||||
pwd
|
||||
|
||||
sed -i -e "s/--\$SERVER_SA_PASSWORD--/\${SERVER_SA_PASSWORD}/" \
|
||||
-e "s/--\$SERVER_ADM_PASSWORD--\/${SERVER_ADM_PASSWORD}/" \
|
||||
-e "s/--\$SERVER_LOGIN--/\${SERVER_LOGIN}/" \
|
||||
-e "s/--\$SERVER_LOGIN_PASSWORD--/\${SERVER_LOGIN_PASSWORD}/" \
|
||||
-e "s/--\$SERVER_NAME--/\${SERVER_NAME}/" \
|
||||
-e "s/--\$SERVER_COMMENT--/\${SERVER_COMMENT}/" \
|
||||
-e "s/--\$SERVER_PASSWORD--/\${SERVER_PASSWORD}/" \
|
||||
-e "s/--\$SERVER_PORT--/\${SERVER_PORT}/" \
|
||||
-e "s/--\$SERVER_P2P_PORT--/\${SERVER_P2P_PORT}/" \
|
||||
sed -i -e "s/--\$SERVER_SA_PASSWORD--/$SERVER_SA_PASSWORD/" \
|
||||
-e "s/--\$SERVER_ADM_PASSWORD--/$SERVER_ADM_PASSWORD/" \
|
||||
-e "s/--\$SERVER_LOGIN--/$SERVER_LOGIN/" \
|
||||
-e "s/--\$SERVER_LOGIN_PASSWORD--/$SERVER_LOGIN_PASSWORD/" \
|
||||
-e "s/--\$SERVER_NAME--/$SERVER_NAME/" \
|
||||
-e "s/--\$SERVER_COMMENT--/$SERVER_COMMENT/" \
|
||||
-e "s/--\$SERVER_PASSWORD--/$SERVER_PASSWORD/" \
|
||||
-e "s/--\$SERVER_PORT--/$SERVER_PORT/" \
|
||||
-e "s/--\$SERVER_P2P_PORT--/$SERVER_P2P_PORT/" \
|
||||
/opt/tmserver/GameData/Config/default.txt
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@ DEDICATED_CFG="${DEDICATED_CFG:-default.txt}"
|
|||
|
||||
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/xaseco
|
||||
su trackmania "$0" "$@"
|
||||
|
@ -25,8 +26,10 @@ case "$1" in
|
|||
case "$2" in
|
||||
tmserver)
|
||||
cd $TMDIR
|
||||
if [[ -e tmserver.pid ]]; then
|
||||
if ( kill -0 $(cat tmserver.pid) 2> /dev/null ); then
|
||||
if [[ -e tmserver.pid ]]
|
||||
then
|
||||
if ( kill -0 $(cat tmserver.pid) 2> /dev/null )
|
||||
then
|
||||
echo "The server is already running, try restart or stop."
|
||||
exit 1
|
||||
else
|
||||
|
@ -35,28 +38,34 @@ case "$1" in
|
|||
rm tmserver.pid
|
||||
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!"
|
||||
fi
|
||||
echo "Starting the Trackmania server"
|
||||
if [[ -e "./TrackmaniaServer" ]]; then
|
||||
if [[ ! -x "./TrackmaniaServer" ]]; then
|
||||
if [[ -e "./TrackmaniaServer" ]]
|
||||
then
|
||||
if [[ ! -x "./TrackmaniaServer" ]]
|
||||
then
|
||||
echo "TrackmaniaServer is not executable, trying to set +x"
|
||||
chmod u+x "./TrackmaniaServer"
|
||||
fi
|
||||
if [[ -x "./TrackmaniaServer" ]]; then
|
||||
if [[ -x "./TrackmaniaServer" ]]
|
||||
then
|
||||
cd $ASECODIR
|
||||
if [[ -e aseco.pid ]]; then
|
||||
if [[ -e aseco.pid ]]
|
||||
then
|
||||
echo "Stopping Xaseco in case it was running."
|
||||
echo "Xaseco cannot be running when starting the Trackmania server."
|
||||
"$0" "stop" "xaseco"
|
||||
fi
|
||||
|
||||
|
||||
"./TrackmaniaServer /internet /game_settings=${GAME_SETTINGS} /dedicated_cfg=${DEDICATED_CFG}" &
|
||||
cd $TMDIR
|
||||
./TrackmaniaServer /internet /game_settings=${GAME_SETTINGS} /dedicated_cfg=${DEDICATED_CFG} &
|
||||
PID=$!
|
||||
ps -p ${PID} > /dev/null 2>&1
|
||||
if [[ "$?" -ne "0" ]]; then
|
||||
if [[ "$?" -ne "0" ]]
|
||||
then
|
||||
echo "Trackmania server could not start"
|
||||
else
|
||||
echo "Trackmania server started"
|
||||
|
@ -75,8 +84,10 @@ case "$1" in
|
|||
;;
|
||||
xaseco)
|
||||
cd $ASECODIR
|
||||
if [[ -e aseco.pid ]]; then
|
||||
if ( kill -0 $(cat aseco.pid) 2> /dev/null ); then
|
||||
if [[ -e aseco.pid ]]
|
||||
then
|
||||
if ( kill -0 $(cat aseco.pid) 2> /dev/null )
|
||||
then
|
||||
echo "Xaseco is already running."
|
||||
exit 1
|
||||
else
|
||||
|
@ -85,15 +96,18 @@ case "$1" in
|
|||
rm aseco.pid
|
||||
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!"
|
||||
fi
|
||||
echo "Starting the Xaseco service"
|
||||
if [[ -e "./aseco.php" ]]; then
|
||||
"php aseco.php TMF </dev/null >aseco.log 2>&1" &
|
||||
if [[ -e "./aseco.php" ]]
|
||||
then
|
||||
php ./aseco.php TMF </dev/null >aseco.log 2>&1 &
|
||||
PID=$!
|
||||
ps -p ${PID} > /dev/null 2>&1
|
||||
if [[ "$?" -ne "0" ]]; then
|
||||
if [[ "$?" -ne "0" ]]
|
||||
then
|
||||
echo "Xaseco could not start"
|
||||
else
|
||||
echo "Xaseco started. Please test the functionality ingame."
|
||||
|
@ -115,12 +129,16 @@ case "$1" in
|
|||
case "$2" in
|
||||
tmserver)
|
||||
cd $TMDIR
|
||||
if [[ -e tmserver.pid ]]; then
|
||||
if [[ -e tmserver.pid ]]
|
||||
then
|
||||
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
|
||||
while [[ "$c" -le 120 ]]; do
|
||||
if (kill -0 $(cat tmserver.pid) 2> /dev/null); then
|
||||
while [[ "$c" -le 120 ]]
|
||||
do
|
||||
if (kill -0 $(cat tmserver.pid) 2> /dev/null)
|
||||
then
|
||||
echo -n "."
|
||||
sleep 1
|
||||
else
|
||||
|
@ -129,7 +147,8 @@ case "$1" in
|
|||
c=$(($c+1))
|
||||
done
|
||||
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"
|
||||
kill -KILL $(cat tmserver.pid)
|
||||
else
|
||||
|
@ -145,12 +164,16 @@ case "$1" in
|
|||
;;
|
||||
xaseco)
|
||||
cd $ASECODIR
|
||||
if [[ -e aseco.pid ]]; then
|
||||
if [[ -e aseco.pid ]]
|
||||
then
|
||||
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
|
||||
while [[ "$c" -le 120 ]]; do
|
||||
if (kill -0 $(cat aseco.pid) 2> /dev/null ); then
|
||||
while [[ "$c" -le 120 ]]
|
||||
do
|
||||
if (kill -0 $(cat aseco.pid) 2> /dev/null )
|
||||
then
|
||||
echo -n "."
|
||||
sleep 1
|
||||
else
|
||||
|
@ -159,7 +182,8 @@ case "$1" in
|
|||
c=$(($c+1))
|
||||
done
|
||||
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"
|
||||
kill -KILL $(cat aseco.pid)
|
||||
else
|
||||
|
@ -195,8 +219,10 @@ case "$1" in
|
|||
case "$2" in
|
||||
tmserver)
|
||||
cd $TMDIR
|
||||
if [[ -e tmserver.pid ]]; then
|
||||
if (kill -0 $(cat tmserver.pid) 2> /dev/null ); then
|
||||
if [[ -e tmserver.pid ]]
|
||||
then
|
||||
if (kill -0 $(cat tmserver.pid) 2> /dev/null )
|
||||
then
|
||||
echo "Trackmania server is up and running."
|
||||
echo "In case of connectivity problems, try restarting your client"
|
||||
echo "If nothing helps use ./tmservser restart tmserver"
|
||||
|
@ -209,8 +235,10 @@ case "$1" in
|
|||
;;
|
||||
xaseco)
|
||||
cd $ASECODIR
|
||||
if [[ -e aseco.pid]]; then
|
||||
if (kill -0 $(cat aseco.pid) 2> /dev/null ); then
|
||||
if [[ -e aseco.pid ]]
|
||||
then
|
||||
if (kill -0 $(cat aseco.pid) 2> /dev/null )
|
||||
then
|
||||
echo "Xaseco is up and running."
|
||||
echo "In case of missing features ingame, try restarting the whole server."
|
||||
echo "Use ./tmserver restart tmserver"
|
||||
|
|
Loading…
Reference in New Issue