This is an experimental copy for testing Poikilos' issue mirroring system. Note that Gitea's migration tool can import issues, but the "Issues" checkbox is disabled when "This repository will be a mirror" is enabled (it is for this repo).
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

435 lines
13 KiB

CONFIGS_PATH="$HOME/.config/EnlivenMinetest"
if [ ! -d "$CONFIGS_PATH" ]; then
mkdir -p "$CONFIGS_PATH"
fi
# * 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
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"
#elif [ "$2" = "version_0_5_enable=true" ]; then
# version_0_5_enable="true"
#elif [ "$1" = "version_0_5_enable=false" ]; then
# version_0_5_enable="false"
#elif [ "$2" = "version_0_5_enable=false" ]; then
# version_0_5_enable="false"
#fi
if [ "$1" = "local_enable=true" ]; then
local_enable="true"
#elif [ "$2" = "local_enable=true" ]; then
# local_enable="true"
elif [ "$1" = "local_enable=false" ]; then
# local_enable="false"
#elif [ "$2" = "local_enable=false" ]; then
local_enable="false"
fi
#echo "3..."
#sleep 1
#echo "2..."
#sleep 1
#echo "1..."
#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
#'[[' doesn't work in debian
if [[ $0 == *"$shell_name"* ]]; then
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")
# Absolute path this script is in, thus /home/user/bin
SCRIPTPATH=$(dirname "$SCRIPT")
REPO_PATH=$(dirname "$SCRIPTPATH")
fi
PATCHES_PATH="$REPO_PATH/patches"
if [ ! -d "$PATCHES_PATH" ]; then
# 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"
fi
if [ ! -d "$PATCHES_PATH" ]; then
# 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
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"
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
fi
version_0_5_enable="false"
if [ -d "$USR_SHARE_MINETEST/games/minetest_game/mods/player_api" ]; then
version_0_5_enable="true"
fi
if [ -f "$CONFIGS_PATH/local_enable" ]; then
local_enable=$(head -n 1 $CONFIGS_PATH/local_enable)
fi
#if [ -f "$CONFIGS_PATH/version_0_5_enable" ]; then
# version_0_5_enable=$(head -n 1 $CONFIGS_PATH/version_0_5_enable)
#fi
if [ -z "$local_enable" ]; then
echo "$local_enable" > "$CONFIGS_PATH/local_enable"
fi
#if [ -z "$version_0_5_enable" ]; then
# echo "$version_0_5_enable" > "$CONFIGS_PATH/version_0_5_enable"
#fi
mtgame_name="minetest_game"
MT_MINETEST_GAME_PATH=$USR_SHARE_MINETEST/games/$mtgame_name
#echo "3..."
#sleep 1
#echo "2..."
#sleep 1
#echo "1..."
#sleep 1
# UNUSED (unknown use): MT_GAMES_DIR=$HOME/.minetest/mods
# intentionally skip the slash in the following line since $USR_SHARE_MINETEST already starts with one:
MT_BACKUP_GAMES_DIR=$HOME/Backup$USR_SHARE_MINETEST/games
MT_GAMES_DIR=$USR_SHARE_MINETEST/games
MT_MYGAME_BAK=$USR_SHARE_MINETEST/ENLIVEN_BAK
MT_MYGAME_NAME=ENLIVEN
MT_MYGAME_DIR="$MT_GAMES_DIR/$MT_MYGAME_NAME"
# formerly MT_MYGAME_MODDIR:
MT_MYGAME_MODS_PATH="$MT_MYGAME_DIR/mods"
MT_WORLDS_DIR="$HOME/.minetest/worlds"
MT_DEFAULT_WORLD_NAME="`ls $MT_WORLDS_DIR | grep -v tar.gz | grep --max-count=1 -v world`" # aka -m 1 (no '=' sign in that case)
MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME"
if [ -z "$MT_DEFAULT_WORLD_NAME" ]; then
if [ ! -z "`ls $MT_WORLDS_DIR | grep --max-count=1 -v world`" ]; then
MT_MYWORLD_NAME=world
echo "Could not find any worlds other than $MT_MYWORLD_NAME"
else
echo "Could not find any worlds"
fi
#if [ "$0" = "-bash" ]; then
#'[[' doesn't work in debian:
if [[ $0 == *"$shell_name"* ]]; then
REPO_PATH="$HOME/GitHub/EnlivenMinetest"
MT_MYWORLD_NAME="world"
echo "You must have pasted this into terminal, so assuming MT_MYWORLD_NAME:"
echo " $MT_MYWORLD_NAME"
echo "Press Ctrl C to cancel, otherwise $MT_MYWORLD_NAME will be used..."
#sleep 1
#echo " 3..."
#sleep 1
#echo " 2..."
sleep 1
echo " 1..."
sleep 1
else
read -p "Please enter a world (name only--must be in $MT_WORLDS_DIR): " MT_MYWORLD_NAME
#$MT_DEFAULT_WORLD_NAME
echo using "$MT_MYWORLD_NAME"
#echo " 3..."
#sleep 1
#echo " 2..."
sleep 1
echo " 1..."
sleep 1
fi
else
#'[[' doesn't work in debian:
if [[ $0 == *"$shell_name"* ]]; then
REPO_PATH="$HOME/GitHub/EnlivenMinetest"
MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME"
echo "You must have pasted this into terminal, so assuming MT_MYWORLD_NAME:"
echo " $MT_MYWORLD_NAME"
else
ls $MT_WORLDS_DIR
read -p "Please enter a world [blank for $MT_DEFAULT_WORLD_NAME]: " MT_MYWORLD_NAME
#$MT_DEFAULT_WORLD_NAME
if [ -z "$MT_MYWORLD_NAME" ]; then
MT_MYWORLD_NAME=$MT_DEFAULT_WORLD_NAME
fi
echo using "$MT_MYWORLD_NAME"
echo " 3..."
sleep 1
echo " 2..."
sleep 1
echo " 1..."
if [ -z "$MT_MYWORLD_NAME" ]; then
MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME"
fi
fi
fi
if [ ! -d "$MT_WORLDS_DIR/$MT_MYWORLD_NAME" ]; then
echo " ERROR: failed to find world path, so cannot continue." > $err_txt
cat $err_txt
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
MT_MYWORLD_DIR=$MT_WORLDS_DIR/$MT_MYWORLD_NAME
echo "Using world at $MT_MYWORLD_DIR"
WORLD_MT_PATH=$MT_MYWORLD_DIR/world.mt
# see also https://www.shellscript.sh/functions.html
reinstall_mt_game() {
if [ "$MT_MINETEST_GAME_PATH" = "/usr/local/share/minetest/games/minetest_game" ]; then
SRC_MT="$HOME/minetest"
if [ -d "$HOME/Downloads/minetest/games/minetest_game" ]; then
SRC_MT="$HOME/Downloads/minetest"
fi
if [ -d "$SRC_MT" ]; then
SRC_MT_GAME="$SRC_MT/games/minetest_game"
cd $SRC_MT_GAME
echo "updating $SRC_MT_GAME..."
git pull
cd
sudo rm -Rf "$MT_MINETEST_GAME_PATH"
sudo cp -R "$SRC_MT_GAME" "$USR_SHARE_MINETEST/games/"
if [ -d "$USR_SHARE_MINETEST/games/minetest_game" ]; then
echo "successfully recreated $USR_SHARE_MINETEST/games/minetest_game"
else
echo " ERROR: failed to create $USR_SHARE_MINETEST/games/minetest_game, so cannot continue." > $err_txt
cat $err_txt
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
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 to packaged dir: $MT_MINETEST_GAME_PATH"
fi
}
add_zip_mod()
{
cd $HOME/Downloads
MTMOD_DEST_NAME=$1
MTMOD_UNZ_NAME=$2
URL=$3
MTMOD_SRC_ZIP=$MTMOD_DEST_NAME.zip
MTMOD_DEST_PATH=$MT_MYGAME_MODS_PATH/$MTMOD_DEST_NAME
if [ ! -z "`ls | grep $MTMOD_UNZ_NAME`" ]; then # works with wildcard in variable
rm -Rf $MTMOD_UNZ_NAME
fi
if [ -f $MTMOD_SRC_ZIP ]; then
rm -f $MTMOD_SRC_ZIP
fi
if [ -d "$MTMOD_DEST_PATH" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH"
fi
wget -O $MTMOD_SRC_ZIP $URL
unzip -q "$MTMOD_SRC_ZIP"
#-q: quiet
if [ -d "$MTMOD_UNZ_NAME" ]; then
# outer case is for safety in case variable is blank or something
if [ -d "$MTMOD_UNZ_NAME/.git" ]; then
rm -Rf "$MTMOD_UNZ_NAME/.git"
fi
if [ -f "$MTMOD_UNZ_NAME/.gitignore" ]; then
rm -Rf "$MTMOD_UNZ_NAME/.gitignore"
fi
# remove etc to make users downloading mods faster:
if [ -d "$MTMOD_UNZ_NAME/etc" ]; then
rm -Rf "$MTMOD_UNZ_NAME/etc"
fi
if [ -f "$MTMOD_UNZ_NAME/screenshot.png" ]; then
rm -f "$MTMOD_UNZ_NAME/screenshot.png"
fi
sudo mv $MTMOD_UNZ_NAME "$MTMOD_DEST_PATH"
fi
if [ ! -d "$MTMOD_DEST_PATH" ]; then
echo " ERROR: failed to unzip $MTMOD_DEST_PATH, so cannot continue." > $err_txt
cat $err_txt
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
else
echo " added as $MTMOD_DEST_PATH"
fi
cd
#if [ -d GitHub/EnlivenMinetest ]; then
# cd GitHub/EnlivenMinetest
#fi
}
add_git_mod()
{
cd $HOME/Downloads
MTMOD_DEST_NAME=$1
MTMOD_UNZ_NAME=$2
URL=$3
BRANCH=$4
MTMOD_DEST_PATH=$MT_MYGAME_MODS_PATH/$MTMOD_DEST_NAME
if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
if [ ! -z "`ls | grep $MTMOD_UNZ_NAME`" ]; then # works with wildcard in variable
rm -Rf $MTMOD_UNZ_NAME
fi
if [ -d "$MTMOD_DEST_PATH" ]; then
echo "removing old $MTMOD_DEST_PATH"
sudo rm -Rf "$MTMOD_DEST_PATH"
fi
if [ ! -z "$BRANCH" ]; then
echo "BRANCH: Cloning $BRANCH branch..."
echo "git clone -b $BRANCH --single-branch $URL"
git clone -b $BRANCH --single-branch $URL
else
#echo "Cloning main branch since no branch specified: $BRANCH"
echo "git clone $URL"
git clone $URL
fi
if [ -d "$MTMOD_UNZ_NAME" ]; then
# outer case is for safety in case variable is blank or something
if [ -d "$MTMOD_UNZ_NAME/.git" ]; then
rm -Rf "$MTMOD_UNZ_NAME/.git"
fi
if [ -f "$MTMOD_UNZ_NAME/.gitignore" ]; then
rm -Rf "$MTMOD_UNZ_NAME/.gitignore"
fi
# remove etc to make users downloading mods faster:
if [ -d "$MTMOD_UNZ_NAME/etc" ]; then
rm -Rf "$MTMOD_UNZ_NAME/etc"
fi
if [ -f "$MTMOD_UNZ_NAME/screenshot.png" ]; then
rm -f "$MTMOD_UNZ_NAME/screenshot.png"
fi
sudo mv $MTMOD_UNZ_NAME "$MTMOD_DEST_PATH"
fi
if [ ! -d "$MTMOD_DEST_PATH" ]; then
echo " ERROR: failed to unzip $MTMOD_DEST_PATH, so cannot continue." > $err_txt
cat $err_txt
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
else
echo " [ + ] added as $MTMOD_DEST_PATH"
fi
cd
#if [ -d GitHub/EnlivenMinetest ]; then
# cd GitHub/EnlivenMinetest
#fi
else
echo " [ ~ ] skipped existing $MTMOD_DEST_PATH"
fi
}
remove_mod()
{
cd $HOME/Downloads
MTMOD_DEST_NAME=$1
MTMOD_DEST_PATH=$MT_MYGAME_MODS_PATH/$MTMOD_DEST_NAME
if [ -d "$MTMOD_DEST_PATH" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH"
if [ -d "$MTMOD_DEST_PATH" ]; then
echo " ERROR in remove_mod: failed to remove $MTMOD_DEST_PATH, so cannot continue." > $err_txt
cat $err_txt
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
else
echo " [ - ] removed $MTMOD_DEST_PATH"
fi
else
echo " [ - ] already not present: $MTMOD_DEST_PATH"
fi
cd
#if [ -d GitHub/EnlivenMinetest ]; then
# cd GitHub/EnlivenMinetest
#fi
}
#echo "MT_MYGAME_MODS_PATH: $MT_MYGAME_MODS_PATH"
echo
echo
echo "To preconfigure, write true or false to files in $CONFIGS_PATH named:"
echo " local_enable"
#echo " version_0_5_enable"
echo
echo "Using following configuration:"
#if [ -z "$version_0_5_enable" ]; then
# echo " version_0_5_enable: (auto--set this var before pasting region into terminal)"
#else
echo " version_0_5_enable: $version_0_5_enable"
#fi
if [ -z "$local_enable" ]; then
echo " local_enable: (auto--set this var before pasting region into terminal)"
else
echo "local_enable: $local_enable"
fi
echo " USR_SHARE_MINETEST: $USR_SHARE_MINETEST"
echo " MT_MYGAME_DIR: $MT_MYGAME_DIR"
echo " MT_WORLDS_DIR: $MT_WORLDS_DIR"
echo " MT_MYWORLD_NAME: $MT_MYWORLD_NAME"
echo " MT_MINETEST_GAME_PATH: $MT_MINETEST_GAME_PATH"