[ -t 2 ] && [ -t 1 ] && [ -t 0 ] && interactive=true || interactive=false
if ! command -v rsync > /dev/null; then
- echo >&2 "FATAL: rsync not found, please install the rsync package"
+ printf >&2 "\033[1;31mFATAL: rsync not found, please install the rsync package!\033[m\n"
exit 1
fi
-if [ "$1" = "-y" ] || [ "$1" = "--yes" ]; then
- choice=y
-elif [ $interactive = false ]; then
- printf >&2 "\033[1;31mFATAL: non-interactive mode requires the \033[1;37m--yes\033[1;31m argument to acknowledge that this script will DELETE any custom files in the Xonotic directory.\033[m\n"
- exit 1
-fi
-until [ "$choice" = y ] || [ "$choice" = Y ]; do
- printf "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]? "
- read -r choice
- [ "$choice" = n ] || [ "$choice" = N ] && exit 1
-done
-
case "${0##*/}" in
update-to-autobuild.sh)
buildtype=autobuild
package="Xonotic"
target="../../.."
if [ -d "../../../.git" ]; then
- echo >&2 "NOTE: this is a git repository download. Using the regular update method."
+ printf >&2 "\033[1;33mNOTE: this is a git repository. Using the git update method.\033[m\n"
exec ../../../all update
-elif [ -e "Xonotic" ]; then
- echo "found manually created 'Xonotic' file"
-elif [ -e "Xonotic-high" ]; then
- echo "found manually created 'Xonotic-high' file"
- package="Xonotic-high"
-elif [ -d "../../../data" ]; then
- if [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then
- echo "found rsync high data files"
- package="Xonotic-high"
- elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
- echo "found release high data files"
+elif PWD="${PWD%/}" && [ "$PWD" != "${PWD%/misc/tools/rsync-updater}" ]; then
+ if [ -f ../../../data/xonotic-*-data-high.pk3 ]; then
+ echo "Found Xonotic-high data files"
package="Xonotic-high"
- elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then
- echo "found Xonotic rsync data files"
elif [ -f ../../../data/xonotic-*-data.pk3 ]; then
- echo "found Xonotic release data files"
+ echo "Found Xonotic data files"
else
- echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used."
- exit 1
+ printf "\033[1;31mNOTE: found misc/tools/rsync-updater parent directories but no data files!\033[m\n"
fi
else
- target="Xonotic/"
+ printf >&2 "\033[1;31mFATAL: unrecognized Xonotic build. This update script cannot be used.\033[m\n"
+ exit 1
+fi
+if [ -e "Xonotic" ]; then
+ printf "\033[1;35mFound manually created 'Xonotic' package override\033[m\n"
+ package="Xonotic"
+elif [ -e "Xonotic-high" ]; then
+ printf "\033[1;35mFound manually created 'Xonotic-high' package override\033[m\n"
+ package="Xonotic-high"
fi
url="beta.xonotic.org/$buildtype-$package"
excludes="$excludes --exclude=/xonotic-osx-*"
;;
*)
- printf >&2 "\e[1;31m"
+ printf >&2 "\033[1;31m"
printf >&2 "WARNING: Could not detect architecture\n"
printf >&2 "WARNING: Xonotic does NOT provide pre-built %s executables\n" "$(uname):$(uname -m)"
printf >&2 "WARNING: Please run make. More info is available at\n"
- printf >&2 "WARNING: \e[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\e[m\n"
+ printf >&2 "WARNING: \033[1;36mhttps://gitlab.com/xonotic/xonotic/-/wikis/Compiling\033[m\n"
excludes="$excludes --exclude=/Xonotic*.app"
excludes="$excludes --exclude=/xonotic-osx-*"
excludes="$excludes --exclude=/xonotic-linux64-*"
resolvedtarget=$(cd $target && [ "${PWD#$HOME}" != "$PWD" ] && printf "~${PWD#$HOME}" || printf "$PWD")
printf "Updating \033[1;34m$resolvedtarget\033[m from \033[0;36m$url \033[m...\n"
+
+targetname=$(cd "$target" && printf "${PWD##*/}")
+if [ "$1" = "-y" ] || [ "$1" = "--yes" ]; then
+ choice=y
+elif [ $interactive = false ]; then
+ printf >&2 "\033[1;31mFATAL: non-interactive mode requires the \033[1;37m--yes\033[1;31m argument to acknowledge that this will DELETE any custom files in the \"$targetname\" directory.\033[m\n"
+ exit 1
+fi
+until [ "$choice" = y ] || [ "$choice" = Y ]; do
+ printf "\033[1mThis will DELETE any custom files in the \"$targetname\" folder, continue? [Y/N] \033[m"
+ read -r choice
+ [ "$choice" = n ] || [ "$choice" = N ] && exit 1
+done
+
# exec ensures this script stops before it's updated to prevent potential glitches
exec rsync $options $excludes "rsync://$url/" "$target"