Browse Source

install ENLIVEN-minetest_game as non-root

master
poikilos 6 years ago
committed by Jacob Gustafson
parent
commit
21cccabc3b
  1. 17
      CHANGELOG.md
  2. 751
      minetestenv.rc
  3. 1080
      utilities/deprecated/install-ENLIVEN-minetest_game.sh

17
CHANGELOG.md

@ -1,5 +1,22 @@
# Changelog # Changelog
## [git] - 2019-05-29
### Added
(minetestenv.rc and utilities/deprecated/install-ENLIVEN-minetest_game.sh
* MT_MYGAMES_DIR (~/.minetest/games)
### Changed
(minetestenv.rc and utilities/deprecated/install-ENLIVEN-minetest_game.sh
* install game as non-root always
- MT_MYGAME_DIR from `$SYSTEM_MT_GAMES_DIR/$MT_MYGAME_NAME`
to `$MT_MYGAMES_DIR/$MT_MYGAME_NAME` (`$MT_MYGAMES_DIR/ENLIVEN`)
- renamed MT_GAMES_DIR to SYSTEM_MT_GAMES_DIR
- MT_BACKUP_GAMES_DIR from `$HOME/Backup$USR_SHARE_MINETEST/games`
to `$HOME/.minetest/games-disabled`
- MT_MYGAME_BAK from `$USR_SHARE_MINETEST/ENLIVEN_BAK`
to `$MT_BACKUP_GAMES_DIR/ENLIVEN_BAK`
## [git] - 2018-03-27 ## [git] - 2018-03-27
### Added ### Added
* overrides for world.conf and world.mt (only if you have the directory * overrides for world.conf and world.mt (only if you have the directory

751
minetestenv.rc

@ -1,59 +1,90 @@
err_txt=$HOME/err-enliven.txt
echo "# * minetestenv.rc started `date`" > "$err_txt"
customDie() {
echo
errorLevel=1
if [ -z "$2" ]; then
errorLevel=$2
fi
if [ -z "$1" ]; then
echo "Unknown error."
else
echo "ERROR:"
echo "$1" >> "$err_txt"
fi
echo "$1"
echo
echo "'$err_txt' may contain more information."
echo
echo "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 $errorLevel
}
CONFIG_PATH="$HOME/.config/EnlivenMinetest" CONFIG_PATH="$HOME/.config/EnlivenMinetest"
CACHE_PATH="$HOME/.cache/EnlivenMinetest" CACHE_PATH="$HOME/.cache/EnlivenMinetest"
if [ ! -d "$CONFIG_PATH" ]; then if [ ! -d "$CONFIG_PATH" ]; then
mkdir -p "$CONFIG_PATH" mkdir -p "$CONFIG_PATH"
fi fi
if [ ! -d "$CACHE_PATH" ]; then if [ ! -d "$CACHE_PATH" ]; then
mkdir -p "$CACHE_PATH" mkdir -p "$CACHE_PATH"
fi fi
RELEASES_PATH="$CACHE_PATH/releases" RELEASES_PATH="$CACHE_PATH/releases"
if [ -d "$CONFIG_PATH/cache/releases" ]; then if [ -d "$CONFIG_PATH/cache/releases" ]; then
# upgrade/remove cache from older versions of this script # upgrade/remove cache from older versions of this script
if [ ! -d "$CACHE_PATH/releases" ]; then if [ ! -d "$CACHE_PATH/releases" ]; then
mv "$CONFIG_PATH/cache/releases" "$CACHE_PATH/" mv "$CONFIG_PATH/cache/releases" "$CACHE_PATH/"
echo "upgraded cache from older version of this script (moved to $RELEASES_PATH)" echo "upgraded cache from older version of this script (moved to $RELEASES_PATH)"
else else
rm -Rf "$CONFIG_PATH/cache/releases" rm -Rf "$CONFIG_PATH/cache/releases"
echo "removed redundant cache from older version of this script: $CONFIG_PATH/cache/releases" echo "removed redundant cache from older version of this script: $CONFIG_PATH/cache/releases"
fi fi
fi fi
if [ ! -d "$RELEASES_PATH" ]; then if [ ! -d "$RELEASES_PATH" ]; then
mkdir -p "$RELEASES_PATH" mkdir -p "$RELEASES_PATH"
fi fi
GIT_REPOS_PATH="$CACHE_PATH/git" GIT_REPOS_PATH="$CACHE_PATH/git"
if [ -d "$CONFIG_PATH/cache/git" ]; then if [ -d "$CONFIG_PATH/cache/git" ]; then
if [ ! -d "$CACHE_PATH/git" ]; then if [ ! -d "$CACHE_PATH/git" ]; then
mv "$CONFIG_PATH/cache/git" "$CACHE_PATH/" mv "$CONFIG_PATH/cache/git" "$CACHE_PATH/"
echo "upgraded cache from older version of this script (moved to $GIT_REPOS_PATH)" echo "upgraded cache from older version of this script (moved to $GIT_REPOS_PATH)"
else else
rm -Rf "$CONFIG_PATH/cache/git" rm -Rf "$CONFIG_PATH/cache/git"
echo "removed redundant cache from older version of this script: $CONFIG_PATH/cache/git" echo "removed redundant cache from older version of this script: $CONFIG_PATH/cache/git"
fi fi
fi fi
if [ ! -d "$GIT_REPOS_PATH" ]; then if [ ! -d "$GIT_REPOS_PATH" ]; then
mkdir -p "$GIT_REPOS_PATH" mkdir -p "$GIT_REPOS_PATH"
fi fi
GIT_BRANCHES_PATH="$CACHE_PATH/git-branches" GIT_BRANCHES_PATH="$CACHE_PATH/git-branches"
if [ -d "$CONFIG_PATH/cache/git-branches" ]; then if [ -d "$CONFIG_PATH/cache/git-branches" ]; then
# upgrade/remove cache from older versions of this script # upgrade/remove cache from older versions of this script
if [ ! -d "$CACHE_PATH/git-branches" ]; then if [ ! -d "$CACHE_PATH/git-branches" ]; then
mv "$CONFIG_PATH/cache/git-branches" "$CACHE_PATH/" mv "$CONFIG_PATH/cache/git-branches" "$CACHE_PATH/"
echo "upgraded cache from older version of this script (moved to $GIT_BRANCHES_PATH)" echo "upgraded cache from older version of this script (moved to $GIT_BRANCHES_PATH)"
else else
rm -Rf "$CONFIG_PATH/cache/git-branches" rm -Rf "$CONFIG_PATH/cache/git-branches"
echo "removed redundant cache from older version of this script: $CONFIG_PATH/cache/git-branches" echo "removed redundant cache from older version of this script: $CONFIG_PATH/cache/git-branches"
fi fi
fi fi
if [ ! -d "$GIT_BRANCHES_PATH" ]; then if [ ! -d "$GIT_BRANCHES_PATH" ]; then
mkdir -p "$GIT_BRANCHES_PATH" mkdir -p "$GIT_BRANCHES_PATH"
fi fi
if [ -d "$CONFIG_PATH/cache" ]; then if [ -d "$CONFIG_PATH/cache" ]; then
rmdir "$CONFIG_PATH/cache" rmdir "$CONFIG_PATH/cache"
fi fi
MOD_LIST="$CONFIG_PATH/mod_list.txt" MOD_LIST="$CONFIG_PATH/mod_list.txt"
@ -61,35 +92,35 @@ MOD_LIST="$CONFIG_PATH/mod_list.txt"
# * 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
version_0_5_enable="true" version_0_5_enable="true"
fi fi
if [ -f "$CONFIG_PATH/local_enable" ]; then if [ -f "$CONFIG_PATH/local_enable" ]; then
local_enable=$(head -n 1 $CONFIG_PATH/local_enable) local_enable=$(head -n 1 $CONFIG_PATH/local_enable)
fi fi
#if [ -f "$CONFIG_PATH/version_0_5_enable" ]; then #if [ -f "$CONFIG_PATH/version_0_5_enable" ]; then
# version_0_5_enable=$(head -n 1 $CONFIG_PATH/version_0_5_enable) # version_0_5_enable=$(head -n 1 $CONFIG_PATH/version_0_5_enable)
#fi #fi
if [ -z "$local_enable" ]; then if [ -z "$local_enable" ]; then
echo "$local_enable" > "$CONFIG_PATH/local_enable" echo "$local_enable" > "$CONFIG_PATH/local_enable"
fi fi
#if [ -z "$version_0_5_enable" ]; then #if [ -z "$version_0_5_enable" ]; then
# echo "$version_0_5_enable" > "$CONFIG_PATH/version_0_5_enable" # echo "$version_0_5_enable" > "$CONFIG_PATH/version_0_5_enable"
#fi #fi
mtgame_name="minetest_game" mtgame_name="minetest_game"
@ -208,102 +219,91 @@ MT_MINETEST_GAME_PATH=$USR_SHARE_MINETEST/games/$mtgame_name
#sleep 1 #sleep 1
#echo "1..." #echo "1..."
#sleep 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: # 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_BACKUP_GAMES_DIR=$HOME/.minetest/games-disabled
MT_GAMES_DIR=$USR_SHARE_MINETEST/games SYSTEM_MT_GAMES_DIR=$USR_SHARE_MINETEST/games
MT_MYGAME_BAK=$USR_SHARE_MINETEST/ENLIVEN_BAK MT_MYGAMES_DIR=$HOME/.minetest/games
MT_MYGAME_BAK=$MT_BACKUP_GAMES_DIR/ENLIVEN_BAK
MT_MYGAME_NAME=ENLIVEN MT_MYGAME_NAME=ENLIVEN
#$PREFIX/minetest/games/ENLIVEN: MT_MYGAME_DIR="$MT_MYGAMES_DIR/$MT_MYGAME_NAME"
MT_MYGAME_DIR="$MT_GAMES_DIR/$MT_MYGAME_NAME"
# formerly MT_MYGAME_MODDIR: # formerly MT_MYGAME_MODDIR:
MT_MYGAME_MODS_PATH="$MT_MYGAME_DIR/mods" MT_MYGAME_MODS_PATH="$MT_MYGAME_DIR/mods"
MT_WORLDS_DIR="$HOME/.minetest/worlds" 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_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" MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME"
if [ -z "$MT_DEFAULT_WORLD_NAME" ]; then if [ -z "$MT_DEFAULT_WORLD_NAME" ]; then
#if [ -z "`ls $MT_WORLDS_DIR | grep --max-count=1 -v world`" ]; then #if [ -z "`ls $MT_WORLDS_DIR | grep --max-count=1 -v world`" ]; then
new_worlds="`ls $MT_WORLDS_DIR | grep --max-count=1 -v '^world$'`" new_worlds="`ls $MT_WORLDS_DIR | grep --max-count=1 -v '^world$'`"
if [ ! -z "$new_worlds" ]; then if [ ! -z "$new_worlds" ]; then
# anchors (`^` and `$`) ensure only exact match, so name containing world is not counted as a match # anchors (`^` and `$`) ensure only exact match, so name containing world is not counted as a match
# see also <https://stackoverflow.com/questions/4709912/how-to-make-grep-only-match-if-the-entire-line-matches> # see also <https://stackoverflow.com/questions/4709912/how-to-make-grep-only-match-if-the-entire-line-matches>
MT_MYWORLD_NAME="$new_worlds" MT_MYWORLD_NAME="$new_worlds"
else
if [ -d "$MT_WORLDS_DIR/world" ]; then
echo "Could not find any new worlds in $MT_WORLDS_DIR so using '$MT_MYWORLD_NAME'"
else else
echo "Could not find any worlds in $MT_WORLDS_DIR" if [ -d "$MT_WORLDS_DIR/world" ]; then
echo "Could not find any new worlds in $MT_WORLDS_DIR so using '$MT_MYWORLD_NAME'"
else
echo "Could not find any worlds in $MT_WORLDS_DIR"
fi
fi fi
fi #if [ "$0" = "-bash" ]; then
#if [ "$0" = "-bash" ]; then
#'[[' doesn't work in debian: #'[[' doesn't work in debian:
#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"
# MT_MYWORLD_NAME="world" # MT_MYWORLD_NAME="world"
# echo "You must have pasted this into terminal, so assuming MT_MYWORLD_NAME:" # echo "You must have pasted this into terminal, so assuming MT_MYWORLD_NAME:"
# echo " $MT_MYWORLD_NAME" # echo " $MT_MYWORLD_NAME"
# echo "Press Ctrl C to cancel, otherwise $MT_MYWORLD_NAME will be used..." # echo "Press Ctrl C to cancel, otherwise $MT_MYWORLD_NAME will be used..."
# #sleep 1 # #sleep 1
# #echo " 3..." # #echo " 3..."
# #sleep 1 # #sleep 1
# #echo " 2..." # #echo " 2..."
# sleep 1 # sleep 1
# echo " 1..." # echo " 1..."
# sleep 1 # sleep 1
#else #else
read -e -p "Please enter a world (name only--must be in $MT_WORLDS_DIR): " -i "$MT_MYWORLD_NAME" MT_MYWORLD_NAME read -e -p "Please enter a world (name only--must be in $MT_WORLDS_DIR): " -i "$MT_MYWORLD_NAME" MT_MYWORLD_NAME
#$MT_DEFAULT_WORLD_NAME #$MT_DEFAULT_WORLD_NAME
echo using "$MT_MYWORLD_NAME" echo using "$MT_MYWORLD_NAME"
#echo " 3..." #echo " 3..."
#sleep 1 #sleep 1
#echo " 2..." #echo " 2..."
sleep 1 sleep 1
echo " 1..." echo " 1..."
sleep 1 sleep 1
#fi #fi
else else
#NOTE: $0 doesn't work because gives actual command (such as `./filename.sh`--gives filename only if command was `bash filename.sh`) #NOTE: $0 doesn't work because gives actual command (such as `./filename.sh`--gives filename only if command was `bash filename.sh`)
#'[[' doesn't work in debian: #'[[' doesn't work in debian:
#if [[ $0 == *"$shell_name"* ]]; then #if [[ $0 == *"$shell_name"* ]]; then
#if [ "$shell_name" = "" ]; then echo "running normally (not pasted)" #if [ "$shell_name" = "" ]; then echo "running normally (not pasted)"
#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"
# MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME" # MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME"
# echo "You must have pasted this into terminal, so assuming MT_MYWORLD_NAME:" # echo "You must have pasted this into terminal, so assuming MT_MYWORLD_NAME:"
# echo " $MT_MYWORLD_NAME" # echo " $MT_MYWORLD_NAME"
#else #else
ls $MT_WORLDS_DIR ls $MT_WORLDS_DIR
read -p "Please enter a world [blank for $MT_DEFAULT_WORLD_NAME]: " MT_MYWORLD_NAME read -p "Please enter a world [blank for $MT_DEFAULT_WORLD_NAME]: " MT_MYWORLD_NAME
#$MT_DEFAULT_WORLD_NAME #$MT_DEFAULT_WORLD_NAME
if [ -z "$MT_MYWORLD_NAME" ]; then if [ -z "$MT_MYWORLD_NAME" ]; then
MT_MYWORLD_NAME=$MT_DEFAULT_WORLD_NAME MT_MYWORLD_NAME=$MT_DEFAULT_WORLD_NAME
fi fi
echo using "$MT_MYWORLD_NAME" echo using "$MT_MYWORLD_NAME"
echo " 3..." echo " 3..."
sleep 1 sleep 1
echo " 2..." echo " 2..."
sleep 1 sleep 1
echo " 1..." echo " 1..."
if [ -z "$MT_MYWORLD_NAME" ]; then if [ -z "$MT_MYWORLD_NAME" ]; then
MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME" MT_MYWORLD_NAME="$MT_DEFAULT_WORLD_NAME"
fi fi
#fi #fi
fi fi
if [ ! -d "$MT_WORLDS_DIR/$MT_MYWORLD_NAME" ]; then if [ ! -d "$MT_WORLDS_DIR/$MT_MYWORLD_NAME" ]; then
echo " ERROR: failed to find world path, so cannot continue." > $err_txt customDie " ERROR: failed to find world path, so cannot continue."
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 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"
@ -311,270 +311,211 @@ WORLD_MT_PATH=$MT_MYWORLD_DIR/world.mt
# see also https://www.shellscript.sh/functions.html # see also https://www.shellscript.sh/functions.html
reinstall_mt_game() { reinstall_mt_game() {
if [ "$MT_MINETEST_GAME_PATH" = "/usr/local/share/minetest/games/minetest_game" ]; then if [ "$MT_MINETEST_GAME_PATH" = "/usr/local/share/minetest/games/minetest_game" ]; then
SRC_MT="$HOME/minetest" SRC_MT="$HOME/minetest"
if [ -d "$HOME/Downloads/minetest/games/minetest_game" ]; then if [ -d "$HOME/Downloads/minetest/games/minetest_game" ]; then
SRC_MT="$HOME/Downloads/minetest" SRC_MT="$HOME/Downloads/minetest"
fi fi
if [ -d "$SRC_MT" ]; then if [ -d "$SRC_MT" ]; then
SRC_MT_GAME="$SRC_MT/games/minetest_game" SRC_MT_GAME="$SRC_MT/games/minetest_game"
cd $SRC_MT_GAME cd $SRC_MT_GAME
echo "updating $SRC_MT_GAME..." echo "updating $SRC_MT_GAME..."
git pull git pull || echo "rm -Rf \"`pwd`\" # FAILED: cd \"`pwd`\" && git pull" >> "$err_txt"
cd cd
sudo rm -Rf "$MT_MINETEST_GAME_PATH" sudo rm -Rf "$MT_MINETEST_GAME_PATH"
sudo cp -R "$SRC_MT_GAME" "$USR_SHARE_MINETEST/games/" sudo cp -R "$SRC_MT_GAME" "$USR_SHARE_MINETEST/games/"
if [ -d "$USR_SHARE_MINETEST/games/minetest_game" ]; then if [ -d "$USR_SHARE_MINETEST/games/minetest_game" ]; then
echo "successfully recreated $USR_SHARE_MINETEST/games/minetest_game" echo "successfully recreated $USR_SHARE_MINETEST/games/minetest_game"
else else
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
rm -Rf $MTMOD_GOT_NAME rm -Rf $MTMOD_GOT_NAME
fi fi
if [ -f $MTMOD_SRC_ZIP ]; then if [ -f $MTMOD_SRC_ZIP ]; then
rm -f $MTMOD_SRC_ZIP rm -f $MTMOD_SRC_ZIP
fi fi
wget -O $MTMOD_SRC_ZIP $URL wget -O $MTMOD_SRC_ZIP $URL
unzip -q "$MTMOD_SRC_ZIP" unzip -q "$MTMOD_SRC_ZIP"
add_mod_from_here $MTMOD_DEST_NAME $MTMOD_GOT_NAME add_mod_from_here $MTMOD_DEST_NAME $MTMOD_GOT_NAME
} }
add_git_mod() add_git_mod()
{ {
cd $GIT_REPOS_PATH cd $GIT_REPOS_PATH
MTMOD_DEST_NAME=$1 MTMOD_DEST_NAME=$1
MTMOD_GOT_NAME=$2 MTMOD_GOT_NAME=$2
URL=$3 URL=$3
BRANCH=$4 BRANCH=$4
if [ ! -z "$BRANCH" ]; then
cd $GIT_BRANCHES_PATH
if [ ! -d "$BRANCH" ]; then
mkdir "$BRANCH"
fi
cd "$BRANCH"
fi
if [ ! -d "$MTMOD_GOT_NAME" ]; then
if [ ! -z "$BRANCH" ]; then if [ ! -z "$BRANCH" ]; then
echo "BRANCH: Cloning $BRANCH branch..." cd $GIT_BRANCHES_PATH
echo "git clone -b $BRANCH --single-branch $URL" if [ ! -d "$BRANCH" ]; then
git clone -b $BRANCH --single-branch $URL mkdir "$BRANCH"
fi
cd "$BRANCH"
fi
if [ ! -d "$MTMOD_GOT_NAME" ]; then
if [ ! -z "$BRANCH" ]; then
echo "BRANCH: Cloning $BRANCH branch..."
this_git_cmd="git clone -b $BRANCH --single-branch $URL"
echo "$this_git_cmd"
git clone -b $BRANCH --single-branch $URL || echo "#FAILED: cd \"`pwd`\" && $this_git_cmd" >> "$err_txt"
else
#echo "Cloning main branch since no branch specified: $BRANCH"
this_git_cmd="git clone $URL"
echo "$this_git_cmd"
git clone $URL || echo "#FAILED: cd \"`pwd`\" && $this_git_cmd" >> "$err_txt"
fi
else else
#echo "Cloning main branch since no branch specified: $BRANCH" cd $MTMOD_GOT_NAME
echo "git clone $URL" echo "updating mod $MTMOD_GOT_NAME in `pwd`..."
git clone $URL git pull || echo "rm -Rf \"`pwd`\" # FAILED: cd \"`pwd`\" && git pull" >> "$err_txt"
cd ..
fi fi
else add_mod_from_here $MTMOD_DEST_NAME $MTMOD_GOT_NAME
cd $MTMOD_GOT_NAME
git pull
cd ..
fi
add_mod_from_here $MTMOD_DEST_NAME $MTMOD_GOT_NAME
} }
add_mod_from_here() add_mod_from_here()
{ {
MTMOD_DEST_NAME=$1 MTMOD_DEST_NAME=$1
MTMOD_GOT_NAME=$2 MTMOD_GOT_NAME=$2
if [ ! -f "$MOD_LIST" ]; then touch "$MOD_LIST"; fi if [ ! -f "$MOD_LIST" ]; then touch "$MOD_LIST"; fi
echo "$MTMOD_DEST_NAME" >> "$MOD_LIST" echo "$MTMOD_DEST_NAME" >> "$MOD_LIST"
MTMOD_DEST_PATH=$MT_MYGAME_MODS_PATH/$MTMOD_DEST_NAME MTMOD_DEST_PATH=$MT_MYGAME_MODS_PATH/$MTMOD_DEST_NAME
if [ -z "$MTMOD_DEST_NAME" ]; then if [ -z "$MTMOD_DEST_NAME" ]; then
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
if [ ! -f "`command -v rsync`" ]; then
sudo 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
sudo mkdir -p "$MTMOD_DEST_PATH"
fi
if [ "$show_changes" != "false" ]; then
#sudo rsync -rtv "$MTMOD_GOT_NAME/" "$MTMOD_DEST_PATH"
echo " * preview of changes (before actual sync):"
sudo rsync -zvc "$MTMOD_GOT_NAME/" "$MTMOD_DEST_PATH" --dry-run | grep -v '\.git' | grep -v '\./' | grep -v 'screenshot\.png' | grep -v received | grep -v 'DRY RUN'
fi
echo " * synchronizing..."
sudo rsync -rt "$MTMOD_GOT_NAME/" "$MTMOD_DEST_PATH"
fi fi
if [ -d "$MTMOD_DEST_PATH/.git" ]; then if [ ! -d "$MTMOD_DEST_PATH" ] || [ "$update_enable" = "true" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH/.git" if [ ! -d "$MTMOD_GOT_NAME" ]; then
customDie "ERROR: nothing done since add_mod_from_here FAILED to find '$MTMOD_GOT_NAME'"
fi fi
if [ -f "$MTMOD_DEST_PATH/.gitignore" ]; then if [ -d "$MTMOD_DEST_PATH" ]; then
sudo rm -Rf "$MTMOD_DEST_PATH/.gitignore" 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 fi
# remove etc to make users downloading mods faster: if [ -d "$MTMOD_GOT_NAME" ]; then
if [ -d "$MTMOD_DEST_PATH/etc" ]; then # outer case is for safety in case variable is blank or something
sudo rm -Rf "$MTMOD_DEST_PATH/etc" 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):"
rsync -zvc "$MTMOD_GOT_NAME/" "$MTMOD_DEST_PATH" --dry-run | grep -v '\.git' | grep -v '\./' | grep -v 'screenshot\.png' | grep -v received | grep -v 'DRY RUN'
fi
echo " * synchronizing..."
rsync -rt "$MTMOD_GOT_NAME/" "$MTMOD_DEST_PATH"
fi
if [ -d "$MTMOD_DEST_PATH/.git" ]; then
rm -Rf "$MTMOD_DEST_PATH/.git"
fi
if [ -f "$MTMOD_DEST_PATH/.gitignore" ]; then
rm -Rf "$MTMOD_DEST_PATH/.gitignore"
fi
# remove etc to make users downloading mods faster:
if [ -d "$MTMOD_DEST_PATH/etc" ]; then
rm -Rf "$MTMOD_DEST_PATH/etc"
fi
if [ -d "$MTMOD_DEST_PATH/src" ]; then
if [ -z "`ls $MTMOD_DEST_PATH/src/*.lua`" ]; then
rm -Rf "$MTMOD_DEST_PATH/src"
fi
fi
if [ -f "$MTMOD_DEST_PATH/screenshot.png" ]; then
rm -f "$MTMOD_DEST_PATH/screenshot.png"
fi
fi fi
if [ -f "$MTMOD_DEST_PATH/screenshot.png" ]; then if [ ! -d "$MTMOD_DEST_PATH" ]; then
sudo rm -f "$MTMOD_DEST_PATH/screenshot.png" customDie " ERROR: failed to get $MTMOD_DEST_PATH, so cannot continue."
else
echo " [ + ] added as $MTMOD_DEST_PATH"
fi fi
fi cd
if [ ! -d "$MTMOD_DEST_PATH" ]; then #if [ -d GitHub/EnlivenMinetest ]; then
echo " ERROR: failed to get $MTMOD_DEST_PATH, so cannot continue." > $err_txt # cd GitHub/EnlivenMinetest
cat $err_txt #fi
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 else
echo " [ ~ ] skipped existing $MTMOD_DEST_PATH" echo " [ ~ ] skipped existing $MTMOD_DEST_PATH"
fi fi
} }
remove_mod() remove_mod()
{ {
cd $HOME/Downloads cd $HOME/Downloads
MTMOD_DEST_NAME=$1 MTMOD_DEST_NAME=$1
MTMOD_DEST_PATH=$MT_MYGAME_MODS_PATH/$MTMOD_DEST_NAME 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 if [ -d "$MTMOD_DEST_PATH" ]; then
echo " ERROR in remove_mod: failed to remove $MTMOD_DEST_PATH, so cannot continue." > $err_txt rm -Rf "$MTMOD_DEST_PATH"
cat $err_txt if [ -d "$MTMOD_DEST_PATH" ]; then
echo " press Ctrl C to cancel ENLIVEN install or this terminal will close..." echo " ERROR in remove_mod: failed to remove $MTMOD_DEST_PATH, so cannot continue." > $err_txt
sleep 1 cat $err_txt
echo " 3..." else
sleep 1 echo " [ - ] removed $MTMOD_DEST_PATH"
echo " 2..." fi
sleep 1
echo " 1..."
sleep 1
exit 1
else else
echo " [ - ] removed $MTMOD_DEST_PATH" echo " [ - ] already not present: $MTMOD_DEST_PATH"
fi fi
else cd
echo " [ - ] already not present: $MTMOD_DEST_PATH" #if [ -d GitHub/EnlivenMinetest ]; then
fi # cd GitHub/EnlivenMinetest
cd #fi
#if [ -d GitHub/EnlivenMinetest ]; then
# cd GitHub/EnlivenMinetest
#fi
} }
#echo "MT_MYGAME_MODS_PATH: $MT_MYGAME_MODS_PATH" #echo "MT_MYGAME_MODS_PATH: $MT_MYGAME_MODS_PATH"
echo echo
echo echo
echo "To preconfigure, write true or false to files in $CONFIG_PATH named:" echo "To preconfigure, write true or false to files in $CONFIG_PATH named:"
echo " local_enable" echo " local_enable"
#echo " version_0_5_enable" #echo " version_0_5_enable"
echo echo
echo "Using following configuration:" echo "Using following configuration:"
#if [ -z "$version_0_5_enable" ]; then #if [ -z "$version_0_5_enable" ]; then
# echo " version_0_5_enable: (auto--set this var before pasting region into terminal)" # echo " version_0_5_enable: (auto--set this var before pasting region into terminal)"
#else #else
echo " version_0_5_enable: $version_0_5_enable" echo " version_0_5_enable: $version_0_5_enable"
#fi #fi
if [ -z "$local_enable" ]; then if [ -z "$local_enable" ]; then
echo " local_enable: (auto--set this var before pasting region into terminal)" echo " local_enable: (auto--set this var before pasting region into terminal)"
else else
echo " local_enable: $local_enable" echo " local_enable: $local_enable"
fi fi
echo " USR_SHARE_MINETEST: $USR_SHARE_MINETEST" echo " USR_SHARE_MINETEST: $USR_SHARE_MINETEST"
echo " MT_MYGAME_DIR: $MT_MYGAME_DIR" echo " MT_MYGAMES_DIR: $MT_MYGAMES_DIR"
echo " MT_WORLDS_DIR: $MT_WORLDS_DIR" echo " MT_MYGAME_DIR: $MT_MYGAME_DIR"
echo " MT_MYWORLD_NAME: $MT_MYWORLD_NAME" echo " MT_WORLDS_DIR: $MT_WORLDS_DIR"
echo " MT_MINETEST_GAME_PATH: $MT_MINETEST_GAME_PATH" echo " MT_MYWORLD_NAME: $MT_MYWORLD_NAME"
echo " MT_MINETEST_GAME_PATH: $MT_MINETEST_GAME_PATH"
if [ ! -f "`command -v rsync`" ]; then if [ ! -f "`command -v rsync`" ]; then
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." 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
fi fi
echo "# * minetestenv.rc finished loading." >> "$err_txt"

1080
utilities/deprecated/install-ENLIVEN-minetest_game.sh

File diff suppressed because it is too large
Loading…
Cancel
Save