diff options
author | Jonas Gunz <himself@jonasgunz.de> | 2020-10-08 02:18:34 +0200 |
---|---|---|
committer | Jonas Gunz <himself@jonasgunz.de> | 2020-10-08 02:18:34 +0200 |
commit | da77e6977c3a71a751752f85446e3e545a7b69e5 (patch) | |
tree | 664880cd841a092f3648b6d3e726a4a505fa1d83 | |
parent | 016519155c521979dd68a48cdad888d8939d8710 (diff) | |
download | minecraft-isekai-da77e6977c3a71a751752f85446e3e545a7b69e5.tar.gz |
getting arguments in order
-rwxr-xr-x | builder.sh | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -7,6 +7,10 @@ function fail(){ exit 1 } +function perror() { + echo $@ +} >&2 + # 1: file 2: attribute function serverprop_get() { sed -n "s/$2=\(.*\)$/\1/p" "$1" @@ -84,6 +88,7 @@ function world_assign() { echo "ASSIGNED_TO=\"$INSTANCE\"" > "$WORLDS/$WORLD.lock" + # TODO check?!? ln -s "$WORLDS/$WORLD" "$INSTANCES/$INSTANCE" serverprop_set "$INSTANCES/$INSTANCE/server.properties" level-name "$WORLD" } @@ -144,19 +149,14 @@ function instance_exists() { return $? } -# 1: name 2: world 3: version +# 1: name function instance_create() { local NAME="$1" - local WORLD="$2" - local VERSION="$3" instance_exists "$NAME" && fail "$NAME already exists." mkdir "$INSTANCES/$NAME" - version_install "$NAME" "$VERSION" confirm "Accept minecraft EULA?" && serverprop_set "$INSTANCES/$NAME/eula.txt" eula true - - world_assign "$WORLD" "$NAME" } function instance_start() { @@ -177,19 +177,21 @@ function version_exists() { return $? } -# 1: instance 2: version +# 1: version 2: instance function version_install() { - instance_exists "$1" || fail "instance $1 not found." - version_exists "$2" || fail "version $2 not found." + local INSTANCE="$1" + local VERSION="$2" + instance_exists "$INSTANCE" || fail "instance $1 not found." + version_exists "$VERSION" || fail "version $2 not found." local PWD=$(pwd) - cd "$INSTANCES/$1" + cd "$INSTANCES/$INSTANCE" - [ -e "$2.jar" ] && rm "$2.jar" + [ -e "$VERSION.jar" ] && rm "$VERSION.jar" - ln -s "$VERSIONS/$2.jar" "$2.jar" + ln -s "$VERSIONS/$VERSION.jar" "$VERSION.jar" - serverprop_set settings.sh MCJAR "$2.jar" + serverprop_set settings.sh MCJAR "$VERSION.jar" cd "$PWD" } @@ -203,7 +205,7 @@ INSTANCES="$PREFIX/instances" RUNNER="$PREFIX/runner.sh" -[ -x ./settings.sh ] || fail "settings.sh not found." +[ -e ./settings.sh ] || fail "settings.sh not found." source ./settings.sh CMD="$1" |