summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-10-05 20:35:51 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-10-05 20:35:51 +0200
commit414155c2827b08e99a57163d4f7aa8d04db9a154 (patch)
tree80b94fdc3c75ea64b99b094c2dd783712e0f8a10
parent598653a4cc89d5588315607a367a87083b73da7c (diff)
downloadminecraft-isekai-414155c2827b08e99a57163d4f7aa8d04db9a154.tar.gz
list functions
-rwxr-xr-xbuilder.sh32
1 files changed, 32 insertions, 0 deletions
diff --git a/builder.sh b/builder.sh
index 5f647f8..8521a09 100755
--- a/builder.sh
+++ b/builder.sh
@@ -61,6 +61,15 @@ function world_exists() {
return $?
}
+function world_list() {
+ for WORLD in $WORLDS/*/; do
+ WORLD=$(basename $WORLD)
+ [ -e "$WORLDS/$WORLD.lock" ] && source "$WORLDS/$WORLD.lock"
+ [ -z "$ASSIGNED_TO" ] || WORLD="$WORLD (-> $ASSIGNED_TO)"
+ echo $WORLD
+ done
+}
+
# 1: world 2: instance
function world_assign() {
local WORLD="$1"
@@ -107,6 +116,29 @@ function instance() {
exit $?
}
+function instance_list() {
+ for INSTANCE in $INSTANCES/*/; do
+ INSTANCE="$(basename "$INSTANCE")"
+ instance_status "$INSTANCE" > /dev/null 2>&1 && INSTANCE+=" (RUNNING)"
+ echo "$INSTANCE"
+ done
+ return 0
+}
+
+function instance_status() {
+ instance_exists "$1" || fail "instance $1 not found."
+
+ local PWD="$(pwd)"
+
+ cd "$INSTANCES/$1"
+
+ $RUNNER status
+ local RET=$?
+
+ cd "$PWD"
+ return $RET
+}
+
function instance_exists() {
[ -d "$INSTANCES/$1" ]
return $?