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 mapserver_lock {
12 echo "/tmp/ElidragonV2_mapserver_lock"
15 function world_screenname {
19 function multiserver_screenname {
20 echo "ElidragonV2_multiserver"
23 function mapserver_screenname {
24 echo "ElidragonV2_mapserver"
28 kill `cat \`world_lock $1\``
31 function kill_multiserver {
32 kill -2 `cat \`multiserver_lock\``
35 function kill_mapserver {
36 kill `cat \`mapserver_lock\``
39 function world_running {
40 return $([ -f `world_lock $1` ])
43 function multiserver_running {
44 return $([ -f `multiserver_lock` ])
47 function mapserver_running {
48 return $([ -f `mapserver_lock` ])
51 function loop_worlds {
53 for WORLD in $WORLDS; do
58 function run_in_screen {
59 screen -dmS $1 bash -c "
70 function start_mapserver {
71 echo -n "Starting mapserver... "
72 if ! mapserver_running; then
74 while ! [ -f map.sqlite ]; do
77 run_in_screen `mapserver_screenname` `mapserver_lock` "./mapserver-linux-x86_64"
79 echo -e "\e[32mDone\e[0m"
81 echo -e "\e[31mmapserver is already running\e[0m"
85 function stop_mapserver {
86 echo -n "Stopping mapserver... "
87 if mapserver_running; then
90 echo -e "\e[32mDone\e[0m"
92 echo -e "\e[31mmapserver is not running\e[0m"
96 function restart_mapserver {
97 echo -n "Restarting mapserver... "
98 if mapserver_running; then
100 echo -e "\e[32mDone\e[0m"
102 echo -e "\e[31mmapserver is not running\e[0m"
106 function start_multiserver {
107 echo -n "Starting multiserver... "
108 if ! multiserver_running; then
109 run_in_screen `multiserver_screenname` `multiserver_lock` "~/go/bin/multiserver"
110 echo -e "\e[32mDone\e[0m"
112 echo -e "\e[31mmultiserver is already running\e[0m"
116 function stop_multiserver {
117 echo -n "Stopping multiserver... "
118 if multiserver_running; then
120 rm `multiserver_lock`
121 echo -e "\e[32mDone\e[0m"
123 echo -e "\e[31mmultiserver is not running\e[0m"
127 function restart_multiserver {
128 echo -n "Restarting multiserver... "
129 if multiserver_running; then
131 echo -e "\e[32mDone\e[0m"
133 echo -e "\e[31mmultiserver is not running\e[0m"
137 function start_world {
138 echo -n "Starting $1... "
139 if ! world_running $1; then
140 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"
141 echo -e "\e[32mDone\e[0m"
143 echo -e "\e[31m$1 is already running\e[0m"
147 function stop_world {
148 echo -n "Stopping $1... "
149 if world_running $1; then
152 echo -e "\e[32mDone\e[0m"
154 echo -e "\e[31m$1 is not running\e[0m"
158 function restart_world {
159 echo -n "Restarting $1... "
160 if world_running $1; then
162 echo -e "\e[32mDone\e[0m"
164 echo -e "\e[31m$1 is not running\e[0m"