1 # common functions used by Elidragon v2 scripts
4 echo "/tmp/ElidragonV2_$1_lock"
7 function multiserver_lock {
8 echo "/tmp/ElidragonV2_Multiserver_lock"
11 function world_screenname {
12 echo "Elidragon v2 - $1"
15 function multiserver_screenname {
16 echo "Elidragon v2 - Multiserver"
20 kill `cat \`world_lock $1\``
23 function kill_multiserver {
24 kill -2 `cat \`multiserver_lock\``
27 function world_running {
28 return $([ -f `world_lock $1` ])
31 function multiserver_running {
32 return $([ -f `multiserver_lock` ])
35 function assert_running {
36 if ! world_running $1; then
37 echo -e "\e[31mWorld $1 is not running\e[0m"
46 function assert_not_running {
47 if world_running $1; then
48 echo -e "\e[31mWorld $1 is already running\e[0m"
57 function loop_worlds {
59 for WORLD in $WORLDS; do
64 function run_one_or_all {
74 function run_in_screen {
75 screen -dmS $1 bash -c "
86 function start_multiserver {
87 echo -n "Starting Multiserver... "
88 if multiserver_running; then
89 echo -e "\e[31mMultiserver is already running\e[0m"
91 run_in_screen `multiserver_screenname` `multiserver_lock` "~/go/bin/multiserver"
92 echo -e "\e[32mDone\e[0m"
96 function stop_multiserver {
97 echo -n "Stopping Multiserver... "
98 if multiserver_running; then
100 rm `multiserver_lock`
102 echo -e "\e[32mDone\e[0m"
104 echo -e "\e[31mMultiserver is not running\e[0m"
108 function restart_multiserver {
109 echo -n "Multiserver..."
110 if multiserver_running; then
113 echo -e "\e[32mDone\e[0m"
115 echo -e "\e[31mMultiserver is not running\e[0m"
119 function start_world {
120 echo -n "Starting $1... "
121 if assert_not_running $1 "true"; then
122 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"
123 echo -e "\e[32mDone\e[0m"
127 function stop_world {
128 echo -n "Stopping $1..."
129 if assert_running $1 "true"; then
133 echo -e "\e[32mDone\e[0m"
137 function restart_world {
138 echo -n "Restarting $1..."
139 if assert_running $1 "true"; then
142 echo -e "\e[32mDone\e[0m"