copytominetest using metascript

Signed-off-by: philippe lhardy <philippe.lhardy@astrolabe.coop>
This commit is contained in:
2025-11-01 16:15:15 +01:00
parent 1d96ee089b
commit 8fdea9ed3a
3 changed files with 70 additions and 13 deletions

View File

@@ -1,20 +1,57 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2025 artlog@l0g.eu
# SPDX-License-Identifier: AGPL-3.0-or-later
# header generated by lib/metascript.sh header
# metascript_version=v1.0.0
toolsdir=lib
pushd $toolsdir >/dev/null
toolsdir=$(pwd)
source metascript.sh
popd >/dev/null
usage() {
cat <<EOF
copy a .we generated lab into minetest local game directory
name=name of generated .we without extension
game=name of game
EOF
}
metarun=metarun
# change default to sudo if needed
# metasudo=sudo
name="$1.we"
srcdir="lab/"
game="nm"
while [[ $# > 0 ]]
do
case "$1" in
name=*)
name=${1/name=}.we
;;
game=*)
game=${1/game=}
;;
*)
parsemetaarg "$1"
;;
esac
shift
done
name=$1.we
srcdir=lab/
game=nm
dest=~/.minetest/worlds/$game/schems
src=${srcdir}$name
if [[ ! -d $dest ]]
then
echo "[ERROR] no destination directory $dest found" >&2
fi
src=$srcdir/$name
enforce file $src exists
enforce dir $dest exists
if [[ -f $src ]]
then
cp $src $dest/
$defer cp $src $dest/
else
echo "[ERROR] missing $src" >&2
log_error "missing $src"
fi