Darryl L. Pierce
2009-Jul-08 13:36 UTC
[Ovirt-devel] Final follow up patch to add warning for NTP...
Now, rather than displaying yet another warning, the NTP configuration just requires that the user select a NIC to configure first. That act alone provides the single warning to the user that they'll be changing their network configuration.
Darryl L. Pierce
2009-Jul-08 13:36 UTC
[Ovirt-devel] [PATCH node] Follow on patch for bz#507393.
This patch adds a warning to the NTP changes.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-config-networking | 86 ++++++++++++++++++++++++--------------
1 files changed, 54 insertions(+), 32 deletions(-)
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 81f017c..78a5333 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -28,6 +28,21 @@ if ! is_local_storage_configured; then
exit 99
fi
+# Checks that a network interface was already configured.
+function has_configured_interface
+{
+ local show_message=${1-false}
+
+ if [[ -n "${CONFIGURED_NIC}" ]]; then
+ return 0
+ else
+ if $show_message; then
+ printf "\nYou must configure a network interface
first.\n\n"
+ fi
+ return 1
+ fi
+}
+
function configure_interface
{
local NIC=$1
@@ -40,7 +55,7 @@ function configure_interface
PREFIX=$OVIRT_IP_PREFIX
fi
- if [[ -n "${CONFIGURED_NIC}" ]]; then
+ if has_configured_interface; then
printf "This will delete the current configuration for
${CONFIGURED_NIC}.\n"
read -ep "Continue? (y/N) "
case $REPLY in
@@ -191,11 +206,6 @@ function configure_interface
function configure_dns
{
- if [[ -z "${CONFIGURED_NIC}" ]]; then
- printf "\nYou must configure a network interface first.\n\n"
- return
- fi
-
local DNS=$1
local AUTO=$2
if [[ "$AUTO" == "AUTO" &&
@@ -208,27 +218,29 @@ function configure_dns
local IF_CONFIG
if [ -z "$AUTO" ]; then
- while true; do
- printf "\n"
- echo "Enter up to two DNS servers separated by commas:"
- if [ -n "$OVIRT_DNS" ]; then
- echo "Press Enter for defaults: ($OVIRT_DNS)"
- fi
- read -ep ": "
- DNS=$REPLY
+ if has_configured_interface true; then
+ while true; do
+ printf "\n"
+ echo "Enter up to two DNS servers separated by
commas:"
+ if [ -n "$OVIRT_DNS" ]; then
+ echo "Press Enter for defaults: ($OVIRT_DNS)"
+ fi
+ read -ep ": "
+ DNS=$REPLY
- if [ -z "$DNS" ]; then
- DNS=$OVIRT_DNS
- fi
+ if [ -z "$DNS" ]; then
+ DNS=$OVIRT_DNS
+ fi
- printf "\n"
- read -ep "Is this correct (Y/N/A)? "
- case $REPLY in
- Y|y) break ;;
- N|n) ;;
- A|a) return ;;
- esac
- done
+ printf "\n"
+ read -ep "Is this correct (Y/N/A)? "
+ case $REPLY in
+ Y|y) break ;;
+ N|n) ;;
+ A|a) return ;;
+ esac
+ done
+ fi
fi
if [ -n "$DNS" ]; then
@@ -251,13 +263,23 @@ function configure_ntp
fi
if [ -z "$AUTO" ]; then
- while true; do
- read -ep "Enter an NTP server (hit return when finished): "
-
- if [ -z "$REPLY" ]; then break; fi
-
- NTPSERVERS="$NTPSERVERS $REPLY"
- done
+ if has_configured_interface true; then
+ while true; do
+ read -ep "By continuing, you will remove any existing NTP
settings. Continue (y/n)? "
+ case $REPLY in
+ Y|y) break;;
+ N|n) return;;
+ esac
+ done
+
+ while true; do
+ read -ep "Enter an NTP server (hit return when finished): "
+
+ if [ -z "$REPLY" ]; then break; fi
+
+ NTPSERVERS="$NTPSERVERS $REPLY"
+ done
+ fi
fi
}
--
1.6.2.5