]> git.lizzy.rs Git - elidragon_v2.git/commitdiff
Add mapserver
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 20 Feb 2021 14:06:19 +0000 (15:06 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 20 Feb 2021 14:06:19 +0000 (15:06 +0100)
README
scripts/common.sh
scripts/console.sh
scripts/restart.sh
scripts/setup.sh
scripts/start.sh
scripts/stop.sh

diff --git a/README b/README
index 6ca1b5ffc61f60b303d9cdd98290e3aa6ae7ce21..55ba2880214c4e7f5776c03acb97815c43700f99 100644 (file)
--- a/README
+++ b/README
@@ -9,20 +9,22 @@ The goal of Elidragon v2 is to provide a server similar to popular Minecraft ser
 
 Minetest does not support "server-hopping" natively; therefore the multiserver proxy written in Go by HimbeerserverDE is used. multiserver depends on mt rudp by anon55555.
 
+For the creative map, minetest mapserver is used.
+
 Elidragon v2 runs on top of the latest git version of MineClone2, and the lastest stable release of minetest.
 
 Quick guide for installation and running
 ----------------------------------------
 
-Elidragon v2 requires a GNU/Linux system to run. The setup and update scripts rely on apt and sudo. Go 1.15 or higher is required.
+Elidragon v2 requires a GNU/Linux x86_64 system to run. The setup and update scripts rely on apt and sudo. Go 1.15 or higher is required. The ports 33000, 30030, 30031, 30032, 30033 and 8080 need to be open.
 
 1. Create a new user using adduser and switch to it. The user should be able to use sudo.
 2. git clone this repository into that user's home directory and rename it to .minetest
 3. cd into .minetest
-4. run scripts/setup.sh - this will automatically install minetest and screen. Also, it initialized the submodules - all external mods and MineClone2 are installed automatically. It will also install multiserver and its dependencies.
-5. run scripts/start.sh - this will automatically start all worlds and multiserver. If one world or multiserver crashes / shuts down it will automatically restart.
+4. run scripts/setup.sh - this will automatically install minetest and screen. Also, it initialized the submodules - all external mods and MineClone2 are installed automatically. It will also install mapserver, multiserver and its dependencies.
+5. run scripts/start.sh --all - this will automatically start all worlds, multiserver and mapserver. If one world or multiserver / mapserver crashes or shuts down it will automatically restarted.
 
-To update, run scripts/update.sh, to restart all worlds and multiserver run scripts/restart.sh and to stop all worlds and multiserver run scripts/stop.sh
+To update, run scripts/update.sh, to restart all worlds run scripts/restart.sh --worlds and to stop all worlds and multiserver run scripts/stop.sh --all.
 
 Organisation structure
 -------------------
@@ -34,17 +36,17 @@ Scripts
 
 For many tasks it is recommended to use the scripts from the scripts/ directory. All scripts need to be run from the root path of this repository.
 
-scripts/setup.sh: This will install minetest and screen using sudo apt. For minetest a apt repository is added that is up to date (the official repos are often one or two versions behind). It will use go to install multiserver, also it will init and update the submodules, which is very important because all external mods are added as submodules.
+scripts/setup.sh: This will install minetest and screen using sudo apt. For minetest a apt repository is added that is up to date (the official repos are often one or two versions behind). It will use go to install multiserver and mapserver, also it will init and update the submodules, which is very important because all external mods are added as submodules.
 
 scripts/update.sh: This will pull the repository including all submodules. Also, it will update minetest, screen and multiserver.
 
-scripts/start.sh: You can use this to start one or all worlds from the worlds folder. If you pass an argument to it, it will start the specified world, else it will start everything. You can use this script even if some worlds are already running. The worlds will be started in a hidden screen and restarted when killed, shut down using /shutdown or crash. Any started world will have a lock file in the /tmp directory that contains the PID of the current minetest process. When the world is stopped, the lock file is deleted. If --multiserver is used, multiserver is started instead of any worlds, and if all worlds are started, multiserver is started as well.
+scripts/start.sh <worldname> | multiserver | mapserver | --all | --worlds: You can use this to start one or all worlds from the worlds folder, or the mapserver / multiserver. When --all is used it will start everything, --worlds starts all worlds. You can use --all or --world even if some tasks that would be started by it are already running. All tasks will be started in a hidden screen and restarted when killed, shut down using /shutdown or they crash. Any started task will have a lock file in the /tmp directory that contains the PID of the current process. When the task is stopped, the lock file is deleted.
 
-scripts/stop.sh: You can use this to stop one or all worlds from the worlds folder started using the start script. If you pass an argument to it, it will stop the specified world, else it will stop everything. You can use this script even if some worlds are not running. If --multiserver is used, multiserver is stopped instead of any worlds, and if all worlds are stopped, multiserver is stopped as well.
+scripts/stop.sh <worldname> | multiserver | mapserver | --all | --worlds: You can use this to stop one or all worlds from the worlds folder or the mapserver / multiserver started using the start script. When --all is used it will stop everything, --worlds stops all worlds. You can use --all or --world even if some tasks that would be stopped by it are not running.
 
-scripts/restart.sh: You can use this to restart one or all running worlds. You can use this script even if some worlds are not running. It will only restart the running worlds. If --multiserver is used, multiserver is restarted instead of any worlds (in case it is running) and if all worlds are restarted, multiserver is restarted as well (in case it is running).
+scripts/restart.sh <worldname> | multiserver | mapserver | --all | --worlds: You can use this to restart one or all worlds from the worlds folder or the mapserver / multiserver started using the start script. When --all is used it will restart everything, --worlds restarts all worlds. You can use --all or --world even if some tasks that would be restarted by it are not running - only the running tasks will be restarted.
 
-scripts/console.sh: You can used this to access the console of the world specified in the argument (minetest --terminal running in a screen). If --multiserver is used, the multiserver screen will be shown.
+scripts/console.sh <worldname> | multiserver | mapserver: You can used this to access the console of the world specified in the argument (minetest --terminal running in a screen). If multiserver / mapserver is used, the multiserver / mapserver output will be shown (in real-time).
 
 scripts/common.sh: This script should not be started, it contains common functions imported by other scripts. You can modify it to e.g. change the paths of lock files or screen names.
 
@@ -72,3 +74,7 @@ Adding new worlds
 -----------------
 
 If you want to add a new world, add a folder to the worlds/directory. Then, create .gitignore, world.mt and minetest.conf in that directory. .gitignore needs to contain * to ignore everything, and !minetest.conf and !world.mt to include these two. minetest.conf and world.mt need to be created and filled, world.mt needs to contain load_mod_xy = true / false for every added mod, see the Adding existing mods section for that. Also, world.mt needs to contain database settings for map, players and auth data and settings to enable / disable creative mode and damage. Each world also has it's own configuration file. The concept for worlds and mods is that some mods are for one world only e.g. the skyblock mod for the skyblock world, and some are shared. Make sure that each world has the mods enabled that the enabled mods depend on. Every world needs to have a port specified in the config file and needs to be added to the multiserver configuration. Only the lobby server is supposed to announce to the server list and should announce the port multiserver is running on.
+
+Ports
+-----
+
index caa3dad3944372714da0b4ae12b1c8367404c805..c8709972bbae364c9e597695e6bb267cc2735511 100644 (file)
@@ -5,7 +5,11 @@ function world_lock {
 }
 
 function multiserver_lock {
-       echo "/tmp/ElidragonV2_Multiserver_lock"
+       echo "/tmp/ElidragonV2_multiserver_lock"
+}
+
+function mapserver_lock {
+       echo "/tmp/ElidragonV2_mapserver_lock"
 }
 
 function world_screenname {
@@ -16,6 +20,10 @@ function multiserver_screenname {
        echo "Elidragon v2 - Multiserver"
 }
 
+function mapserver_screenname {
+       echo "Elidragon v2 - Mapserver"
+}
+
 function kill_world {
        kill `cat \`world_lock $1\``
 }
@@ -24,6 +32,10 @@ function kill_multiserver {
        kill -2 `cat \`multiserver_lock\``
 }
 
+function kill_mapserver {
+       kill `cat \`mapserver_lock\``
+}
+
 function world_running {
        return $([ -f `world_lock $1` ])
 }
@@ -32,26 +44,8 @@ function multiserver_running {
        return $([ -f `multiserver_lock` ])
 }
 
-function assert_running {
-       if ! world_running $1; then
-               echo -e "\e[31mWorld $1 is not running\e[0m"
-               if [ -z $2 ]; then
-                       exit 1
-               else
-                       return 1
-               fi
-       fi
-}
-
-function assert_not_running {
-       if world_running $1; then
-               echo -e "\e[31mWorld $1 is already running\e[0m"
-               if [ -z $2 ]; then
-                       exit 1
-               else
-                       return 1
-               fi
-       fi
+function mapserver_running {
+       return $([ -f `mapserver_lock` ])
 }
 
 function loop_worlds {
@@ -61,20 +55,10 @@ function loop_worlds {
        done
 }
 
-function run_one_or_all {
-       if [ -z $2 ]; then
-               loop_worlds $1
-               return 0
-       else
-               $1 $2
-               return 1
-       fi
-}
-
 function run_in_screen {
        screen -dmS $1 bash -c "
                touch $2
-               while [ -f $2; ] do
+               while [ -f $2 ]; do
                        bash -c \"
                                echo \\$\\$ > $2
                                exec $3
@@ -83,13 +67,46 @@ function run_in_screen {
        "
 }
 
+function start_mapserver {
+       echo -n "Starting Mapserver... "
+       if ! mapserver_running; then
+               cd worlds/creative
+               run_in_screen `mapserver_screenname` `mapserver_lock` "./mapserver-linux-x86_64"
+               cd ../..
+               echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31mMapserver is already running\e[0m"
+       fi
+}
+
+function stop_mapserver {
+       echo -n "Stopping Mapserver... "
+       if mapserver_running; then
+               kill_mapserver
+               rm `mapserver_lock`
+               echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31mMapserver is not running\e[0m"
+       fi
+}
+
+function restart_mapserver {
+       echo -n "Restarting Mapserver..."
+       if mapserver_running; then
+               kill_mapserver
+               echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31mMapserver is not running\e[0m"
+       fi
+}
+
 function start_multiserver {
        echo -n "Starting Multiserver... "
-       if multiserver_running; then
-               echo -e "\e[31mMultiserver is already running\e[0m"
-       else
+       if ! multiserver_running; then
                run_in_screen `multiserver_screenname` `multiserver_lock` "~/go/bin/multiserver"
                echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31mMultiserver is already running\e[0m"
        fi
 }
 
@@ -98,7 +115,6 @@ function stop_multiserver {
        if multiserver_running; then
                kill_multiserver
                rm `multiserver_lock`
-
                echo -e "\e[32mDone\e[0m"
        else
                echo -e "\e[31mMultiserver is not running\e[0m"
@@ -106,10 +122,9 @@ function stop_multiserver {
 }
 
 function restart_multiserver {
-       echo -n "Multiserver..."
+       echo -n "Restarting Multiserver..."
        if multiserver_running; then
                kill_multiserver
-
                echo -e "\e[32mDone\e[0m"
        else
                echo -e "\e[31mMultiserver is not running\e[0m"
@@ -118,27 +133,31 @@ function restart_multiserver {
 
 function start_world {
        echo -n "Starting $1... "
-       if assert_not_running $1 "true"; then
+       if ! world_running $1; then
                run_in_screen `world_screenname $1` `world_lock $1` "minetest --server --terminal --world worlds/$1 --config worlds/$1/minetest.conf --logfile worlds/$1/debug.txt"
                echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31m$2 is already running\e[0m"
        fi
 }
 
 function stop_world {
        echo -n "Stopping $1..."
-       if assert_running $1 "true"; then
+       if world_running $1; then
                kill_world $1
                rm `world_lock $1`
-
                echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31m$2 is already running\e[0m"
        fi
 }
 
 function restart_world {
        echo -n "Restarting $1..."
-       if assert_running $1 "true"; then
+       if world_running $1; then
                kill_world $1
-
                echo -e "\e[32mDone\e[0m"
+       else
+               echo -e "\e[31m$2 is not running\e[0m"
        fi
 }
index ef1538c175659fa9f1ac20bd8978da12404631e7..03f3d8f1b92b66774d14b035cbe0f5b0a103e5b9 100755 (executable)
@@ -1,13 +1,17 @@
 #! /bin/bash
 # Elidragon v2 console script
-# Attach to the console of a world or multiserver
-# Arguments: <worldname>
+# Attach to the screen of a world, multiserver or mapserver
 
 source scripts/common.sh
 
-if [[ $1 == "--multiserver" ]]; then
-       screen -r `multiserver_sceenname`
-else
-       assert_running $1
-       screen -r `world_screenname $1`
-fi
+case $1 in
+       "mapserver")
+               screen -r `mapserver_screenname`
+               ;;
+       "multiserver")
+               screen -r `multiserver_sceenname`
+               ;;
+       *)
+               screen -r `world_screenname $1`
+               ;;
+esac
index 53a385f19e6a468b4932e9e1e2148442bba2ddd6..13b612a7a586aea47a2457685589da1b508b4125 100755 (executable)
@@ -1,10 +1,25 @@
 #! /bin/bash
 # Elidragon v2 restart script
-# Restart one or all worlds, or if --multiserver is used, the multiserver. If all worlds are restarted, multiserver is restarted as well
-# Arguments: [<worldname> | --multiserver]
+# Restart worlds, multiserver and mapserver
 
 source source scripts/common.sh
 
-if [[ $1 == "--multiserver" || run_one_or_all restart_world $1 ]]; then
-       restart_multiserver
-fi
+case $1 in
+       "--all")
+               restart_mapserver
+               restart_multiserver
+               loop_worlds restart_world
+               ;;
+       "--worlds")
+               loop_worlds restart_world
+               ;;
+       "mapserver")
+               restart_mapserver
+               ;;
+       "multiserver")
+               restart_multiserver
+               ;;
+       *)
+               restart_world $1
+               ;;
+esac
index 37460abb5cad4d2c74c77fa1be95316121418e52..67f2448944f18582db8482ecd84a24f0ebda2db5 100755 (executable)
@@ -14,3 +14,9 @@ sudo apt install minetest screen -y
 
 # Install multiserver and its dependencies
 go get github.com/HimbeerserverDE/multiserver
+
+# Download & install mapserver
+cd worlds/creative/
+curl -s https://api.github.com/repos/minetest-mapserver/mapserver/releases/latest | grep "mapserver-linux-x86_64" | cut -d : -f 2,3 | tr -d \" | wget -qi -
+chmod +x mapserver-linux-x86_64
+cd ../..
index 06a96e2e7cdaebc9ad8bab35aafdf904a36eefff..17a70535e4d3baf38e99fa879eb0e9cf2aac5318 100755 (executable)
@@ -1,10 +1,25 @@
 #! /bin/bash
 # Elidragon v2 start script
-# Start one or all worlds, or if --multiserver is used, the multiserver. If all worlds are started, multiserver is started as well
-# Arguments: [<worldname>]
+# Start worlds, multiserver and mapserver
 
 source source scripts/common.sh
 
-if [ $1 = "--multiserver" ] || run_one_or_all start_world $1; then
-       start_multiserver
-fi
+case $1 in
+       "--all"
+               start_mapserver
+               start_multiserver
+               loop_worlds start_world
+               ;;
+       "--worlds")
+               loop_worlds start_world
+               ;;
+       "mapserver")
+               start_mapserver
+               ;;
+       "multiserver")
+               start_multiserver
+               ;;
+       *)
+               start_world $1
+               ;;
+esac
index 8297ddc1e2c455cb7e4a9cc3eaae7b8e30f164f9..b4a48bf2de69c565f22a4ee94c351ac7bf90042b 100755 (executable)
@@ -1,10 +1,25 @@
 #! /bin/bash
 # Elidragon v2 stop script
-# Stop one or all worlds, or if --multiserver is used, the multiserver. If all worlds are stopped, multiserver is stopped as well
-# Arguments: [<worldname>]
+# Stop worlds, multiserver and mapserver
 
-source scripts/common.sh
+source source scripts/common.sh
 
-if [[ $1 == "--multiserver" || run_one_or_all stop_world $1 ]]; then
-       stop_multiserver
-fi
+case $1 in
+       "--all"
+               stop_mapserver
+               stop_multiserver
+               loop_worlds stop_world
+               ;;
+       "--worlds")
+               loop_worlds stop_world
+               ;;
+       "mapserver")
+               stop_mapserver
+               ;;
+       "multiserver")
+               stop_multiserver
+               ;;
+       *)
+               stop_world $1
+               ;;
+esac