]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
update-to-autobuild.sh: add "-y" argument to skip confirmation prompt
authorbones_was_here <bones_was_here@xa.org.au>
Tue, 2 Aug 2022 19:01:53 +0000 (05:01 +1000)
committerbones_was_here <bones_was_here@xa.org.au>
Tue, 2 Aug 2022 19:20:01 +0000 (05:20 +1000)
Setting environment variable `choice=y` will also work.

misc/tools/rsync-updater/update-to-autobuild.sh
misc/tools/rsync-updater/update-to-release.sh

index bd1c6fc9da818661169dd15cc49e7929146a337d..32ce1f2a5e21d857445bd2da18cc80dc3d06f6bd 100755 (executable)
@@ -9,12 +9,11 @@ if ! which rsync >/dev/null; then
        exit 1
 fi
 
        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)
 
 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
 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
        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
        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
                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
                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
index bd1c6fc9da818661169dd15cc49e7929146a337d..32ce1f2a5e21d857445bd2da18cc80dc3d06f6bd 100755 (executable)
@@ -9,12 +9,11 @@ if ! which rsync >/dev/null; then
        exit 1
 fi
 
        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)
 
 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
 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
        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
        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
                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
                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