summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2009-02-12 19:54:03 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-17 15:46:41 -0800
commit03fdd12651ac3d6c370e203d32d785253a7bd6c2 (patch)
tree7910e6ced2f26d8880f4047982feb56749dbcd4f
parentf9399f6cd3aeff3478d47183932b771aa4f19d5e (diff)
downloadvyatta-op-03fdd12651ac3d6c370e203d32d785253a7bd6c2.tar.gz
vyatta-op-03fdd12651ac3d6c370e203d32d785253a7bd6c2.zip
Prompt before immediate shutdown
Add yesno helper script and prompt before shutdown
-rw-r--r--Makefile.am1
-rwxr-xr-xscripts/yesno20
-rw-r--r--templates/shutdown/node.def3
3 files changed, 23 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index 3fcf55b..a89a7be 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,7 @@ bin_SCRIPTS += scripts/vyatta-show-dmi
bin_SCRIPTS += scripts/vyatta-tshark-interface-port.pl
bin_SCRIPTS += scripts/vyatta-show-bonding.pl
bin_SCRIPTS += scripts/vyatta-cpu-summary.pl
+bin_SCRIPTS += scripts/yesno
bin_sudo_users_SCRIPTS = scripts/vyatta-identify-interface.pl
bin_sudo_users_SCRIPTS += scripts/vyatta-delete-log-file.sh
diff --git a/scripts/yesno b/scripts/yesno
new file mode 100755
index 0000000..dd186c7
--- /dev/null
+++ b/scripts/yesno
@@ -0,0 +1,20 @@
+#! /bin/bash
+# Usage: yesno prompt...
+
+if [ $# -eq 0 ]
+then prompt="yes or no: "
+else prompt="$*"
+fi
+
+while true
+do
+ read -p "$prompt" || exit 1
+ case "$REPLY" in
+ y*|Y*) exit 0;;
+ n*|n*) exit 1;;
+ *) echo "Answer yes or no please";;
+ esac
+done
+
+
+
diff --git a/templates/shutdown/node.def b/templates/shutdown/node.def
index be56a0c..388dd33 100644
--- a/templates/shutdown/node.def
+++ b/templates/shutdown/node.def
@@ -1,2 +1,3 @@
help: Shutdown the system
-run: sudo /sbin/shutdown -h now
+run: ${vyatta_bindir}/yesno "Proceed with shutdown? [confirm] " \
+ && sudo /sbin/shutdown -h now