2021-03-25 14:57:30 -07:00
#!/bin/bash
2019-02-06 09:20:15 -08:00
echo
zs_dest = /opt/zbstudio
if [ " $1 " = = "uninstall" ] ; then
bad_file = " $zs_dest /zbstudio/interpreters/minetest.lua "
dest_file = " $zs_dest /interpreters/minetest.lua "
if [ -f " $bad_file " ] ; then
echo " WARNING: found incorrectly installed file $bad_file , so removing... "
sudo rm -f " $bad_file "
sudo rmdir " $zs_dest /zbstudio/interpreters "
if [ -f " $bad_file " ] ; then
echo " ERROR: Failed to remove $bad_file "
end_msg = "Uninstall FAILED."
end_ret = 1
fi
fi
if [ -f " $dest_file " ] ; then
sudo rm -f " $dest_file "
sudo rmdir " $zs_dest /interpreters "
fi
end_msg = "Uninstalled successfully"
end_ret = 0
if [ -f " $dest_file " ] ; then
echo " ERROR: could not remove $dest_file "
echo
echo
end_ret = 1
end_msg = "Uninstall FAILED."
fi
2021-03-25 14:57:30 -07:00
2019-02-06 09:20:15 -08:00
bad_file = " $zs_dest /zbstudio/api/lua/minetest.lua "
dest_file = " $zs_dest /api/lua/minetest.lua "
if [ -f " $bad_file " ] ; then
echo " WARNING: found incorrectly installed file $bad_file , so removing... "
sudo rm -f " $bad_file "
sudo rmdir " $zs_dest /api/lua "
sudo rmdir " $zs_dest /api "
if [ -f " $bad_file " ] ; then
echo " ERROR: Failed to remove $bad_file "
end_msg = "Uninstall FAILED."
end_ret = 1
fi
fi
if [ -f " $dest_file " ] ; then
sudo rm -f " $dest_file "
sudo rmdir " $zs_dest /zbstudio/api/lua "
sudo rmdir " $zs_dest /zbstudio/api "
fi
if [ -f " $dest_file " ] ; then
echo " ERROR: could not remove $dest_file "
echo
echo
end_msg = "Uninstall FAILED."
end_ret = 1
fi
echo " $end_msg "
echo
echo
exit $end_ret
fi
2021-03-28 01:47:00 -07:00
printf "* checking installer..."
good_src_flag = "zbstudio/interpreters/minetest.lua"
#if [ ! -d zbstudio ]; then
# cd "${0%/*}"
# if [ -f "$good_src_flag" ]; then
# echo "WARNING: had to change directory to `pwd` since zbstudio patch directory was not found..."
# fi
#fi
if [ ! -f " $good_src_flag " ] ; then
echo " ERROR: Nothing done since missing zbstudio patch--you must run this installer from the MinetestIDE directory containing \" $good_src_flag \". "
2019-02-06 09:20:15 -08:00
echo
echo
exit 1
fi
2021-03-28 01:47:00 -07:00
echo " OK (found \" $good_src_flag \" in \"`pwd`\") "
2019-02-06 09:20:15 -08:00
mi_path = "`pwd`"
end_msg = ""
if [ ! -d " $zs_dest " ] ; then
2021-03-28 01:47:00 -07:00
echo " * installing zbstudio to $zs_dest ... "
if [ ! -d " $HOME /Downloads " ] ; then
mkdir -p " $HOME /Downloads "
if [ $? -ne 0 ] ; then
echo " Error: 'mkdir -p \" $HOME /Downloads\"' failed "
exit 1
fi
fi
2019-02-06 09:20:15 -08:00
cd " $HOME /Downloads "
dl_name = ZeroBraneStudioEduPack-1.80-linux.sh
2021-03-28 01:47:00 -07:00
URL = https://download.zerobrane.com/$dl_name
2019-02-06 09:20:15 -08:00
if [ ! -f " $dl_name " ] ; then
2021-03-28 01:47:00 -07:00
if [ ! -f "`command -v wget`" ] ; then
echo " Error: This script requires wget unless \" $dl_name \" is in \"`pwd`\". "
exit 1
fi
echo " * downloading $URL ... "
wget -O $dl_name $URL
if [ $? -ne 0 ] ; then
echo " Error: 'wget -O $dl_name $URL ' failed in \"`pwd`\" "
exit 1
fi
echo " * running ' $dl_name ' in \"`pwd`\"... "
2019-02-06 09:20:15 -08:00
sh $dl_name
2021-03-28 01:47:00 -07:00
if [ $? -ne 0 ] ; then
echo " Error: 'sh $dl_name ' failed in \"`pwd`\" "
exit 1
fi
2019-02-06 09:20:15 -08:00
if [ ! -d " $zs_dest " ] ; then
echo " ERROR: MinetestIDE not installed since failed to install $zs_dest "
echo
echo
exit 2
fi
end_msg = "If you paid for ZeroBrane Studio, thank you for your contribution. If you have not, please consider supporting the project <https://studio.zerobrane.com/support>."
fi
2021-03-28 01:47:00 -07:00
else
echo " * detected $zs_dest "
2019-02-06 09:20:15 -08:00
fi
if [ ! -d " $zs_dest " ] ; then
echo " ERROR: nothing done since missing $zs_dest . "
2021-03-25 14:57:30 -07:00
echo "You first must install ZeroBrane studio (See readme)."
2019-02-06 09:20:15 -08:00
exit 3
fi
cd " $mi_path "
2021-03-28 01:47:00 -07:00
if [ $? -ne 0 ] ; then
echo " Error: 'cd \" $mi_path \"' failed in \"`pwd`\" "
exit 1
fi
2019-02-06 09:20:15 -08:00
if [ ! -f "`command -v rsync`" ] ; then
#echo "ERROR: Nothing done since rsync is required."
#exit 5
echo "WARNING: no rsync, so trying cp -R..."
api_lua_dest = " $zs_dest /api/lua "
interpreters_dest = " $zs_dest /interpreters "
# if [ ! -d "$api_lua_dest" ]; then sudo mkdir -p "$api_lua_dest"; fi
# if [ ! -d "$interpreters_dest" ]; then sudo mkdir -p "$interpreters_dest"; fi
sudo cp -R zbstudio/* " $zs_dest "
if [ ! -f " $api_lua_dest /minetest.lua " ] ; then
echo " ERROR: failed to install $api_lua_dest /minetest.lua "
find " $zs_dest " -iname minetest.lua
exit 4
fi
if [ ! -f " $interpreters_dest /minetest.lua " ] ; then
echo " ERROR: failed to install $interpreters_dest /minetest.lua "
find " $zs_dest " -iname minetest.lua
exit 4
fi
echo "Successfully installed. See README for manual steps needed in GUI."
else
2021-03-28 01:47:00 -07:00
printf " * installing patches to \" $zs_dest \"... "
2019-02-06 09:20:15 -08:00
sudo rsync -rt zbstudio/ $zs_dest
2021-03-28 01:47:00 -07:00
if [ $? -ne 0 ] ; then
echo "FAILED"
exit 1
else
echo "OK"
fi
2019-02-06 09:20:15 -08:00
fi
echo " $end_msg "
echo
echo