summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2020-10-11 00:59:51 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2020-10-11 00:59:51 +0200
commitebe40a531c81db980f1411004c7583baf36d8331 (patch)
treefad87ba3c486031dd466e4a24baa7b61961c9cb7
parent4541bf611508565610a99f8036b3d49009a52518 (diff)
downloadminecraft-isekai-ebe40a531c81db980f1411004c7583baf36d8331.tar.gz
skeleton, assign improvements
-rwxr-xr-xbuilder.sh56
1 files changed, 51 insertions, 5 deletions
diff --git a/builder.sh b/builder.sh
index 9fee1d6..cc65090 100755
--- a/builder.sh
+++ b/builder.sh
@@ -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)