]> git.lizzy.rs Git - elidragon_v2.git/commitdiff
Rename internal.sh to common.sh
authorElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 19 Feb 2021 20:42:54 +0000 (21:42 +0100)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Fri, 19 Feb 2021 20:42:54 +0000 (21:42 +0100)
scripts/common.sh [new file with mode: 0644]
scripts/console.sh
scripts/internal.sh [deleted file]
scripts/restart.sh
scripts/start.sh

diff --git a/scripts/common.sh b/scripts/common.sh
new file mode 100644 (file)
index 0000000..0b4887a
--- /dev/null
@@ -0,0 +1,92 @@
+# common functions used by Elidragon v2 scripts
+
+function world_lock {
+       echo "/tmp/ElidragonV2_$1_lock"
+}
+
+function world_screenname {
+       echo "Elidragon v2 - $1"
+}
+
+function kill_world {
+       kill `cat \`world_lock $1\``
+}
+
+function is_running {
+       return $(test -f `world_lock $1`)
+}
+
+function loop_worlds {
+       WORLDS=`ls worlds`
+       for WORLD in $WORLDS; do
+               $1 $WORLD
+       done
+}
+
+function assert_running {
+       if ! is_running $1; then
+               echo "\e[31mWorld $1 is not running\e[0m"
+               if [ -z "$2" ]; then
+                       exit 1
+               else
+                       return 1
+               fi
+       fi
+}
+
+function assert_not_running {
+       if is_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 start_world {
+       echo -n "Starting $1... "
+       if assert_not_running $1 "true"; then
+               LOCK=`world_lock $1`
+
+               screen -dmS `world_screenname $1` bash -c "
+                       while is_running $1; do
+                               bash -c \"
+                                       echo \\$\\$ > $LOCK
+                                       exec minetest --server --terminal --world worlds/$1 --config worlds/$1/minetest.conf --logfile worlds/$1/debug.txt 
+                               \"
+                       done
+                       rm $LOCK
+               "
+
+               echo "\e[32mDone\e[0m"
+       fi
+}
+
+function stop_world {
+       echo -n "Stopping $1..."
+       if assert_running $1 "true"; then
+               kill_world $1
+               rm `world_lock $1`
+
+               echo "\e[32mDone\e[0m"
+       fi
+}
+
+function restart_world {
+       echo -n "Restarting $1..."
+       if assert_running $1 "true"; then
+               kill_world $1
+
+               echo "\e[32mDone\e[0m"
+       fi
+}
+
+function run_one_or_all {
+       if [ -z "$2" ]; then
+               loop_worlds $1
+       else
+               $1 $2
+       fi
+}
index 6751c0cda443a29461dbf3a20defcda41277553f..77d876db16bd233c9192fb0ff500dcfbb1193307 100755 (executable)
@@ -3,7 +3,7 @@
 # Attach to the console of a world
 # Arguments: <worldname>
 
-source scripts/internal.sh
+source scripts/common.sh
 
 assert_running $1
 screen -r `world_screenname $1`
diff --git a/scripts/internal.sh b/scripts/internal.sh
deleted file mode 100644 (file)
index 6792af1..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-# internal functions used by Elidragon v2 scripts
-
-function world_lock {
-       echo "/tmp/ElidragonV2_$1_lock"
-}
-
-function world_screenname {
-       echo "Elidragon v2 - $1"
-}
-
-function kill_world {
-       kill `cat \`world_lock $1\``
-}
-
-function is_running {
-       return $(test -f `world_lock $1`)
-}
-
-function loop_worlds {
-       WORLDS=`ls worlds`
-       for WORLD in $WORLDS; do
-               $1 $WORLD
-       done
-}
-
-function assert_running {
-       if ! is_running $1; then
-               echo "\e[31mWorld $1 is not running\e[0m"
-               if [ -z "$2" ]; then
-                       exit 1
-               else
-                       return 1
-               fi
-       fi
-}
-
-function assert_not_running {
-       if is_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 start_world {
-       echo -n "Starting $1... "
-       if assert_not_running $1 "true"; then
-               LOCK=`world_lock $1`
-
-               screen -dmS `world_screenname $1` bash -c "
-                       while is_running $1; do
-                               bash -c \"
-                                       echo \\$\\$ > $LOCK
-                                       exec minetest --server --terminal --world worlds/$1 --config worlds/$1/minetest.conf --logfile worlds/$1/debug.txt 
-                               \"
-                       done
-                       rm $LOCK
-               "
-
-               echo "\e[32mDone\e[0m"
-       fi
-}
-
-function stop_world {
-       echo -n "Stopping $1..."
-       if assert_running $1 "true"; then
-               kill_world $1
-               rm `world_lock $1`
-
-               echo "\e[32mDone\e[0m"
-       fi
-}
-
-function restart_world {
-       echo -n "Restarting $1..."
-       if assert_running $1 "true"; then
-               kill_world $1
-
-               echo "\e[32mDone\e[0m"
-       fi
-}
-
-function run_one_or_all {
-       if [ -z "$2" ]; then
-               loop_worlds $1
-       else
-               $1 $2
-       fi
-}
index a39e4548c3894f077803fb052a66f0f5e46e69e3..f1e0f3a04998fc48ab218c57721a7e0d1e62819c 100755 (executable)
@@ -3,6 +3,6 @@
 # Restart one or all worlds
 # Arguments: [<worldname>]
 
-source scripts/internal.sh
+source source scripts/common.sh
 
 run_one_or_all restart_world $1
index 96cc2fe46a028fad2bcb1928604cbe7aaa7c897c..254b3a775962d8eb849837f221128f3b3b0aa986 100755 (executable)
@@ -3,6 +3,6 @@
 # Start one or all worlds
 # Arguments: [<worldname>]
 
-source scripts/internal.sh
+source source scripts/common.sh
 
 run_one_or_all start_world $1