echo "# * minetestenv.rc started `date`" > "$err_txt"
echo "# * minetestenv.rc started `date`" > "$err_txt"
customDie() {
customExit() {
echo
echo
errorLevel=1
errorLevel=1
if [ -z "$2" ]; then
if [ -z "$2" ]; then
@ -147,7 +147,7 @@ show_changes="true"
if [ "$SCRIPT" = "/bin/bash" ]; then
if [ "$SCRIPT" = "/bin/bash" ]; then
SCRIPT=minetestenv.rc
SCRIPT=minetestenv.rc
if [ ! -f "$SCRIPT" ]; then
if [ ! -f "$SCRIPT" ]; then
customDie "ERROR: could not find self (need location of self in order to get SCRIPTPATH and then REPO_PATH in order for patches directory to be found."
customExit "ERROR: could not find self (need location of self in order to get SCRIPTPATH and then REPO_PATH in order for patches directory to be found."
fi
fi
fi
fi
# Absolute path this script is in, thus /home/user/bin
# Absolute path this script is in, thus /home/user/bin
@ -182,7 +182,7 @@ fi
if [ ! -d "$PATCHES_PATH" ]; then
if [ ! -d "$PATCHES_PATH" ]; then
echo
echo
echo
echo
customDie "ERROR: could not find patches such as in $PATCHES_PATH"
customExit "ERROR: could not find patches such as in $PATCHES_PATH"
fi
fi
# NOTE: minetest mods (other than 0.4.16 client-side mods) are ALWAYS ONLY installed on server, unless you need them for singleplayer
# NOTE: minetest mods (other than 0.4.16 client-side mods) are ALWAYS ONLY installed on server, unless you need them for singleplayer
USR_SHARE_MINETEST=/usr/share/games/minetest
USR_SHARE_MINETEST=/usr/share/games/minetest
@ -311,7 +311,7 @@ else
#fi
#fi
fi
fi
if [ ! -d "$MT_WORLDS_DIR/$MT_MYWORLD_NAME" ]; then
if [ ! -d "$MT_WORLDS_DIR/$MT_MYWORLD_NAME" ]; then
customDie " ERROR: failed to find world path, so cannot continue."
customExit " ERROR: failed to find world path, so cannot continue."
fi
fi
MT_MYWORLD_DIR=$MT_WORLDS_DIR/$MT_MYWORLD_NAME
MT_MYWORLD_DIR=$MT_WORLDS_DIR/$MT_MYWORLD_NAME
echo "Using world at $MT_MYWORLD_DIR"
echo "Using world at $MT_MYWORLD_DIR"
@ -335,7 +335,7 @@ reinstall_mt_game() {
if [ -d "$USR_SHARE_MINETEST/games/minetest_game" ]; then
if [ -d "$USR_SHARE_MINETEST/games/minetest_game" ]; then
customDie "failed to create $USR_SHARE_MINETEST/games/minetest_game, so cannot continue."
customExit "failed to create $USR_SHARE_MINETEST/games/minetest_game, so cannot continue."
fi
fi
else
else
echo "ERROR: refusing to reinstall minetest_game since missing sources (not at $HOME/minetest/games/minetest_game nor $HOME/Downloads/minetest/games/minetest_game"
echo "ERROR: refusing to reinstall minetest_game since missing sources (not at $HOME/minetest/games/minetest_game nor $HOME/Downloads/minetest/games/minetest_game"
customDie "ERROR: nothing done since add_mod_from_here FAILED to receive 'MTMOD_DEST_NAME' (1st param)"
customExit "ERROR: nothing done since add_mod_from_here FAILED to receive 'MTMOD_DEST_NAME' (1st param)"
fi
fi
if [ -z "$MTMOD_GOT_NAME" ]; then
if [ -z "$MTMOD_GOT_NAME" ]; then
customDie "ERROR: nothing done since add_mod_from_here FAILED to receive 'MTMOD_GOT_NAME' which is the exact downloaded or unzipped folder name (2nd param)"
customExit "ERROR: nothing done since add_mod_from_here FAILED to receive 'MTMOD_GOT_NAME' which is the exact downloaded or unzipped folder name (2nd param)"
fi
fi
if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
if [ ! -d "$MTMOD_GOT_NAME" ]; then
if [ ! -d "$MTMOD_GOT_NAME" ]; then
customDie "ERROR: nothing done since add_mod_from_here FAILED to find '$MTMOD_GOT_NAME'"
customExit "ERROR: nothing done since add_mod_from_here FAILED to find '$MTMOD_GOT_NAME'"
fi
fi
if [ -d "$MTMOD_DEST_PATH" ]; then
if [ -d "$MTMOD_DEST_PATH" ]; then
if [ ! -f "`command -v rsync`" ]; then
if [ ! -f "`command -v rsync`" ]; then
echo "removing old $MTMOD_DEST_PATH"
echo "removing old $MTMOD_DEST_PATH"
rm -Rf "$MTMOD_DEST_PATH"
rm -Rf "$MTMOD_DEST_PATH"
if [ -d "$MTMOD_DEST_PATH" ]; then
if [ -d "$MTMOD_DEST_PATH" ]; then
customDie "FAILED to remove '$MTMOD_DEST_PATH'"
customExit "FAILED to remove '$MTMOD_DEST_PATH'"
fi
fi
fi
fi
fi
fi
@ -463,7 +463,7 @@ if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
fi
fi
fi
fi
if [ ! -d "$MTMOD_DEST_PATH" ]; then
if [ ! -d "$MTMOD_DEST_PATH" ]; then
customDie " ERROR: failed to get $MTMOD_DEST_PATH, so cannot continue."
customExit " MTMOD_DEST_PATH $MTMOD_DEST_PATH is not a directory."