Browse Source

only stop install on missing source IF not compiled already

master
poikilos 6 years ago
committed by Jacob Gustafson
parent
commit
bed7d73ee8
  1. 111
      webapp/install-mts.sh

111
webapp/install-mts.sh

@ -5,36 +5,37 @@ echo
echo echo
echo "Starting install..." echo "Starting install..."
date date
echo "Checking if program is compiled..." customDie() {
extracted_name=linux-minetest-kit cat <<END
flag_dir="$extracted_name/mtsrc"
if [ ! -d "$flag_dir" ]; then ERROR:
echo "ERROR: missing $flag_dir" $@
echo "- If you do not have a minetest source directory with"
echo " libraries built yet, you must add that such as by running:"
echo END
echo "bash reset-minetest-install-source.sh"
echo
echo
exit 1 exit 1
fi }
extracted_name=linux-minetest-kit
flag_dir_rel="$extracted_name/mtsrc"
flag_dir="`pwd`/$flag_dir_rel"
pushd "$extracted_name" pushd "$extracted_name"
enable_client=false enable_client=false
extra_options="" extra_options=""
if [ "@$1" = "@--client" ]; then if [ "@$1" = "@--client" ]; then
extra_options="--client"
enable_client=true enable_client=true
fi fi
flag_icon="$HOME/Desktop/org.minetest.minetest.desktop" flag_icon="$HOME/Desktop/org.minetest.minetest.desktop"
flag_file="minetest/bin/minetestserver" flag_file="minetest/bin/minetestserver"
if [ -f "$flag_icon" ]; then if [ -f "$flag_icon" ]; then
extra_options="--client"
enable_client=true enable_client=true
echo "automatically adding --client to compile since detected" echo "* automatically adding --client to compile since detected"
echo " '$flag_icon'" echo " '$flag_icon'"
# echo "--press Ctrl C to cancel..." # echo "--press Ctrl C to cancel..."
# sleep 2 # sleep 2
fi
if [ "@$enable_client" = "@true" ]; then
flag_file="minetest/bin/minetest" flag_file="minetest/bin/minetest"
extra_options="--client"
fi fi
#if [ -f "$flag_file" ]; then #if [ -f "$flag_file" ]; then
#rm -f "$flag_file" #rm -f "$flag_file"
@ -49,57 +50,87 @@ if [ -d minetest ]; then
if [ "@$enable_client" = "@true" ]; then if [ "@$enable_client" = "@true" ]; then
if [ ! -f minetest/bin/minetest ]; then if [ ! -f minetest/bin/minetest ]; then
enable_compile=true enable_compile=true
echo "Recompiling since client was not built before..." echo "* enabling compile (since no `pwd`/minetest/bin/minetest but client install is enabled)"
fi fi
fi fi
else
echo "* enabling compile since missing `pwd`/minetest directory"
fi fi
if [ "@$enable_compile" = "@true" ]; then 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` start=`date +%s`
if [ -f "mtcompile-program.pl" ]; then if [ -f "mtcompile-program.pl" ]; then
# perl mtcompile-program.pl build >& program.log # perl mtcompile-program.pl build >& program.log
echo "Compiling via perl..." 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 perl mtcompile-program.pl build --server $extra_options >& program.log
else else
# NOTE: no pl in $extracted_name, assuming bash: # NOTE: no pl in $extracted_name, assuming bash:
echo "Compiling via 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 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 fi
end=`date +%s` end=`date +%s`
compile_time=$((end-start)) compile_time=$((end-start))
echo "Compiling program finished in $compile_time seconds." echo "Compiling the program finished in $compile_time seconds."
else else
echo "using existing minetest..." echo "* using existing minetest..."
fi fi
if [ ! -f "$flag_file" ]; then if [ ! -f "$flag_file" ]; then
echo "ERROR: Build did not complete--missing '$flag_file'" customDie "The build did not complete since '$flag_file' is missing."
exit 1
fi fi
dest_flag_file="$HOME/$flag_file" dest_flag_file="$HOME/$flag_file"
if [ -f "$dest_flag_file" ]; then if [ -f "$dest_flag_file" ]; then
mv -f "$dest_flag_file" "$dest_flag_file.bak" mv -f "$dest_flag_file" "$dest_flag_file.bak"
fi fi
if [ -f "$dest_flag_file" ]; then if [ -f "$dest_flag_file" ]; then
echo "ERROR: not complete since can't move old '$dest_flag_file'" customDie "Install is incomplete because it can't move '$dest_flag_file'."
exit 1
fi fi
if [ ! -d minetest ]; then if [ ! -d minetest ]; then
echo "ERROR: can't install since missing `pwd`/minetest" customDie "Install is incomplete because `pwd`/minetest is missing."
exit 1 fi
fi virtual_dest="$HOME/minetest"
try_dest="/tank/local/owner/minetest" link_target=`readlink $virtual_dest`
if [ -d "$try_dest" ]; then # install_dest="/tank/local/owner/minetest"
echo "Installing minetest as symlink '$HOME/minetest' pointing to '$try_dest'..." install_dest="$virtual_dest"
rsync -rt minetest/ $try_dest 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 "$HOME/minetest" ]; then if [ ! -d "$HOME/minetest" ]; then
ln -s $try_dest $HOME/minetest echo "* creating link to $install_dest directory as $HOME/minetest..."
#ln -s "$install_dest" "$HOME/minetest"
fi fi
else else
echo "Installing minetest to '$HOME'..." echo "Installing minetest to '$HOME'..."
rsync -rt minetest/ $HOME/minetest #rsync -rt minetest/ $install_dest || customDie "Cannot rsync files from installer data `pwd`/minetest/ to $install_dest"
fi
if [ ! -f "$dest_flag_file" ]; then if [ ! -f "$dest_flag_file" ]; then
echo "ERROR: not complete--couldn't create '$dest_flag_file'" echo "ERROR: not complete--couldn't create '$dest_flag_file'"
exit 1 #exit 1
fi
fi fi
flag_dir="$HOME/minetest/games/Bucket_Game" flag_dir="$HOME/minetest/games/Bucket_Game"
@ -175,9 +206,13 @@ fi
server_minetest_conf_dest="$HOME/minetest/games/ENLIVEN/minetest.conf" server_minetest_conf_dest="$HOME/minetest/games/ENLIVEN/minetest.conf"
if [ -f "$server_minetest_conf_dest" ]; then if [ -f "$server_minetest_conf_dest" ]; then
echo cat << END
echo "NOTE: $server_minetest_conf_dest will be overwritten (minetest.org releases allow you to put a world.conf file in your world, so that should be customized instead)..." NOTE: minetest.org releases allow you to put a world.conf file in your
echo world, so that is the file you should edit manually in your world
--this installer overwrites $server_minetest_conf_dest and
worlds/CenterOfTheSun settings (the author Poikilos' world).
END
fi fi
echo "Writing '$server_minetest_conf_dest'..." echo "Writing '$server_minetest_conf_dest'..."
cp -f "patches/subgame/minetest.server-example.conf" "$server_minetest_conf_dest" cp -f "patches/subgame/minetest.server-example.conf" "$server_minetest_conf_dest"

Loading…
Cancel
Save