From 6d0d12a179c5bf69e0344371abd4e5b8157f5428 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Sun, 29 Mar 2020 21:08:03 -0400 Subject: [PATCH] Do not depend on pwd. Add more config--see Changelog. --- changelog.md | 15 ++- install-mts.sh | 160 ++++++++++++++++++------------- readme.md | 51 ++++++++++ reset-minetest-install-source.sh | 23 +++-- versionize.sh | 10 +- 5 files changed, 176 insertions(+), 83 deletions(-) diff --git a/changelog.md b/changelog.md index 21f09e5..aadb4c7 100644 --- a/changelog.md +++ b/changelog.md @@ -5,7 +5,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [git] - 2020-03-11 +## [git] - 2020-03-29 +### Added +- Add "Linux Server Install or Upgrade" section to + [readme.md](readme.md). + +### Fixed +- Fix counting of screenshots (`*` doesn't work in quotes) + +### Changed +- Do not depend on pwd. +- Use more variables from scripting.rc if they are present. + + +## [git] - 2020-03-29 ### Changed - Use $HOME/.config/EnlivenMinetest to store downloads. diff --git a/install-mts.sh b/install-mts.sh index 108ca99..7cd8285 100755 --- a/install-mts.sh +++ b/install-mts.sh @@ -5,7 +5,7 @@ echo echo echo "Starting install..." MY_NAME="install-mts.sh" -config_path="$HOME/.config/EnlivenMinetest" +EM_CONFIG_PATH="$HOME/.config/EnlivenMinetest" date customDie() { @@ -63,28 +63,48 @@ 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" -extracted_path="$config_path/$extracted_name" -cd "$config_path" || customDie "[$MY_NAME] cd \"$config_path\" failed." +extracted_path="$EM_CONFIG_PATH/$extracted_name" +cd "$EM_CONFIG_PATH" || customDie "[$MY_NAME] cd \"$EM_CONFIG_PATH\" failed." flag_dir_rel="$extracted_name/mtsrc" flag_dir="$extracted_path/mtsrc" -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" +if [ -z "$CUSTOM_SCRIPTS_PATH" ]; then + CUSTOM_SCRIPTS_PATH="$HOME" fi - +MT_POST_INSTALL_SCRIPT_1=archive-minetestserver-debug.sh scripting_rc_path=~/.config/EnlivenMinetest/scripting.rc +if [ -z "$MT_POST_INSTALL_SCRIPT_2" ]; then + MT_POST_INSTALL_SCRIPT_2="mts.sh" + if [ -f "$CUSTOM_SCRIPTS_PATH/mts-CenterOfTheSun.sh" ]; then + MT_POST_INSTALL_SCRIPT_2="mts-CenterOfTheSun.sh" + else + if [ ! -f $CUSTOM_SCRIPTS_PATH/$MT_POST_INSTALL_SCRIPT_2 ]; then + cat <& program.log echo "Compiling via perl (this may take a while--output redirected to `pwd`/program.log)..." @@ -197,7 +219,7 @@ END echo "Compiling the program finished in $compile_time seconds." cp $extracted_path/release.txt $extracted_path/minetest/ || customWarn "Cannot copy $extracted_path/release.txt to $extracted_path/minetest/" else - echo "* using existing minetest..." + echo "* using existing $extracted_path/minetest..." fi if [ ! -f "$flag_file" ]; then customDie "The build did not complete since '$flag_file' is missing. Maybe you didn't compile the libraries. Running reset-minetest-install-source.sh should do that automatically, but you can also do: cd $extracted_path && ./mtcompile-libraries.sh build" @@ -209,8 +231,8 @@ 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." +if [ ! -d "$extracted_path/minetest" ]; then + customDie "Install is incomplete because \"$extracted_path/minetest\" is missing." fi virtual_dest="$dest_programs/minetest" link_target=`readlink $virtual_dest` @@ -268,14 +290,14 @@ if [ ! -z "$link_target" ]; then 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" + rsync -rt "$extracted_path/minetest/" "$install_dest" || customDie "Cannot rsync files from installer data $extracted_path/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" + echo "Installing \"$extracted_path/minetest\" directory to \"$dest_programs\"..." + rsync -rt --info=progress2 $extracted_path/minetest/ $install_dest || customDie "Cannot rsync files from installer data $extracted_path/minetest/ to $install_dest" fi if [ ! -f "$dest_flag_file" ]; then customDie "ERROR: not complete--couldn't install binary as '$dest_flag_file'" @@ -305,20 +327,20 @@ fi popd # pushd .. # go from EnlivenMinetest/webapp to EnlivenMinetest -PATCHES_DIR="patches" +# PATCHES_DIR_NAME="patches" if [ -z "$REPO_PATH" ]; then REPO_PATH="$HOME/git/EnlivenMinetest" fi PATCHES_PATH="$REPO_PATH/patches" if [ -d "$PATCHES_PATH" ]; then - pushd "$REPO_PATH" + # pushd "$REPO_PATH" -src="patches/subgame/menu" +src="$PATCHES_PATH/subgame/menu" dst="$dest_programs/minetest/games/ENLIVEN/menu" echo "updating '$dst' from '$src/'..." rsync -rt "$src/" "$dst" -src="patches/Bucket_Game-patched" +src="$PATCHES_PATH/Bucket_Game-patched" dst="$dest_programs/minetest/games/ENLIVEN" echo "updating '$dst' from '$src/'..." rsync -rt "$src/" "$dst" @@ -337,12 +359,12 @@ game_minetest_conf_dest="$dest_programs/minetest/games/ENLIVEN/minetest.conf" 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" +cp -f "$PATCHES_PATH/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_PATH/subgame/minetest.server-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.server-example.conf" || customDie "Cannot copy minetest.ENLIVEN.server-example.conf" +cp -f "$PATCHES_PATH/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" +cp -f "$PATCHES_PATH/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 @@ -355,9 +377,9 @@ if [ ! -f "$minetest_conf_dest" ]; then # 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" + cp -f "$PATCHES_PATH/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" + cat "$PATCHES_PATH/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 @@ -410,7 +432,7 @@ fi enable_clear_icon_cache=false -if [ "@$enable_client" = "@true" ]; then +if [ "@$ENABLE_CLIENT" = "@true" ]; then dest_icons=$HOME/.local/share/applications dest_icon=$dest_icons/org.minetest.minetest.desktop # if [ -f "$dest_icon" ]; then @@ -421,7 +443,7 @@ if [ "@$enable_client" = "@true" ]; then # 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" + cat "$PATCHES_PATH/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" @@ -460,45 +482,45 @@ if [ "@$enable_client" = "@true" ]; then fi if [ -f $dest_programs/minetest/games/ENLIVEN/mods/codermobs/codermobs/animal_materials.lua ]; then - if [ -d patches/mods-stopgap/animal_materials_legacy ]; then + if [ -d $PATCHES_PATH/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/ + rsync -rt $PATCHES_PATH/mods-stopgap/animal_materials_legacy $dest_programs/minetest/games/ENLIVEN/mods/ else - echo "* MISSING patches/mods-stopgap/animal_materials" + echo "* MISSING $PATCHES_PATH/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 + if [ -d $PATCHES_PATH/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/ + rsync -rt $PATCHES_PATH/mods-stopgap/elk_legacy $dest_programs/minetest/games/ENLIVEN/mods/ else - echo "* MISSING patches/mods-stopgap/elk_legacy" + echo "* MISSING $PATCHES_PATH/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 + if [ -d $PATCHES_PATH/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/ + rsync -rt $PATCHES_PATH/mods-stopgap/nftools_legacy $dest_programs/minetest/games/ENLIVEN/mods/ else - echo "* MISSING patches/mods-stopgap/nftools_legacy" + echo "* MISSING $PATCHES_PATH/mods-stopgap/nftools_legacy" fi else echo "* SKIPPING a stopgap mod since no nftools" fi -popd +# popd else cat < (also part of Bucket_Game) @@ -95,6 +97,55 @@ bash install-mts.sh --client contact the maintainer of your window manager. This works in KDE on Fedora 29. Workaround: copy the icon from there to your desktop.) + +## Linux Server Install or Upgrade +``` +cd ~/git/EnlivenMinetest +./reset-minetest-install-source.sh && ./versionize && ./install-mts.sh +# You can leave out `&& ./versionize` if you don't want to keep old +# copies. +``` + +### Using install-mts.sh +You must first run reset-minetest-install-source.sh to compile the +libraries automatically, or otherwise have run the compile libraries +script in `~/.config/EnlivenMinetest/linux-minetest-kit`, or at least +have already compiled Minetest there. If the minetest or +minetestserver binary (or just minetestserver if client is not enabled) +is not present there (in +`~/.config/EnlivenMinetest/linux-minetest-kit/minetest/bin/`), the +script will try to compile the program before installing or stop if it +cannot. + +#### Arguments +- `--clean` is the recommended option, and is the default. It + erases Bucket_Game and causes ENLIVEN to be remade using Bucket_Game. + - It backs up skins, but that is not necessary anymore since + coderskins uses world storage (follow this issue at + ). +- `--client` installs the client too. Since "install-mts.sh" stands for + "Install minetestserver," the `--client` option is off by default + (See the "Configuration Files" section for how to change the default). + +#### Configuration Files +You can place zero or more of the following variables in +$HOME/.config/EnlivenMinetest/scripting.rc: +``` +CUSTOM_SCRIPTS_PATH +MT_POST_INSTALL_SCRIPT_2 # relative to CUSTOM_SCRIPTS_PATH +REPO_PATH # Set this if your copy of the repo is not ~/git/EnlivenMinetest +ENABLE_CLIENT # =true if you want install-mts.sh to install the client. +``` +- If ~/minetest/bin/minetest is present, that has the same effect as + `ENABLE_CLIENT=true`. + +You can place a script called mts.sh in your home (or +CUSTOM_SCRIPTS_PATH) directory to run it after install (you can put +archive-minetestserver-debug.sh there too to run first). A suggested use +is to put a line in mts.sh that starts the server, so that the server +starts after the installation or upgrade is complete. + + ## How to use ### Windows Client diff --git a/reset-minetest-install-source.sh b/reset-minetest-install-source.sh index 2309b5e..381b49e 100755 --- a/reset-minetest-install-source.sh +++ b/reset-minetest-install-source.sh @@ -5,13 +5,14 @@ echo echo "Starting cleanup and library rebuild..." date MY_NAME="reset-minetest-install-source.sh" -config_path=$HOME/.config/EnlivenMinetest +EM_CONFIG_PATH=$HOME/.config/EnlivenMinetest zip_name=linux-minetest-kit.zip extracted_name=linux-minetest-kit -config_path=~/.config/EnlivenMinetest -if [ ! -d "$config_path" ]; then - mkdir -p "$config_path" +EM_CONFIG_PATH=~/.config/EnlivenMinetest +extracted_path="$EM_CONFIG_PATH/$extracted_name" +if [ ! -d "$EM_CONFIG_PATH" ]; then + mkdir -p "$EM_CONFIG_PATH" fi in_use_name=minetest @@ -83,10 +84,16 @@ do customDie "Invalid argument: $var" fi done -cd "$config_path" || customDie "[$MY_NAME] cd \"$config_path\" failed." -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" +cd "$EM_CONFIG_PATH" || customDie "[$MY_NAME] cd \"$EM_CONFIG_PATH\" failed." +if [ -d "$extracted_path" ]; then + + # NOTE: ls -lR $extracted_path/screenshots/ + screenshot_count=0 + if [ -d $extracted_path/screenshots/ ]; then + screenshot_count="`ls $extracted_path/screenshots/ | wc -l`" + fi + if [ $screenshot_count -gt 0 ]; then + mv $extracted_path/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 diff --git a/versionize.sh b/versionize.sh index daaf191..14e5936 100755 --- a/versionize.sh +++ b/versionize.sh @@ -2,8 +2,8 @@ echo echo "Collecting version..." MY_NAME="versionize.sh" -config_path=$HOME/.config/EnlivenMinetest -cd "$config_path" || customDie "[$MY_NAME] cd \"$config_path\" failed." +EM_CONFIG_PATH=$HOME/.config/EnlivenMinetest +cd "$EM_CONFIG_PATH" || customDie "[$MY_NAME] cd \"$EM_CONFIG_PATH\" failed." if [ -z "$original_src_path" ]; then original_src_path="$1" fi @@ -51,13 +51,13 @@ customDie() { destroy_msg="" # src_path: extracted name (always linux-mintetest-kit unless source is # archive, in which case src_path is detected) -src_path="$config_path/linux-minetest-kit" -versions_path="$config_path/minetest-versions" +src_path="$EM_CONFIG_PATH/linux-minetest-kit" +versions_path="$EM_CONFIG_PATH/minetest-versions" if [ ! -d "$versions_path" ]; then mkdir -p "$versions_path" || customDie "mkdir $versions_path FAILED" fi src_name="" -try_path="$config_path/$original_src_path" +try_path="$EM_CONFIG_PATH/$original_src_path" if [ -f "$original_src_path" ]; then echo "* detected file param..." elif [ -d "$original_src_path" ]; then