From 414155c2827b08e99a57163d4f7aa8d04db9a154 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Mon, 5 Oct 2020 20:35:51 +0200 Subject: list functions --- builder.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) 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 $? -- cgit v1.2.3