# * 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/
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 "Usage:"
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
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
exit 0
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
#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 "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
exit 0
fi
#NOTE: version_0_5_enable is now detected further down instead of being specified
#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
# version_0_5_enable="true"
# version_0_5_enable="true"
#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
# version_0_5_enable="false"
# version_0_5_enable="false"
#fi
if [ "$1" = "local_enable=true" ]; then
local_enable="true"
local_enable="true"
#elif [ "$2" = "local_enable=true" ]; then
# local_enable="true"
# local_enable="true"
elif [ "$1" = "local_enable=false" ]; then
# local_enable="false"
# local_enable="false"
#elif [ "$2" = "local_enable=false" ]; then
local_enable="false"
local_enable="false"
fi
#echo "3..."
#sleep 1
@ -99,7 +130,6 @@ fi
#sleep 1
update_enable="true"
shell_name="bash"
err_txt=$HOME/err-enliven.txt
# doesn't work if equal: [ $0 = *"$shell_name"* ]
# could be -bash or bash
#if [ "$0" = "-bash" ]; then
@ -109,95 +139,76 @@ show_changes="true"
#if [[ $0 == *"$shell_name"* ]]; then
#doesn't work on Fedora since shell_name is blank even when in shell and not pasting:
#if [ "$shell_name" != "" ]; then
#REPO_PATH="$HOME/GitHub/EnlivenMinetest"
#echo "You must have pasted this into terminal, so assuming REPO_PATH:"
#echo " $REPO_PATH"
#REPO_PATH="$HOME/GitHub/EnlivenMinetest"
#echo "You must have pasted this into terminal, so assuming REPO_PATH:"
#echo " $REPO_PATH"
#else
SCRIPT=$(readlink -f "$0")
if [ "$SCRIPT" = "/bin/bash" ]; then
SCRIPT=minetestenv.rc
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."
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
SCRIPT=$(readlink -f "$0")
if [ "$SCRIPT" = "/bin/bash" ]; then
SCRIPT=minetestenv.rc
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."
fi
fi
fi
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")
REPO_PATH="$SCRIPTPATH"
#formerly, this script was in a subdir:
#REPO_PATH=$(dirname "$SCRIPTPATH")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")
REPO_PATH="$SCRIPTPATH"
#formerly, this script was in a subdir:
#REPO_PATH=$(dirname "$SCRIPTPATH")
#fi
PATCHES_PATH="$REPO_PATH/patches"
echo "PATCHES_PATH: $PATCHES_PATH"
sleep 10
if [ ! -d "$PATCHES_PATH" ]; then
# maybe moved somewhere or this code was pasted
PATCHES_PATH=$HOME/GitHub/EnlivenMinetest/patches
# maybe moved somewhere or this code was pasted
PATCHES_PATH=$HOME/GitHub/EnlivenMinetest/patches
fi
if [ ! -d "$PATCHES_PATH" ]; then
# maybe running from root of repo
PATCHES_PATH="patches"
# maybe running from root of repo
PATCHES_PATH="patches"
fi
if [ ! -d "$PATCHES_PATH" ]; then
# should work if ran from folder where exists
PATCHES_PATH="../patches"
# should work if ran from folder where exists
PATCHES_PATH="../patches"
fi
if [ ! -d "$PATCHES_PATH" ]; then
echo
echo
echo "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
echo
echo
customDie "ERROR: could not find patches such as in $PATCHES_PATH"
fi
# 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
try_path="/usr/share/minetest"
if [ -d "$try_path" ]; then
# Arch linux
USR_SHARE_MINETEST="$try_path"
# Arch linux
USR_SHARE_MINETEST="$try_path"
fi
if [ "$local_enable" != "false" ]; then
# IF git version is installed
try_path="/usr/local/share/minetest"
if [ -d "$try_path" ]; then
#if [ -z "$version_0_5_enable" ]; then
# version_0_5_enable="true"
#fi
USR_SHARE_MINETEST="$try_path"
fi
# IF git version is installed
try_path="/usr/local/share/minetest"
if [ -d "$try_path" ]; then
#if [ -z "$version_0_5_enable" ]; then
# version_0_5_enable="true"
#fi
USR_SHARE_MINETEST="$try_path"
fi
fi
version_0_5_enable="false"
if [ -d "$USR_SHARE_MINETEST/games/minetest_game/mods/player_api" ]; then
customDie "failed to create $USR_SHARE_MINETEST/games/minetest_game, so cannot continue."
fi
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"
fi
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
else
echo "ERROR: refusing to reinstall minetest_game to packaged dir: $MT_MINETEST_GAME_PATH"
fi
}
add_zip_mod()
{
cd $RELEASES_PATH
MTMOD_DEST_NAME=$1
MTMOD_GOT_NAME=$2
URL=$3
MTMOD_SRC_ZIP=$MTMOD_DEST_NAME.zip
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..."
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
MTMOD_DEST_NAME=$1
MTMOD_GOT_NAME=$2
if [ ! -f "$MOD_LIST" ]; then touch "$MOD_LIST"; fi
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)"
fi
if [ -d "$MTMOD_DEST_PATH/.git" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH/.git"
if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
if [ ! -d "$MTMOD_GOT_NAME" ]; then
customDie "ERROR: nothing done since add_mod_from_here FAILED to find '$MTMOD_GOT_NAME'"
fi
if [ -f "$MTMOD_DEST_PATH/.gitignore" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH/.gitignore"
if [ -d "$MTMOD_DEST_PATH" ]; then
if [ ! -f "`command -v rsync`" ]; then
echo "removing old $MTMOD_DEST_PATH"
rm -Rf "$MTMOD_DEST_PATH"
if [ -d "$MTMOD_DEST_PATH" ]; then
customDie "FAILED to remove '$MTMOD_DEST_PATH'"
fi
fi
fi
# remove etc to make users downloading mods faster:
if [ -d "$MTMOD_DEST_PATH/etc" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH/etc"
if [ -d "$MTMOD_GOT_NAME" ]; then
# outer case is for safety in case variable is blank or something
if [ ! -f "`command -v rsync`" ]; then
cp -R $MTMOD_GOT_NAME "$MTMOD_DEST_PATH"
if [ "$show_changes" != "false" ]; then
echo "$MTMOD_DEST_PATH"
fi
else
if [ ! -d "$MTMOD_DEST_PATH" ]; then
mkdir -p "$MTMOD_DEST_PATH"
fi
if [ "$show_changes" != "false" ]; then
#rsync -rtv "$MTMOD_GOT_NAME/" "$MTMOD_DEST_PATH"
echo " * preview of changes (before actual sync):"
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
echo
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."