From 94e1185e89944f0c01c4b116bc9fece4ea74f8a1 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Wed, 3 Aug 2022 05:01:53 +1000 Subject: [PATCH] update-to-autobuild.sh: add "-y" argument to skip confirmation prompt Setting environment variable `choice=y` will also work. --- misc/tools/rsync-updater/update-to-autobuild.sh | 17 ++++++++--------- misc/tools/rsync-updater/update-to-release.sh | 17 ++++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/misc/tools/rsync-updater/update-to-autobuild.sh b/misc/tools/rsync-updater/update-to-autobuild.sh index bd1c6fc9..32ce1f2a 100755 --- a/misc/tools/rsync-updater/update-to-autobuild.sh +++ b/misc/tools/rsync-updater/update-to-autobuild.sh @@ -9,12 +9,11 @@ if ! which rsync >/dev/null; then exit 1 fi -read -rp "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]?" choice -case "$choice" in - Y) ;; - y) ;; - *) exit 1 ;; -esac +[ "$1" = "-y" ] && choice=y +until [ "$choice" = y ] || [ "$choice" = Y ]; do + read -rp "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]? " choice + [ "$choice" = n ] || [ "$choice" = N ] && exit 1 +done case "${0##*/}" in update-to-autobuild.sh) @@ -28,7 +27,7 @@ esac options="-Prtzil --executability --delete-after --delete-excluded --stats" if [ -d "Xonotic-low" ]; then - echo NOTE: Xonotic-low is gone, downloading normal Xonotic. + echo NOTE: Xonotic-low is gone, downloading normal Xonotic. url="rsync://beta.xonotic.org/$buildtype-Xonotic/" target="Xonotic-low/" elif [ -d "Xonotic-high" ]; then @@ -39,10 +38,10 @@ elif [ -d "../../../.git" ]; then exec ../../../all update elif [ -d "../../../data" ]; then if [ -f ../../../data/xonotic-rsync-data-low.pk3 ]; then - echo NOTE: Xonotic-low is gone, downloading normal Xonotic. + echo NOTE: Xonotic-low is gone, downloading normal Xonotic. url="rsync://beta.xonotic.org/$buildtype-Xonotic/" elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then - echo NOTE: Xonotic-low is gone, downloading normal Xonotic. + echo NOTE: Xonotic-low is gone, downloading normal Xonotic. url="rsync://beta.xonotic.org/$buildtype-Xonotic/" options="$options -y" # use fuzzy matching because file names differ elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then diff --git a/misc/tools/rsync-updater/update-to-release.sh b/misc/tools/rsync-updater/update-to-release.sh index bd1c6fc9..32ce1f2a 100755 --- a/misc/tools/rsync-updater/update-to-release.sh +++ b/misc/tools/rsync-updater/update-to-release.sh @@ -9,12 +9,11 @@ if ! which rsync >/dev/null; then exit 1 fi -read -rp "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]?" choice -case "$choice" in - Y) ;; - y) ;; - *) exit 1 ;; -esac +[ "$1" = "-y" ] && choice=y +until [ "$choice" = y ] || [ "$choice" = Y ]; do + read -rp "This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]? " choice + [ "$choice" = n ] || [ "$choice" = N ] && exit 1 +done case "${0##*/}" in update-to-autobuild.sh) @@ -28,7 +27,7 @@ esac options="-Prtzil --executability --delete-after --delete-excluded --stats" if [ -d "Xonotic-low" ]; then - echo NOTE: Xonotic-low is gone, downloading normal Xonotic. + echo NOTE: Xonotic-low is gone, downloading normal Xonotic. url="rsync://beta.xonotic.org/$buildtype-Xonotic/" target="Xonotic-low/" elif [ -d "Xonotic-high" ]; then @@ -39,10 +38,10 @@ elif [ -d "../../../.git" ]; then exec ../../../all update elif [ -d "../../../data" ]; then if [ -f ../../../data/xonotic-rsync-data-low.pk3 ]; then - echo NOTE: Xonotic-low is gone, downloading normal Xonotic. + echo NOTE: Xonotic-low is gone, downloading normal Xonotic. url="rsync://beta.xonotic.org/$buildtype-Xonotic/" elif [ -f ../../../data/xonotic-*-data-low.pk3 ]; then - echo NOTE: Xonotic-low is gone, downloading normal Xonotic. + echo NOTE: Xonotic-low is gone, downloading normal Xonotic. url="rsync://beta.xonotic.org/$buildtype-Xonotic/" options="$options -y" # use fuzzy matching because file names differ elif [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then -- 2.39.2