# * Git version uses /home/*/minetest/games and /usr/local/share/minetest/games but the latter is used for minetestserver (minetest-server package)
# * Git version uses /home/*/minetest/games and /usr/local/share/minetest/games but the latter is used for minetestserver (minetest-server package)
# * Arch stable version uses /usr/share/minetest/
# * Arch stable version uses /usr/share/minetest/
if [ "$1" = "--help" ]; then
if [ "$1" = "--help" ]; then
echo "This script installs ENLIVEN subgame for minetest. It uses individual git repositories, so please only run this once so as not to exceed their bandwidth."
echo "This script installs ENLIVEN subgame for minetest. It uses individual git repositories, so please only run this once so as not to exceed their bandwidth."
echo "Usage:"
echo "Usage:"
echo
echo
#echo "version_0_5_enable=<value> (where value is true or false): forces 0.5 (if not specified, this script uses 0.5 versions of mods if minetest is at /usr/local/share/minetest)"
#echo "version_0_5_enable=<value> (where value is true or false): forces 0.5 (if not specified, this script uses 0.5 versions of mods if minetest is at /usr/local/share/minetest)"
#echo
#echo
echo "local_enable=<value> (where value is true or false): forces /usr/local/share/minetest (if not specified, script detects minetest but if exists both in /usr/share/ and /usr/local/share, prefers /usr/local/share/minetest)"
echo "local_enable=<value> (where value is true or false): forces /usr/local/share/minetest (if not specified, script detects minetest but if exists both in /usr/share/ and /usr/local/share, prefers /usr/local/share/minetest)"
echo
echo
exit 0
exit 0
fi
fi
#NOTE: version_0_5_enable is now detected further down instead of being specified
#NOTE: version_0_5_enable is now detected further down instead of being specified
#if [ "$1" = "version_0_5_enable=true" ]; then
#if [ "$1" = "version_0_5_enable=true" ]; then
# version_0_5_enable="true"
# version_0_5_enable="true"
#elif [ "$2" = "version_0_5_enable=true" ]; then
#elif [ "$2" = "version_0_5_enable=true" ]; then
# version_0_5_enable="true"
# version_0_5_enable="true"
#elif [ "$1" = "version_0_5_enable=false" ]; then
#elif [ "$1" = "version_0_5_enable=false" ]; then
# version_0_5_enable="false"
# version_0_5_enable="false"
#elif [ "$2" = "version_0_5_enable=false" ]; then
#elif [ "$2" = "version_0_5_enable=false" ]; then
# version_0_5_enable="false"
# version_0_5_enable="false"
#fi
#fi
if [ "$1" = "local_enable=true" ]; then
if [ "$1" = "local_enable=true" ]; then
local_enable="true"
local_enable="true"
#elif [ "$2" = "local_enable=true" ]; then
#elif [ "$2" = "local_enable=true" ]; then
# local_enable="true"
# local_enable="true"
elif [ "$1" = "local_enable=false" ]; then
elif [ "$1" = "local_enable=false" ]; then
# local_enable="false"
# local_enable="false"
#elif [ "$2" = "local_enable=false" ]; then
#elif [ "$2" = "local_enable=false" ]; then
local_enable="false"
local_enable="false"
fi
fi
#echo "3..."
#echo "3..."
#sleep 1
#sleep 1
@ -99,7 +130,6 @@ fi
#sleep 1
#sleep 1
update_enable="true"
update_enable="true"
shell_name="bash"
shell_name="bash"
err_txt=$HOME/err-enliven.txt
# doesn't work if equal: [ $0 = *"$shell_name"* ]
# doesn't work if equal: [ $0 = *"$shell_name"* ]
# could be -bash or bash
# could be -bash or bash
#if [ "$0" = "-bash" ]; then
#if [ "$0" = "-bash" ]; then
@ -109,95 +139,76 @@ show_changes="true"
#if [[ $0 == *"$shell_name"* ]]; then
#if [[ $0 == *"$shell_name"* ]]; then
#doesn't work on Fedora since shell_name is blank even when in shell and not pasting:
#doesn't work on Fedora since shell_name is blank even when in shell and not pasting:
#if [ "$shell_name" != "" ]; then
#if [ "$shell_name" != "" ]; then
#REPO_PATH="$HOME/GitHub/EnlivenMinetest"
#REPO_PATH="$HOME/GitHub/EnlivenMinetest"
#echo "You must have pasted this into terminal, so assuming REPO_PATH:"
#echo "You must have pasted this into terminal, so assuming REPO_PATH:"
#echo " $REPO_PATH"
#echo " $REPO_PATH"
#else
#else
SCRIPT=$(readlink -f "$0")
SCRIPT=$(readlink -f "$0")
if [ "$SCRIPT" = "/bin/bash" ]; then
if [ "$SCRIPT" = "/bin/bash" ]; then
SCRIPT=minetestenv.rc
SCRIPT=minetestenv.rc
if [ ! -f "$SCRIPT" ]; then
if [ ! -f "$SCRIPT" ]; then
echo "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."
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."
echo " press Ctrl C to cancel ENLIVEN install or this terminal will close..."
fi
sleep 1
echo " 3..."
sleep 1
echo " 2..."
sleep 1
echo " 1..."
sleep 1
exit 1
fi
fi
fi
# Absolute path this script is in, thus /home/user/bin
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")
SCRIPTPATH=$(dirname "$SCRIPT")
REPO_PATH="$SCRIPTPATH"
REPO_PATH="$SCRIPTPATH"
#formerly, this script was in a subdir:
#formerly, this script was in a subdir:
#REPO_PATH=$(dirname "$SCRIPTPATH")
#REPO_PATH=$(dirname "$SCRIPTPATH")
#fi
#fi
PATCHES_PATH="$REPO_PATH/patches"
PATCHES_PATH="$REPO_PATH/patches"
echo "PATCHES_PATH: $PATCHES_PATH"
echo "PATCHES_PATH: $PATCHES_PATH"
sleep 10
if [ ! -d "$PATCHES_PATH" ]; then
if [ ! -d "$PATCHES_PATH" ]; then
# maybe moved somewhere or this code was pasted
# maybe moved somewhere or this code was pasted
PATCHES_PATH=$HOME/GitHub/EnlivenMinetest/patches
PATCHES_PATH=$HOME/GitHub/EnlivenMinetest/patches
fi
fi
if [ ! -d "$PATCHES_PATH" ]; then
if [ ! -d "$PATCHES_PATH" ]; then
# maybe running from root of repo
# maybe running from root of repo
PATCHES_PATH="patches"
PATCHES_PATH="patches"
fi
fi
if [ ! -d "$PATCHES_PATH" ]; then
if [ ! -d "$PATCHES_PATH" ]; then
# should work if ran from folder where exists
# should work if ran from folder where exists
PATCHES_PATH="../patches"
PATCHES_PATH="../patches"
fi
fi
if [ ! -d "$PATCHES_PATH" ]; then
if [ ! -d "$PATCHES_PATH" ]; then
echo
echo
echo
echo
echo "ERROR: could not find patches such as in $PATCHES_PATH"
customDie "ERROR: could not find patches such as in $PATCHES_PATH"
echo " press Ctrl C to cancel ENLIVEN install or this terminal will close..."
sleep 1
echo " 3..."
sleep 1
echo " 2..."
sleep 1
echo " 1..."
sleep 1
exit 1
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
try_path="/usr/share/minetest"
try_path="/usr/share/minetest"
if [ -d "$try_path" ]; then
if [ -d "$try_path" ]; then
# Arch linux
# Arch linux
USR_SHARE_MINETEST="$try_path"
USR_SHARE_MINETEST="$try_path"
fi
fi
if [ "$local_enable" != "false" ]; then
if [ "$local_enable" != "false" ]; then
# IF git version is installed
# IF git version is installed
try_path="/usr/local/share/minetest"
try_path="/usr/local/share/minetest"
if [ -d "$try_path" ]; then
if [ -d "$try_path" ]; then
#if [ -z "$version_0_5_enable" ]; then
#if [ -z "$version_0_5_enable" ]; then
# version_0_5_enable="true"
# version_0_5_enable="true"
#fi
#fi
USR_SHARE_MINETEST="$try_path"
USR_SHARE_MINETEST="$try_path"
fi
fi
fi
fi
version_0_5_enable="false"
version_0_5_enable="false"
if [ -d "$USR_SHARE_MINETEST/games/minetest_game/mods/player_api" ]; then
if [ -d "$USR_SHARE_MINETEST/games/minetest_game/mods/player_api" ]; then
echo " ERROR: failed to create $USR_SHARE_MINETEST/games/minetest_game, so cannot continue." > $err_txt
customDie "failed to create $USR_SHARE_MINETEST/games/minetest_game, so cannot continue."
cat $err_txt
fi
echo " press Ctrl C to cancel ENLIVEN install or this terminal will close..."
else
sleep 1
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 " 3..."
fi
sleep 1
echo " 2..."
sleep 1
echo " 1..."
sleep 1
exit 1
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 to packaged dir: $MT_MINETEST_GAME_PATH"
fi
fi
else
echo "ERROR: refusing to reinstall minetest_game to packaged dir: $MT_MINETEST_GAME_PATH"
fi
}
}
add_zip_mod()
add_zip_mod()
{
{
cd $RELEASES_PATH
cd $RELEASES_PATH
MTMOD_DEST_NAME=$1
MTMOD_DEST_NAME=$1
MTMOD_GOT_NAME=$2
MTMOD_GOT_NAME=$2
URL=$3
URL=$3
MTMOD_SRC_ZIP=$MTMOD_DEST_NAME.zip
MTMOD_SRC_ZIP=$MTMOD_DEST_NAME.zip
if [ ! -z "`ls | grep $MTMOD_GOT_NAME`" ]; then # works with wildcard in variable
if [ ! -z "`ls | grep $MTMOD_GOT_NAME`" ]; then # works with wildcard in variable
echo "ERROR: nothing done since add_mod_from_here FAILED to receive 'MTMOD_DEST_NAME' (1st param)--this session will exit unless you press Ctrl-C to cancel script..."
customDie "ERROR: nothing done since add_mod_from_here FAILED to receive 'MTMOD_DEST_NAME' (1st param)"
sleep 1
echo "4..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
exit 1
fi
if [ -z "$MTMOD_GOT_NAME" ]; then
echo "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)--this session will exit unless you press Ctrl-C to cancel script..."
sleep 1
echo "4..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
exit 1
fi
if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
if [ ! -d "$MTMOD_GOT_NAME" ]; then
echo "ERROR: nothing done since add_mod_from_here FAILED to find '$MTMOD_GOT_NAME'--this session will exit unless you press Ctrl-C to cancel script..."
sleep 1
echo "4..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
exit 1
fi
if [ -d "$MTMOD_DEST_PATH" ]; then
if [ ! -f "`command -v rsync`" ]; then
echo "removing old $MTMOD_DEST_PATH"
sudo rm -Rf "$MTMOD_DEST_PATH"
if [ -d "$MTMOD_DEST_PATH" ]; then
echo "FAILED to remove '$MTMOD_DEST_PATH'--this session will exit unless you press Ctrl-C to cancel script..."
sleep 1
echo "4..."
sleep 1
echo "3..."
sleep 1
echo "2..."
sleep 1
echo "1..."
sleep 1
exit 1
fi
fi
fi
fi
if [ -z "$MTMOD_GOT_NAME" ]; then
if [ -d "$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)"
# outer case is for safety in case variable is blank or something
echo "The 'rsync' command was not found. Installing rsync will reduce writes to drive if you run install methods (as all use add_mod_from_here) more than once for the same mod."
echo "The 'rsync' command was not found. Installing rsync will reduce writes to drive if you run install methods (as all use add_mod_from_here) more than once for the same mod."