[Ovirt-devel] [PATCH node] Follow on patch for bz#507393.
Darryl L. Pierce
dpierce at redhat.com
Thu Jul 9 14:38:21 UTC 2009
This patch fixes the warnings displayed to the user.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-config-networking | 84 ++++++++++++++++++++++----------------
1 files changed, 49 insertions(+), 35 deletions(-)
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 81f017c..2d0e2b6 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
@@ -131,9 +146,9 @@ function configure_interface
esac
printf "\n"
- read -ep "Is this correct (Y/N/A)? "
- case $REPLY in
- Y|y)
+ ask_yes_or_no "Is this correct (y/n/a)?"
+ case $?
+ 0)
IF_CONFIG="$IF_CONFIG\nset $IF_ROOT/ONBOOT yes"
BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/ONBOOT yes"
@@ -141,8 +156,8 @@ function configure_interface
printf "$BR_CONFIG\n" > $BR_FILENAME
break
;;
- N|n) BR_CONFIG=$BR_CONFIG_BASE ;;
- A|a) CONFIGURED_NIC=""; return;;
+ 1) BR_CONFIG=$BR_CONFIG_BASE ;;
+ 2) CONFIGURED_NIC=""; return;;
esac
done
else
@@ -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,15 @@ function configure_ntp
fi
if [ -z "$AUTO" ]; then
- while true; do
- read -ep "Enter an NTP server (hit return when finished): "
+ if has_configured_interface true; then
+ while true; do
+ read -ep "Enter an NTP server (hit return when finished): "
- if [ -z "$REPLY" ]; then break; fi
+ if [ -z "$REPLY" ]; then break; fi
- NTPSERVERS="$NTPSERVERS $REPLY"
- done
+ NTPSERVERS="$NTPSERVERS $REPLY"
+ done
+ fi
fi
}
--
1.6.2.5
More information about the ovirt-devel
mailing list