diff options
-rwxr-xr-x | scripts/yesno | 12 | ||||
-rw-r--r-- | templates/shutdown/node.def | 2 |
2 files changed, 13 insertions, 1 deletions
diff --git a/scripts/yesno b/scripts/yesno index dd186c7..cbed0e0 100755 --- a/scripts/yesno +++ b/scripts/yesno @@ -1,14 +1,26 @@ #! /bin/bash # Usage: yesno prompt... +default= +if [ $1 == "-y" ] +then default='y'; shift +fi + if [ $# -eq 0 ] then prompt="yes or no: " else prompt="$*" fi +if [ ! -z $default ]; then + prompt+="[y]" +fi + while true do read -p "$prompt" || exit 1 + if [ -z "$REPLY" -a ! -z $default ] + then REPLY=$default + fi case "$REPLY" in y*|Y*) exit 0;; n*|n*) exit 1;; diff --git a/templates/shutdown/node.def b/templates/shutdown/node.def index 388dd33..4185f40 100644 --- a/templates/shutdown/node.def +++ b/templates/shutdown/node.def @@ -1,3 +1,3 @@ help: Shutdown the system -run: ${vyatta_bindir}/yesno "Proceed with shutdown? [confirm] " \ +run: ${vyatta_bindir}/yesno -y "Proceed with shutdown? [confirm]" \ && sudo /sbin/shutdown -h now |