]> git.ipfire.org Git - thirdparty/fcron.git/commitdiff
boot-install: added missing ask_user() (lost in merge?) fcron-3.2 ver3_2_1
authorThibault Godouet <yo8192@users.noreply.github.com>
Sun, 26 Jun 2016 17:43:19 +0000 (18:43 +0100)
committerThibault Godouet <yo8192@users.noreply.github.com>
Sat, 9 May 2020 11:23:16 +0000 (12:23 +0100)
script/boot-install

index f8e23607f219fe550ab4f756d74b1da642202c7b..93c2cf5b29181cdbe04e554aeff42e2bec7e15fb 100755 (executable)
@@ -31,9 +31,32 @@ DESTBIN=$2
 DEBUG=$3
 #DEBUG=1
 FCRONTABS=$4
-ANSWER=$5
+ANSWER=$5 # Automatic answer: 0->no, 1->yes, 2->ask
 SRCDIR=$6
 
+# Return y or n (defaults to y)
+# (uses the automatic answer if appropriate)
+ask_user() {
+    if test "$ANSWER" -eq 1 ; then
+        echo y
+    elif test "$ANSWER" -eq 0 ; then
+        echo n
+    fi
+
+    # If we get here, then ask the user interactively
+    ANS=
+    while test \( "$ANS" != "y" \) -a \( "$ANS" != "n" \) ; do
+        echo -n "Please answer with 'y' or 'n' (default: 'y'): " >/dev/stderr
+        read ANS NOTHING
+        test -z "$ANS" && ANS=y # Default value
+    done
+    echo $ANS
+
+}
+
+# Validate the command line arguments:
+# FIXME
+
 if test $DEBUG -eq 1; then
     STARTCMD="fcron -b -d"
 else