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 run_in_screen `mapserver_screenname` `mapserver_lock` "./mapserver-linux-x86_64"
76 echo -e "\e[32mDone\e[0m"
78 echo -e "\e[31mmapserver is already running\e[0m"
82 function stop_mapserver {
83 echo -n "Stopping mapserver... "
84 if mapserver_running; then
87 echo -e "\e[32mDone\e[0m"
89 echo -e "\e[31mmapserver is not running\e[0m"
93 function restart_mapserver {
94 echo -n "Restarting mapserver... "
95 if mapserver_running; then
97 echo -e "\e[32mDone\e[0m"
99 echo -e "\e[31mmapserver is not running\e[0m"
103 function start_multiserver {
104 echo -n "Starting multiserver... "
105 if ! multiserver_running; then
106 run_in_screen `multiserver_screenname` `multiserver_lock` "~/go/bin/multiserver"
107 echo -e "\e[32mDone\e[0m"
109 echo -e "\e[31mmultiserver is already running\e[0m"
113 function stop_multiserver {
114 echo -n "Stopping multiserver... "
115 if multiserver_running; then
117 rm `multiserver_lock`
118 echo -e "\e[32mDone\e[0m"
120 echo -e "\e[31mmultiserver is not running\e[0m"
124 function restart_multiserver {
125 echo -n "Restarting multiserver... "
126 if multiserver_running; then
128 echo -e "\e[32mDone\e[0m"
130 echo -e "\e[31mmultiserver is not running\e[0m"
134 function start_world {
135 echo -n "Starting $1... "
136 if ! world_running $1; then
137 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"
138 echo -e "\e[32mDone\e[0m"
140 echo -e "\e[31m$1 is already running\e[0m"
144 function stop_world {
145 echo -n "Stopping $1... "
146 if world_running $1; then
149 echo -e "\e[32mDone\e[0m"
151 echo -e "\e[31m$1 is not running\e[0m"
155 function restart_world {
156 echo -n "Restarting $1... "
157 if world_running $1; then
159 echo -e "\e[32mDone\e[0m"
161 echo -e "\e[31m$1 is not running\e[0m"