poikilos
5 years ago
3 changed files with 822 additions and 0 deletions
@ -0,0 +1,534 @@ |
|||||
|
#!/bin/bash |
||||
|
me=`basename "$0"` |
||||
|
echo |
||||
|
echo |
||||
|
echo |
||||
|
echo "Starting install..." |
||||
|
date |
||||
|
customDie() { |
||||
|
cat <<END |
||||
|
|
||||
|
ERROR: |
||||
|
$1 |
||||
|
|
||||
|
|
||||
|
END |
||||
|
exit 1 |
||||
|
} |
||||
|
customWarn() { |
||||
|
cat <<END |
||||
|
|
||||
|
WARNING: |
||||
|
$1 |
||||
|
|
||||
|
|
||||
|
END |
||||
|
echo -en "\a" > /dev/tty0 # beep (You must specify a tty path if not in console mode) |
||||
|
echo "Press Ctrl+C to cancel..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "3..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "2..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "1..." |
||||
|
sleep 1 |
||||
|
} |
||||
|
|
||||
|
install_git_mod_here(){ |
||||
|
git_url="$1" |
||||
|
mod_name="$2" |
||||
|
if [ -z "$git_url" ]; then |
||||
|
customDie "install_git_mod_here requires a URL." |
||||
|
fi |
||||
|
if [ -z "$mod_name" ]; then |
||||
|
customDie "install_git_mod_here requires a mod name as the second parameter." |
||||
|
fi |
||||
|
if [ ! -d "$mod_name" ]; then |
||||
|
git clone "$git_url" "$mod_name" |
||||
|
else |
||||
|
cd "$mod_name" || customDie "(install_git_mod_here) 'cd \"$mod_name\"' failed in '`pwd`'" |
||||
|
echo "* updating '`pwd`' from git..." |
||||
|
git pull || echo "WARNING: (install_git_mod_here) 'git pull' failed in '`pwd`'" |
||||
|
cd .. || customDie "(install_git_mod_here) 'cd ..' failed in '`pwd`'" |
||||
|
fi |
||||
|
} |
||||
|
enable_server=true |
||||
|
dest_programs="$HOME" |
||||
|
#NOTE: $HOME is still used further down, for $HOME/.* and $HOME/i_am_dedicated_minetest_server flag file (which can be empty) |
||||
|
#TODO: change $HOME/i_am_dedicated_minetest_server to $HOME/.config/EnlivenMinetest/i_am_dedicated_minetest_server or rc file |
||||
|
extracted_name=linux-minetest-kit |
||||
|
flag_dir_rel="$extracted_name/mtsrc" |
||||
|
flag_dir="`pwd`/$flag_dir_rel" |
||||
|
enable_client=false |
||||
|
custom_scripts_dir="$HOME" |
||||
|
custom_script_name="mts.sh" |
||||
|
if [ -f "$custom_scripts_dir/mts-CenterOfTheSun.sh" ]; then |
||||
|
custom_script_name="mts-CenterOfTheSun.sh" |
||||
|
fi |
||||
|
|
||||
|
scripting_rc_path=~/.config/EnlivenMinetest/scripting.rc |
||||
|
|
||||
|
if [ -f ~/.config/EnlivenMinetest/scripting.rc ]; then |
||||
|
echo "Running $scripting_rc_path..." |
||||
|
source $scripting_rc_path |
||||
|
# may contain any variables above, plus: |
||||
|
# * enable_run_after_compile: if true, then run the server, such as |
||||
|
# ~/mts-CenterOfTheSun.sh |
||||
|
else |
||||
|
echo "* skipping $scripting_rc_path (not present)" |
||||
|
echo " (can contain settings such as enable_run_after_compile)" |
||||
|
fi |
||||
|
|
||||
|
pushd "$extracted_name" |
||||
|
extracted_dir="`pwd`" |
||||
|
|
||||
|
|
||||
|
extra_options="" |
||||
|
for var in "$@" |
||||
|
do |
||||
|
if [ "@$var" = "@--client" ]; then |
||||
|
enable_client=true |
||||
|
elif [ "@$var" = "@--clean" ]; then |
||||
|
enable_clean=true |
||||
|
elif [ "@$var" = "@--noclean" ]; then |
||||
|
enable_clean=false |
||||
|
else |
||||
|
customDie "Invalid argument: $var" |
||||
|
fi |
||||
|
done |
||||
|
|
||||
|
if [ -z "$enable_clean" ]; then |
||||
|
enable_clean=true |
||||
|
fi |
||||
|
|
||||
|
echo "enable_clean=\"$enable_clean\"..." |
||||
|
|
||||
|
# flag_icon="$HOME/Desktop/org.minetest.minetest.desktop" |
||||
|
flag_client_dest_file="$dest_programs/minetest/bin/minetest" |
||||
|
flag_file="minetest/bin/minetestserver" |
||||
|
if [ -f "$flag_client_dest_file" ]; then |
||||
|
enable_client=true |
||||
|
echo "* automatically adding --client to compile since detected" |
||||
|
echo " '$flag_client_dest_file'" |
||||
|
# echo "--press Ctrl C to cancel..." |
||||
|
# sleep 2 |
||||
|
fi |
||||
|
if [ "@$enable_client" = "@true" ]; then |
||||
|
flag_file="minetest/bin/minetest" |
||||
|
extra_options="--client" |
||||
|
fi |
||||
|
#if [ -f "$flag_file" ]; then |
||||
|
#rm -f "$flag_file" |
||||
|
#fi |
||||
|
#if [ -f "$flag_file" ]; then |
||||
|
#echo "ERROR: Nothing done since can't remove old '$flag_file'" |
||||
|
#exit 1 |
||||
|
#fi |
||||
|
enable_compile=true |
||||
|
if [ -d minetest ]; then |
||||
|
enable_compile=false |
||||
|
if [ "@$enable_client" = "@true" ]; then |
||||
|
if [ ! -f minetest/bin/minetest ]; then |
||||
|
enable_compile=true |
||||
|
echo "* enabling compile (since no `pwd`/minetest/bin/minetest but client install is enabled)" |
||||
|
fi |
||||
|
fi |
||||
|
if [ "@$enable_server" = "@true" ]; then |
||||
|
if [ ! -f minetest/bin/minetestserver ]; then |
||||
|
enable_compile=true |
||||
|
echo "* enabling compile (since no `pwd`/minetest/bin/minetestserver)" |
||||
|
fi |
||||
|
fi |
||||
|
else |
||||
|
echo "* enabling compile since missing `pwd`/minetest directory" |
||||
|
fi |
||||
|
if [ "@$enable_compile" = "@true" ]; then |
||||
|
echo "* checking if the compile library script extracted the program source yet ($flag_dir)..." |
||||
|
if [ ! -d "$flag_dir" ]; then |
||||
|
cat <<END |
||||
|
ERROR: missing $flag_dir_rel |
||||
|
- If you do not have an extracted minetest source directory which |
||||
|
is normally extracted by the library build script, you must add |
||||
|
that--it can be automatically added by running: |
||||
|
|
||||
|
bash reset-minetest-install-source.sh |
||||
|
|
||||
|
|
||||
|
END |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
start=`date +%s` |
||||
|
if [ -f "mtcompile-program.pl" ]; then |
||||
|
# perl mtcompile-program.pl build >& program.log |
||||
|
echo "Compiling via perl (this may take a while--output redirected to `pwd`/program.log)..." |
||||
|
perl mtcompile-program.pl build --server $extra_options >& program.log |
||||
|
else |
||||
|
# NOTE: no pl in $extracted_name, assuming bash: |
||||
|
if [ -f mtcompile-program.sh ]; then |
||||
|
echo "Compiling via bash (this may take a while--output redirected to `pwd`/program.log)..." |
||||
|
bash -e mtcompile-program.sh build --server $extra_options >& program.log |
||||
|
else |
||||
|
echo |
||||
|
echo "ERROR: Install cannot finish since there is no" |
||||
|
echo " mtcompile-program.pl nor mtcompile-program.pl" |
||||
|
echo " in the extracted $extracted_name directory." |
||||
|
echo |
||||
|
echo |
||||
|
fi |
||||
|
fi |
||||
|
end=`date +%s` |
||||
|
compile_time=$((end-start)) |
||||
|
echo "Compiling the program finished in $compile_time seconds." |
||||
|
cp release.txt minetest/ || customWarn "Cannot copy `pwd`/release.txt to `pwd`/minetest/" |
||||
|
else |
||||
|
echo "* using existing minetest..." |
||||
|
fi |
||||
|
if [ ! -f "$flag_file" ]; then |
||||
|
customDie "The build did not complete since '$flag_file' is missing." |
||||
|
fi |
||||
|
dest_flag_file="$dest_programs/$flag_file" |
||||
|
if [ -f "$dest_flag_file" ]; then |
||||
|
mv -f "$dest_flag_file" "$dest_flag_file.bak" |
||||
|
fi |
||||
|
if [ -f "$dest_flag_file" ]; then |
||||
|
customDie "Install is incomplete because it can't move '$dest_flag_file'." |
||||
|
fi |
||||
|
if [ ! -d minetest ]; then |
||||
|
customDie "Install is incomplete because `pwd`/minetest is missing." |
||||
|
fi |
||||
|
virtual_dest="$dest_programs/minetest" |
||||
|
link_target=`readlink $virtual_dest` |
||||
|
# install_dest="/tank/local/owner/minetest" |
||||
|
install_dest="$virtual_dest" |
||||
|
dest_official_game="$dest_programs/minetest/games/Bucket_Game" |
||||
|
dest_enliven="$dest_programs/minetest/games/ENLIVEN" |
||||
|
skins_dst="$dest_enliven/mods/codercore/coderskins/textures" |
||||
|
skins_bak="$HOME/Backup/ENLIVEN/mods/codercore/coderskins/textures" |
||||
|
official_game_mod_list="coderbuild codercore coderedit coderfood codermobs decorpack mtmachines" |
||||
|
dest_enliven_mods="$dest_enliven/mods" |
||||
|
if [ "@$enable_clean" = "@true" ]; then |
||||
|
echo "* cleaning destination..." |
||||
|
if [ -d "$dest_official_game" ]; then |
||||
|
echo " - erasing '$dest_official_game'..." |
||||
|
rm -Rf "$dest_official_game" |
||||
|
fi |
||||
|
if [ -d "$dest_enliven" ]; then |
||||
|
if [ -d "$skins_dst" ]; then |
||||
|
echo " - Backing up '$skins_dst' to '$skins_bak'..." |
||||
|
if [ ! -d "$skins_bak" ]; then |
||||
|
mkdir -p "$skins_bak" || customDie "* cannot create $skins_bak" |
||||
|
fi |
||||
|
rsync -rt "$skins_dst/" "$skins_bak" |
||||
|
fi |
||||
|
for var in $official_game_mod_list |
||||
|
do |
||||
|
if [ -d "$dest_enliven_mods/$var" ]; then |
||||
|
echo " - erasing '$dest_enliven_mods/$var'..." |
||||
|
rm -Rf "$dest_enliven_mods/$var" || customDie "rm -Rf \"$dest_enliven_mods/$var\" failed" |
||||
|
# See rsync further down for installation of each of these |
||||
|
else |
||||
|
echo " - already clean: no '$dest_enliven_mods/$var'..." |
||||
|
fi |
||||
|
done |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
enliven_warning="" |
||||
|
if [ -d "$dest_enliven_mods" ]; then |
||||
|
pushd "$dest_enliven_mods" || customDie "'pushd \"$dest_enliven_mods\"' failed." |
||||
|
install_git_mod_here https://github.com/BenjieFiftysix/sponge.git sponge |
||||
|
install_git_mod_here https://github.com/poikilos/metatools.git metatools |
||||
|
install_git_mod_here https://github.com/MinetestForFun/fishing.git fishing |
||||
|
install_git_mod_here https://github.com/minetest-mods/throwing.git throwing |
||||
|
install_git_mod_here https://github.com/minetest-mods/ccompass.git ccompass |
||||
|
install_git_mod_here https://github.com/minetest-mods/throwing_arrows.git throwing_arrows |
||||
|
|
||||
|
popd || customDie "'popd' failed." |
||||
|
else |
||||
|
enliven_warning="$enliven_warning* WARNING: Installing ENLIVEN mods was skipped since '$dest_enliven_mods' does not exist." |
||||
|
fi |
||||
|
if [ ! -z "$link_target" ]; then |
||||
|
install_dest="$link_target" |
||||
|
echo "* detected that $virtual_dest is a symlink to $link_target" |
||||
|
echo " (redirecting rsync to prevent symlink to dir conversion: installing to $install_dest" |
||||
|
echo " and recreating symlink '$virtual_dest' pointing to '$install_dest')..." |
||||
|
rsync -rt "minetest/" "$install_dest" || customDie "Cannot rsync files from installer data `pwd`/minetest/ to $install_dest" |
||||
|
if [ ! -d "$dest_programs/minetest" ]; then |
||||
|
echo "* creating link to $install_dest directory as $dest_programs/minetest..." |
||||
|
ln -s "$install_dest" "$dest_programs/minetest" |
||||
|
fi |
||||
|
else |
||||
|
echo "Installing minetest directory to '$dest_programs'..." |
||||
|
rsync -rt --info=progress2 minetest/ $install_dest || customDie "Cannot rsync files from installer data `pwd`/minetest/ to $install_dest" |
||||
|
fi |
||||
|
if [ ! -f "$dest_flag_file" ]; then |
||||
|
customDie "ERROR: not complete--couldn't install binary as '$dest_flag_file'" |
||||
|
fi |
||||
|
|
||||
|
flag_dir="$dest_official_game" |
||||
|
if [ ! -d "$flag_dir" ]; then |
||||
|
customDie "ERROR: missing $flag_dir" |
||||
|
fi |
||||
|
if [ ! -d "$dest_programs/minetest/games/ENLIVEN" ]; then |
||||
|
echo "Copying $flag_dir to $dest_programs/minetest/games/ENLIVEN..." |
||||
|
cp -R "$flag_dir" "$dest_programs/minetest/games/ENLIVEN" |
||||
|
echo "name = ENLIVEN" > "$dest_programs/minetest/games/ENLIVEN/game.conf" |
||||
|
else |
||||
|
|
||||
|
for mod_name in $official_game_mod_list |
||||
|
do |
||||
|
echo " - updating $mod_name from '$flag_dir/mods/$mod_name' to '$dest_programs/minetest/games/ENLIVEN/mods'..." |
||||
|
rsync -rt --delete "$flag_dir/mods/$mod_name" "$dest_programs/minetest/games/ENLIVEN/mods" |
||||
|
done |
||||
|
# cp -f "$flag_dir/mods/LICENSE" "$dest_programs/minetest/games/ENLIVEN/mods/LICENSE" |
||||
|
if [ -d "$skins_bak" ]; then |
||||
|
echo " - restoring skins from '$skins_bak'..." |
||||
|
rsync -rt "$skins_bak/" "$skins_dst" |
||||
|
fi |
||||
|
fi |
||||
|
popd |
||||
|
|
||||
|
pushd .. |
||||
|
src="patches/subgame/menu" |
||||
|
dst="$dest_programs/minetest/games/ENLIVEN/menu" |
||||
|
echo "updating '$dst' from '$src/'..." |
||||
|
rsync -rt "$src/" "$dst" |
||||
|
|
||||
|
src="patches/Bucket_Game-patched" |
||||
|
dst="$dest_programs/minetest/games/ENLIVEN" |
||||
|
echo "updating '$dst' from '$src/'..." |
||||
|
rsync -rt "$src/" "$dst" |
||||
|
if [ -d "$dst/mods/coderfood/food_basic/etc" ]; then |
||||
|
rm -Rf "$dst/mods/coderfood/food_basic/etc" |
||||
|
fi |
||||
|
|
||||
|
minetest_conf_dest="$dest_programs/minetest/minetest.conf" |
||||
|
game_minetest_conf_dest="$dest_programs/minetest/games/ENLIVEN/minetest.conf" |
||||
|
|
||||
|
# Bucket_Game doesn't come with a minetest.conf, only minetest.conf.example* files |
||||
|
# if [ ! -f "$dest_programs/minetest/minetest.Bucket_Game-example.conf" ]; then |
||||
|
# cp -f "$$minetest_conf_dest" "$dest_programs/minetest/minetest.Bucket_Game-example.conf" |
||||
|
# fi |
||||
|
|
||||
|
client_example_dest="$dest_programs/minetest/minetest.ENLIVEN.client-example.conf" |
||||
|
|
||||
|
echo "Installing minetest.ENLIVEN.*-example.conf files..." |
||||
|
cp -f "patches/subgame/minetest.LAN-client-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.LAN-client-example.conf" || customDie "Cannot copy minetest.ENLIVEN.LAN-client-example.conf" |
||||
|
cp -f "patches/subgame/minetest.server-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.server-example.conf" || customDie "Cannot copy minetest.ENLIVEN.server-example.conf" |
||||
|
cp -f "patches/subgame/minetest.client-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.client-example.conf" || customDie "Cannot copy minetest.ENLIVEN.client-example.conf" |
||||
|
|
||||
|
echo "Writing '$game_minetest_conf_dest'..." |
||||
|
cp -f "patches/subgame/minetest.conf" "$game_minetest_conf_dest" |
||||
|
|
||||
|
# client conf writing only ever happens once, unless you manually delete $minetest_conf_dest: |
||||
|
if [ ! -f "$minetest_conf_dest" ]; then |
||||
|
# if [ -f "$minetest_conf_dest" ]; then |
||||
|
# echo "Backing up minetest.conf..." |
||||
|
# if [ ! -f "$minetest_conf_dest.1st" ]; then |
||||
|
# cp -f "$minetest_conf_dest" "$minetest_conf_dest.1st" |
||||
|
# else |
||||
|
# cp -f "$minetest_conf_dest" "$minetest_conf_dest.bak" |
||||
|
# fi |
||||
|
# fi |
||||
|
echo "Writing minetest.conf (client region)..." |
||||
|
cp -f "patches/subgame/minetest.client-example.conf" "$minetest_conf_dest" || customDie "Cannot copy minetest.client-example.conf to $minetest_conf_dest" |
||||
|
echo "Appending example settings (server region) to '$minetest_conf_dest'..." |
||||
|
cat "patches/subgame/minetest.server-example.conf" >> "$minetest_conf_dest" || customDie "Cannot append minetest.server-example.conf" |
||||
|
else |
||||
|
echo "$minetest_conf_dest exists (remove it if you want the installer to write an example version)" |
||||
|
fi |
||||
|
|
||||
|
|
||||
|
if [ -f "$minetest_conf_dest" ]; then |
||||
|
cat << END |
||||
|
NOTE: minetest.org releases allow you to put a world.conf file in your |
||||
|
world, so that is the file you should edit manually in your world |
||||
|
--this installer overwrites $minetest_conf_dest and |
||||
|
worlds/CenterOfTheSun settings (the author Poikilos' world). |
||||
|
Continue to place server settings such as announce in |
||||
|
$minetest_conf_dest. |
||||
|
Leave $game_minetest_conf_dest intact, as it defines the game. |
||||
|
If you have suggestions for changes or configurability, please use the |
||||
|
issue tracker at <https://github.com/poikilos/EnlivenMinetest>. |
||||
|
|
||||
|
END |
||||
|
fi |
||||
|
|
||||
|
|
||||
|
world_override_src="overrides/CenterOfTheSun/minetest/worlds/CenterOfTheSun" |
||||
|
world_override_dst="$HOME/.minetest/worlds/CenterOfTheSun" |
||||
|
world_override_dst="$HOME/.minetest/worlds/CenterOfTheSun" |
||||
|
try_world_override_dst="$HOME/minetest/worlds/CenterOfTheSun" |
||||
|
if [ -d "$try_world_override_dst" ]; then |
||||
|
world_override_dst="$try_world_override_dst" |
||||
|
fi |
||||
|
world_conf_src="$world_override_src/world.conf" |
||||
|
world_conf_dst="$world_override_dst/world.conf" |
||||
|
world_mt_src="$world_override_src/world.mt" |
||||
|
world_mt_dst="$world_override_dst/world.mt" |
||||
|
override_more="overrides/CenterOfTheSun/games/ENLIVEN" |
||||
|
appends="overrides/CenterOfTheSun/append" |
||||
|
minetest_conf_append="$appends/minetest.conf" |
||||
|
if [ -d "$world_override_dst" ]; then |
||||
|
echo "You have the CenterOfTheSun world. Listing any changes..." |
||||
|
if [ -f "$world_conf_src" ]; then |
||||
|
if [ -f "$world_conf_dst" ]; then |
||||
|
echo " * overwrite $world_conf_dst with $world_conf_src" |
||||
|
else |
||||
|
echo " * add the world.conf from $world_conf_src" |
||||
|
fi |
||||
|
cp -f "$world_conf_src" "$world_conf_dst" |
||||
|
fi |
||||
|
if [ -f "$minetest_conf_append" ]; then |
||||
|
cat "$minetest_conf_append" >> "$minetest_conf_dest" |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
|
||||
|
enable_clear_icon_cache=false |
||||
|
if [ "@$enable_client" = "@true" ]; then |
||||
|
dest_icons=$HOME/.local/share/applications |
||||
|
dest_icon=$dest_icons/org.minetest.minetest.desktop |
||||
|
# if [ -f "$dest_icon" ]; then |
||||
|
# comment since never fixes broken icon anyway |
||||
|
# TODO: fixed bad cache even if icon was rewritten properly after written improperly |
||||
|
# * not tried yet: |
||||
|
# * rm $HOME/.kde/share/config/kdeglobals |
||||
|
# enable_clear_icon_cache=true |
||||
|
# fi |
||||
|
echo "Writing icon '$dest_icon'..." |
||||
|
cat "patches/deploy-patched/misc/org.minetest.minetest.desktop" | grep -v Icon | grep -v Path | grep -v Exec > "$dest_icon" |
||||
|
# Icon must be an absolute path (other variables use $HOME in |
||||
|
# desktop file above), so exclude it above and rewrite it below: |
||||
|
echo "Icon=$dest_programs/minetest/misc/minetest-xorg-icon-128.png" >> "$dest_icon" |
||||
|
echo "Path=$dest_programs/minetest/bin" >> "$dest_icon" |
||||
|
echo "Exec=$dest_programs/minetest/bin/minetest" >> "$dest_icon" |
||||
|
if [ "@$enable_clear_icon_cache" = "@true" ]; then |
||||
|
if [ -f "`command -v gnome-shell`" ]; then |
||||
|
echo "Refreshing Gnome icons..." |
||||
|
gnome-shell --replace & disown |
||||
|
sleep 10 |
||||
|
fi |
||||
|
if [ -f "$HOME/.cache/icon-cache.kcache" ]; then |
||||
|
echo "clearing $HOME/.cache/icon-cache.kcache..." |
||||
|
rm $HOME/.cache/icon-cache.kcache |
||||
|
fi |
||||
|
if [ -f "`command -v kquitapp5`" ]; then |
||||
|
echo "Refreshing KDE icons..." |
||||
|
if [ "`command -v kstart5`" ]; then |
||||
|
kquitapp5 plasmashell && kstart5 plasmashell |
||||
|
else |
||||
|
kquitapp5 plasmashell && kstart plasmashell |
||||
|
fi |
||||
|
sleep 15 |
||||
|
fi |
||||
|
if [ -f "`command -v xfce4-panel`" ]; then |
||||
|
echo "Refreshing Xfce icons..." |
||||
|
xfce4-panel -r && xfwm4 --replace |
||||
|
sleep 5 |
||||
|
fi |
||||
|
if [ -f "`command -v lxpanelctl`" ]; then |
||||
|
echo "Refreshing LXDE icons..." |
||||
|
lxpanelctl restart && openbox --restart |
||||
|
sleep 5 |
||||
|
fi |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
if [ -f $dest_programs/minetest/games/ENLIVEN/mods/codermobs/codermobs/animal_materials.lua ]; then |
||||
|
if [ -d patches/mods-stopgap/animal_materials_legacy ]; then |
||||
|
echo "* installing animal_materials_legacy (only needed for worlds created with old versions of Bucket_Game)" |
||||
|
rsync -rt patches/mods-stopgap/animal_materials_legacy $dest_programs/minetest/games/ENLIVEN/mods/ |
||||
|
else |
||||
|
echo "* MISSING patches/mods-stopgap/animal_materials" |
||||
|
fi |
||||
|
else |
||||
|
echo "* SKIPPING a stopgap mod since no animal_materials" |
||||
|
fi |
||||
|
|
||||
|
if [ -f $dest_programs/minetest/games/ENLIVEN/mods/codermobs/codermobs/elk.lua ]; then |
||||
|
if [ -d patches/mods-stopgap/elk_legacy ]; then |
||||
|
echo "* installing elk_legacy (only needed for worlds created with old versions of Bucket_Game)" |
||||
|
rsync -rt patches/mods-stopgap/elk_legacy $dest_programs/minetest/games/ENLIVEN/mods/ |
||||
|
else |
||||
|
echo "* MISSING patches/mods-stopgap/elk_legacy" |
||||
|
fi |
||||
|
else |
||||
|
echo "* SKIPPING a stopgap mod since no elk.lua" |
||||
|
fi |
||||
|
|
||||
|
if [ -d "$dest_programs/minetest/games/ENLIVEN/mods/coderbuild/nftools" ]; then |
||||
|
if [ -d patches/mods-stopgap/nftools_legacy ]; then |
||||
|
echo "* installing nftools_legacy (only needed for worlds created with old versions of Bucket_Game)" |
||||
|
rsync -rt patches/mods-stopgap/nftools_legacy $dest_programs/minetest/games/ENLIVEN/mods/ |
||||
|
else |
||||
|
echo "* MISSING patches/mods-stopgap/nftools_legacy" |
||||
|
fi |
||||
|
else |
||||
|
echo "* SKIPPING a stopgap mod since no nftools" |
||||
|
fi |
||||
|
|
||||
|
popd |
||||
|
settings_dump="`pwd`/settings-dump.txt" |
||||
|
settings_types_list="`pwd`/settingtypes-list.txt" |
||||
|
# grep -r `pwd`/linux-minetest-kit/minetest/games/Bucket_Game -e "setting_get" > $settings_dump |
||||
|
pushd linux-minetest-kit/minetest/games |
||||
|
if [ ! -f "$settings_dump" ]; then |
||||
|
echo "Creating $settings_dump..." |
||||
|
grep -r Bucket_Game -e "setting_get" > $settings_dump |
||||
|
grep -r Bucket_Game -e "minetest.settings:get" >> $settings_dump |
||||
|
else |
||||
|
echo "* $settings_dump was already created" |
||||
|
fi |
||||
|
if [ ! -f "$settings_types_list" ]; then |
||||
|
echo "Creating $settings_types_list..." |
||||
|
find Bucket_Game -name "settingtypes.txt" > $settings_types_list |
||||
|
else |
||||
|
echo "* $settings_types_list was already created" |
||||
|
fi |
||||
|
popd |
||||
|
echo "* finished compiling." |
||||
|
if [ -f "$extracted_dir/release.txt" ]; then |
||||
|
versionLine=`cat $extracted_dir/release.txt` |
||||
|
echo " - version: $versionLine" |
||||
|
fi |
||||
|
if [ "@$enable_run_after_compile" = "@true" ]; then |
||||
|
echo "Trying to run minetest or other custom post-install script" |
||||
|
echo "(enable_run_after_compile is true in '$scripting_rc_path')." |
||||
|
if [ -d "$custom_scripts_dir" ]; then |
||||
|
pushd "$custom_scripts_dir" |
||||
|
if [ -f archive-minetestserver-debug.sh ]; then |
||||
|
./archive-minetestserver-debug.sh |
||||
|
echo "NOTE: if you put archive-minetestserver-debug.sh" |
||||
|
echo " in `pwd`, it would run at this point if" |
||||
|
echo " marked executable." |
||||
|
fi |
||||
|
if [ -f "$custom_script_name" ]; then |
||||
|
./$custom_script_name |
||||
|
echo "$custom_script_name finished (exit code $?)" |
||||
|
else |
||||
|
cat <<END |
||||
|
ERROR: enable_run_after_compile is true, but |
||||
|
'$custom_script_name' is not in |
||||
|
'$custom_scripts_dir'. |
||||
|
Try setting custom_scripts_dir and custom_script_name in |
||||
|
'$scripting_rc_path' |
||||
|
END |
||||
|
fi |
||||
|
popd |
||||
|
else |
||||
|
cat <<END |
||||
|
ERROR: enable_run_after_compile is true, but |
||||
|
'$custom_scripts_dir' |
||||
|
does not exist. Try setting custom_scripts_dir in |
||||
|
'$scripting_rc_path'. |
||||
|
END |
||||
|
fi |
||||
|
fi |
||||
|
echo "$enliven_warning" |
||||
|
echo |
||||
|
echo |
@ -0,0 +1,124 @@ |
|||||
|
#!/bin/bash |
||||
|
echo |
||||
|
echo |
||||
|
echo |
||||
|
echo "Starting cleanup and library rebuild..." |
||||
|
date |
||||
|
zip_name=linux-minetest-kit.zip |
||||
|
extracted_name=linux-minetest-kit |
||||
|
in_use_name=minetest |
||||
|
#not reliable with bash -e (if not running, check throws error): |
||||
|
#running=`ps ax | grep -v grep | grep $in_use_name | wc -l` |
||||
|
#if [ $running -gt 0 ]; then |
||||
|
# echo "killing minetest processes..." |
||||
|
# killall $in_use_name |
||||
|
#fi |
||||
|
url=https://downloads.minetest.org |
||||
|
release_txt_url=http://downloads.minetest.org/release.txt |
||||
|
customWarn() { |
||||
|
cat <<END |
||||
|
|
||||
|
WARNING: |
||||
|
$1 |
||||
|
|
||||
|
|
||||
|
END |
||||
|
echo -en "\a" > /dev/tty0 # beep (You must specify a tty path if not in console mode) |
||||
|
echo "Press Ctrl+C to cancel..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "3..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "2..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "1..." |
||||
|
sleep 1 |
||||
|
} |
||||
|
|
||||
|
customDie () { |
||||
|
echo "ERROR: Cannot continue since" |
||||
|
echo "$1" |
||||
|
exit 1 |
||||
|
} |
||||
|
available_release_line=`curl http://downloads.minetest.org/release.txt | head -n 1` |
||||
|
# echo "Release data: $available_release_line" # "Release *" where * is YYMMDD |
||||
|
# See <https://unix.stackexchange.com/questions/174037/extracting-the-second-word-from-a-string-variable> |
||||
|
available_version=$(echo $available_release_line | awk '{print $2}') |
||||
|
# OR: available_version="${available_release_line##* }" # get second word |
||||
|
if [ ${#available_version} -ne 6 ]; then |
||||
|
customDie "The available version is not recognized: $available_version" |
||||
|
fi |
||||
|
installed_release_line=`head -n 1 ~/minetest/release.txt` |
||||
|
installed_version=$(echo $installed_release_line | awk '{print $2}') |
||||
|
compiled_release_line=`head -n 1 ~/minetest/release.txt` |
||||
|
compiled_version=$(echo $compiled_release_line | awk '{print $2}') |
||||
|
echo "installed_version: $installed_version" |
||||
|
echo "compiled_version: $compiled_version" |
||||
|
echo "available_version: $available_version" |
||||
|
if [ "@$installed_version" = "@$available_version" ]; then |
||||
|
echo "You already have the latest version installed." |
||||
|
exit 1 |
||||
|
fi |
||||
|
if [ "@$compiled_version" -ne "@$installed_version" ]; then |
||||
|
echo "ERROR: You have not yet installed version $compiled_version which you already compiled (you have installed $installed_version)." |
||||
|
echo "You should run ./install-mts.sh instead (with --client option if you want more than minetestserver)" |
||||
|
exit 2 |
||||
|
fi |
||||
|
enable_offline=false |
||||
|
for var in "$@" |
||||
|
do |
||||
|
if [ "@$var" = "@--offline" ]; then |
||||
|
enable_offline=true |
||||
|
else |
||||
|
customDie "Invalid argument: $var" |
||||
|
fi |
||||
|
done |
||||
|
if [ -d "$extracted_name" ]; then |
||||
|
if [ "`ls -lR screenshots/*.png | wc -l`" -gt 0 ]; then |
||||
|
mv screenshots/*.png ~/ || customDie "can't move screenshots from $extracted_name/minetest/bin/*.png" |
||||
|
rmdir --ignore-fail-on-non-empty screenshots |
||||
|
fi |
||||
|
if [ "`ls -lR $extracted_name/minetest/bin/*.png | wc -l`" -gt 0 ]; then |
||||
|
# if [ ! -d screenshots ]; then mkdir screenshots; fi |
||||
|
# NOTE: system-wide install of minetest puts screenshots in ~/ (cwd) |
||||
|
mv $extracted_name/minetest/bin/*.png ~/ || customDie "can't move screenshots from $extracted_name/minetest/bin/*.png" |
||||
|
fi |
||||
|
rm -Rf "$extracted_name" || customDie "can't remove $extracted_name" |
||||
|
fi |
||||
|
|
||||
|
if [ "@$enable_offline" = "@true" ]; then |
||||
|
if [ ! -f "$zip_name" ]; then |
||||
|
customDie "* Offline install is impossible without '`pwd`/$zip_name'." |
||||
|
fi |
||||
|
else |
||||
|
wget -O $zip_name $url/$zip_name || customDie "no $zip_name at $url" |
||||
|
fi |
||||
|
unzip -u $zip_name || customDie "Can't unzip $zip_name" |
||||
|
cd "$extracted_name" |
||||
|
cat "$extracted_name/release.txt" |
||||
|
echo "compiling libraries..." |
||||
|
date |
||||
|
start=`date +%s` |
||||
|
bash -e mtcompile-libraries.sh build >& libraries.log |
||||
|
end=`date +%s` |
||||
|
compile_time=$((end-start)) |
||||
|
echo "Compiling libraries finished in $compile_time seconds." |
||||
|
echo " (see libraries.log in case of any errors)" |
||||
|
#echo "compiling program..." |
||||
|
#bash -e mtcompile-program.sh build >& program.log |
||||
|
echo "done." |
||||
|
echo |
||||
|
echo |
||||
|
echo |
||||
|
echo |
||||
|
echo |
||||
|
cd .. |
||||
|
echo "Check libraries.log for errors, then..." |
||||
|
echo "- Run the following manually for SERVER only (no graphical client):" |
||||
|
echo " bash install-mts.sh" |
||||
|
echo "- Run the following manually for both minetestserver and minetest:" |
||||
|
echo " bash install-mts.sh --client" |
||||
|
echo |
||||
|
echo |
@ -0,0 +1,164 @@ |
|||||
|
#!/bin/bash |
||||
|
echo |
||||
|
echo "Collecting version..." |
||||
|
if [ -z "$original_src_path" ]; then |
||||
|
original_src_path="$1" |
||||
|
fi |
||||
|
if [ -z "$original_src_path" ]; then |
||||
|
if [ -f "linux-minetest-kit.zip" ]; then |
||||
|
original_src_path="linux-minetest-kit.zip" |
||||
|
echo "* no script argument, so using linux-minetest-kit.zip" |
||||
|
else |
||||
|
echo "* original_src_path (linux-minetest-kit.zip) not detected" |
||||
|
fi |
||||
|
fi |
||||
|
if [ -z "$original_src_path" ]; then |
||||
|
echo "You must specify a zip file path OR directory path." |
||||
|
exit 1 |
||||
|
fi |
||||
|
customWarn() { |
||||
|
cat <<END |
||||
|
|
||||
|
WARNING: |
||||
|
$1 |
||||
|
|
||||
|
|
||||
|
END |
||||
|
echo -en "\a" > /dev/tty0 # beep (You must specify a tty path if not in console mode) |
||||
|
echo "Press Ctrl+C to cancel..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "3..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "2..." |
||||
|
sleep 1 |
||||
|
echo -en "\a" > /dev/tty0 |
||||
|
echo "1..." |
||||
|
sleep 1 |
||||
|
} |
||||
|
customDie() { |
||||
|
echo |
||||
|
echo "ERROR:" |
||||
|
echo " $1" |
||||
|
echo |
||||
|
echo |
||||
|
exit 1 |
||||
|
} |
||||
|
destroy_msg="" |
||||
|
# src_path: extracted name (always linux-mintetest-kit unless source is |
||||
|
# archive, in which case src_path is detected) |
||||
|
src_path="linux-minetest-kit" |
||||
|
versions_path="$HOME/git/EnlivenMinetest/webapp/minetest-versions" |
||||
|
if [ ! -d "$versions_path" ]; then |
||||
|
mkdir -p "$versions_path" || customDie "mkdir $versions_path FAILED" |
||||
|
fi |
||||
|
src_name="" |
||||
|
try_path="`pwd`/$original_src_path" |
||||
|
if [ -f "$original_src_path" ]; then |
||||
|
echo "* detected file param..." |
||||
|
elif [ -d "$original_src_path" ]; then |
||||
|
echo "* detected directory param..." |
||||
|
else |
||||
|
customDie "$original_src_path is not a file or directory." |
||||
|
fi |
||||
|
cd /tmp || customDie "cannot cd to /tmp" |
||||
|
if [ -d versionize ]; then |
||||
|
rm -Rf versionize || customDie "cannot remove /tmp/versionize" |
||||
|
fi |
||||
|
mkdir versionize || customDie "cannot create /tmp/versionize" |
||||
|
cd /tmp/versionize || customDie "cannot cd /tmp/versionize" |
||||
|
if [ -f "$original_src_path" ]; then |
||||
|
echo "* detected archive file full path..." |
||||
|
try_path="$original_src_path" |
||||
|
elif [ -d "$original_src_path" ]; then |
||||
|
echo "* detected directory full path..." |
||||
|
try_path="$original_src_path" |
||||
|
fi |
||||
|
|
||||
|
src_archive= |
||||
|
if [ -f "$try_path" ]; then |
||||
|
src_archive="$try_path" |
||||
|
echo "* set src_archive to '$try_path'" |
||||
|
unzip "$try_path" |
||||
|
src_name="`ls`" |
||||
|
if [ ! -d "$src_name" ]; then |
||||
|
customDie "unzip $try_path did not result in a directory!" |
||||
|
fi |
||||
|
src_path="`pwd`/$src_name" |
||||
|
destroy_msg=" (but will be destroyed on next run)" |
||||
|
if [ ! -d "$src_path" ]; then |
||||
|
customDie "$src_path from unzip $try_path is not a directory!" |
||||
|
fi |
||||
|
elif [ -d "$try_path" ]; then |
||||
|
src_path="$try_path" |
||||
|
src_name="`basename $src_path`" |
||||
|
else |
||||
|
customDie "$try_path is not a file or directory." |
||||
|
fi |
||||
|
release_txt_path="$src_path/minetest/release.txt" |
||||
|
if [ ! -f "$release_txt_path" ]; then |
||||
|
try_release_txt_path="$src_path/release.txt" |
||||
|
if [ ! -f "$try_release_txt_path" ]; then |
||||
|
echo |
||||
|
echo |
||||
|
echo "* '$src_path' remains$destroy_msg." |
||||
|
customDie "Missing $release_txt_path (or $src_path/release.txt)" |
||||
|
else |
||||
|
echo "Missing $release_txt_path (usually copied from $try_release_txt_path by EnlivenMinetest compille script(s)); reverting to $try_release_txt_path" |
||||
|
release_txt_path="$try_release_txt_path" |
||||
|
fi |
||||
|
fi |
||||
|
release_line="`head -n 1 $release_txt_path`" |
||||
|
version="${release_line##* }" # get second word |
||||
|
version_len=${#version} |
||||
|
if [ "$version_len" -ne "6" ]; then |
||||
|
customDie "Unexpected version scheme (not 6 characters): '$version' near '$release_line' in file $release_txt_path" |
||||
|
fi |
||||
|
echo "src_name=$src_name" |
||||
|
echo "src_path=$src_path" |
||||
|
echo "version=$version" |
||||
|
# dest_path="$versions_path/$src_name-$version" |
||||
|
dest_path="$versions_path/linux-minetest-kit-$version" |
||||
|
echo "dest_path=$dest_path" |
||||
|
|
||||
|
if [ ! -z "$src_archive" ]; then |
||||
|
echo "* Collecting src_archive '$src_archive'" |
||||
|
# The effectiveness of any bash extension extraction is debatable-- |
||||
|
# see |
||||
|
# <https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash> |
||||
|
filename=$(basename -- "$src_archive") |
||||
|
extension="${filename##*.}" |
||||
|
filename="${filename%.*}" |
||||
|
dst_archive="$versions_path/$filename-$version.$extension" |
||||
|
if [ -f "$dst_archive" ]; then |
||||
|
customWarn "This will overwrite '$dst_archive' with '$src_archive'." |
||||
|
fi |
||||
|
if [ -f "$src_archive" ]; then |
||||
|
mv "$src_archive" "$dst_archive" || customDie "Cannot mv '$src_archive' '$dst_archive'" |
||||
|
echo "* moved archive to '$dst_archive'" |
||||
|
echo |
||||
|
echo |
||||
|
else |
||||
|
echo "* ERROR: '$src_archive' is not accessible from `pwd`--" |
||||
|
echo " skipping:" |
||||
|
echo " mv '$src_archive' '$dst_archive'" |
||||
|
echo |
||||
|
echo |
||||
|
fi |
||||
|
else |
||||
|
echo "* There is no src_archive to collect." |
||||
|
fi |
||||
|
if [ -d "$dest_path" ]; then |
||||
|
echo |
||||
|
echo "There is nothing to do. Directory $dest_path exists." |
||||
|
echo "* '$src_path' remains$destroy_msg." |
||||
|
echo |
||||
|
echo |
||||
|
exit 0 |
||||
|
fi |
||||
|
mv "$src_path" "$dest_path" || customDie "Failed to move to 'dest_path'" |
||||
|
echo |
||||
|
echo "Done $0." |
||||
|
echo |
||||
|
echo |
Loading…
Reference in new issue