diff options
-rwxr-xr-x | builder.sh | 56 |
1 files changed, 51 insertions, 5 deletions
@@ -19,7 +19,7 @@ function serverprop_get() { # 1: file 2: attribute 3: value function serverprop_set() { if grep -s "^$2=.*$" "$1"; then - sed -i "s/$2=.*$/$2=$3/g" "$1" + sed -ni "s/$2=.*$/$2=$3/g" "$1" else echo "$2=$3" >> "$1" fi @@ -49,6 +49,7 @@ function world() { clone) ;& backup) ;& delete) ;& + unassign) ;& assign) shift eval 'world_$CMD "$@"' @@ -84,15 +85,53 @@ function world_assign() { && world_create "$WORLD" \ || fail "World $WORLD not found." ) - [ -f "$WORLDS/$WORLD.lock" ] && fail "$WORLD is already used by another instance." + if [ -f "$WORLDS/$WORLD.lock" ]; then + source "$WORLDS/$WORLD.lock" + [ "$ASSIGNED_TO" = "$INSTANCE" ] \ + || fail "$WORLD is already used by another instance." + fi + + [ -L "$INSTANCES/$INSTANCE/$WORLD" ] \ + && rm "$INSTANCES/$INSTANCE/$WORLD" + [ -e "$INSTANCES/$INSTANCE/$WORLD" ] \ + && fail "A file/folder named $WORLD already exists in the instance directory." echo "ASSIGNED_TO=\"$INSTANCE\"" > "$WORLDS/$WORLD.lock" - # TODO check?!? - ln -s "$WORLDS/$WORLD" "$INSTANCES/$INSTANCE" + ln -s "$WORLDS/$WORLD" "$INSTANCES/$INSTANCE/$WORLD" serverprop_set "$INSTANCES/$INSTANCE/server.properties" level-name "$WORLD" } +# 1: world +function world_unassign() { + local WORLD="$1" + world_exists "$WORLD" || fail "World $WORLD not found." + + [ -f "$WORLDS/$WORLD.lock" ] || fail "World is not in use." + source "$WORLDS/$WORLD.lock" + rm "$WORLDS/$WORLD.lock" + + [ -L "$INSTANCES/$ASSIGNED_TO/$WORLD" ] && rm "$INSTANCES/$ASSIGNED_TO/$WORLD" + echo "$WORLD was assigned to $ASSIGNED_TO" + + #serverprop_set "$WORLDS/$WORLD/settings.sh" LOCK 1 +} + +function world_clone() { + fail "TODO" +} + +function world_backup() { + fail "TODO" +} + +function world_restore() { + fail "TODO" +} + +function world_delete() { + fail "TODO" +} # 1: name function world_create() { @@ -162,8 +201,11 @@ function instance_create() { function instance_start() { instance_exists "$1" || fail "instance $1 not found." + fail "TODO" +} - # TODO +function instance_stop() { + fail "TODO" } ## version @@ -217,6 +259,10 @@ function version_install() { cd "$PWD" } +function version_uninstall() { + fail "TODO" +} + # NO_INTERACTIVE=1 PREFIX=$(pwd) |