Joey Boggs
2009-Oct-09 17:51 UTC
[Ovirt-devel] [PATCH node] validify ipv4/ipv6 static/dhcp choice else loop
If you select an option that's not listed during ipv4/ipv6 setup it will
accept it without verification. This corrects that behavior and forces a valid
option to be picked.
---
scripts/ovirt-config-networking | 106 +++++++++++++++++++++------------------
1 files changed, 58 insertions(+), 48 deletions(-)
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 7d4e363..45f7129 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -160,56 +160,66 @@ function configure_interface
return;;
esac
- read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o or
[A]bort)? "
- case $REPLY in
- D|d)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO
dhcp"
- ;;
- S|s)
- printf "\n"
- read -ep "IP Address: "; IPADDR=$REPLY
- read -ep " Netmask: "; NETMASK=$REPLY
- read -ep " Gateway: "; GATEWAY=$REPLY
-
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO
none"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR
$IPADDR"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK
$NETMASK"
- if [ -n "${GATEWAY}" ]; then
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY
$GATEWAY"
- fi
- ;;
- A|a)
- CONFIGURED_NIC=""
- VLAN_ID=""
- return
- ;;
- esac
+ while true; do
+ read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o
or [A]bort)? "
+ case $REPLY in
+ D|d)
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO
dhcp"
+ break
+ ;;
+ S|s)
+ printf "\n"
+ read -ep "IP Address: "; IPADDR=$REPLY
+ read -ep " Netmask: "; NETMASK=$REPLY
+ read -ep " Gateway: "; GATEWAY=$REPLY
+
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO
none"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR
$IPADDR"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK
$NETMASK"
+ if [ -n "${GATEWAY}" ]; then
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY
$GATEWAY"
+ fi
+ break
+ ;;
+ A|a)
+ CONFIGURED_NIC=""
+ VLAN_ID=""
+ return
+ ;;
+ esac
+ done
printf "\n"
- read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to,
[N]o or [A]bort)? "
- case $REPLY in
- S|s)
- read -ep "IPv6 Address: "; IPADDR=$REPLY
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IP6ADDR
$IPADDR"
- ;;
- D|d)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF
no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING
no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C yes"
- ;;
- U|u)
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING
no"
- BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF
yes"
- ;;
- A|a)
- CONFIGURED_NIC=""
- VLAN_ID=""
- return
- ;;
- esac
+
+ while true; do
+ read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to,
[N]o or [A]bort)? "
+ case $REPLY in
+ S|s)
+ read -ep "IPv6 Address: "; IPADDR=$REPLY
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT
yes"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IP6ADDR
$IPADDR"
+ break
+ ;;
+ D|d)
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT
yes"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF
no"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING
no"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C
yes"
+ break
+ ;;
+ U|u)
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT
yes"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING
no"
+ BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF
yes"
+ break
+ ;;
+ A|a)
+ CONFIGURED_NIC=""
+ VLAN_ID=""
+ return
+ ;;
+ esac
+ done
printf "\n"
ask_yes_or_no "Is this correct ([Y]es/[N]o/[A]bort)?"
true true
--
1.6.2.5
Darryl L. Pierce
2009-Nov-09 16:41 UTC
[Ovirt-devel] [PATCH node] validify ipv4/ipv6 static/dhcp choice else loop
On Fri, Oct 09, 2009 at 01:51:20PM -0400, Joey Boggs wrote:> If you select an option that's not listed during ipv4/ipv6 setup it will accept it without verification. This corrects that behavior and forces a valid option to be picked. > --- > scripts/ovirt-config-networking | 106 +++++++++++++++++++++------------------ > 1 files changed, 58 insertions(+), 48 deletions(-) > > diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking > index 7d4e363..45f7129 100755 > --- a/scripts/ovirt-config-networking > +++ b/scripts/ovirt-config-networking > @@ -160,56 +160,66 @@ function configure_interface > return;; > esac > > - read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o or [A]bort)? " > - case $REPLY in > - D|d) > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp" > - ;; > - S|s) > - printf "\n" > - read -ep "IP Address: "; IPADDR=$REPLY > - read -ep " Netmask: "; NETMASK=$REPLY > - read -ep " Gateway: "; GATEWAY=$REPLY > - > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO none" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK" > - if [ -n "${GATEWAY}" ]; then > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY" > - fi > - ;; > - A|a) > - CONFIGURED_NIC="" > - VLAN_ID="" > - return > - ;; > - esac > + while true; do > + read -ep "Enable IPv4 support ([S]tatic IP, [D]HCP, [N]o or [A]bort)? " > + case $REPLY in > + D|d) > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp" > + break > + ;; > + S|s) > + printf "\n" > + read -ep "IP Address: "; IPADDR=$REPLY > + read -ep " Netmask: "; NETMASK=$REPLY > + read -ep " Gateway: "; GATEWAY=$REPLY > + > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO none" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK" > + if [ -n "${GATEWAY}" ]; then > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY" > + fi > + break > + ;; > + A|a) > + CONFIGURED_NIC="" > + VLAN_ID="" > + return > + ;; > + esac > + done > > printf "\n" > - read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to, [N]o or [A]bort)? " > - case $REPLY in > - S|s) > - read -ep "IPv6 Address: "; IPADDR=$REPLY > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IP6ADDR $IPADDR" > - ;; > - D|d) > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF no" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C yes" > - ;; > - U|u) > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" > - BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes" > - ;; > - A|a) > - CONFIGURED_NIC="" > - VLAN_ID="" > - return > - ;; > - esac > + > + while true; do > + read -ep "Enable IPv6 support ([S]tatic, [D]HCPv6, A[u]to, [N]o or [A]bort)? " > + case $REPLY in > + S|s) > + read -ep "IPv6 Address: "; IPADDR=$REPLY > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IP6ADDR $IPADDR" > + break > + ;; > + D|d) > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTCONF no" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/DHCPV6C yes" > + break > + ;; > + U|u) > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6INIT yes" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no" > + BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes" > + break > + ;; > + A|a) > + CONFIGURED_NIC="" > + VLAN_ID="" > + return > + ;; > + esac > + doneNAK. This portion is missing support for [N]o on IPv6 support. -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 197 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20091109/8e12a39b/attachment.sig>
Reasonably Related Threads
- [PATCH node] Adds vlan support to auto-installations for the node. bz#511056
- [PATCH node] Rerunning network config resets all network config. bz#507393
- [PATCH node] Make all yes/no prompts consistent. rhbz#508778
- [PATCH node] REPOST Joey's and Darryl's ovirt-config-* patches
- [PATCH node] Restricts network configuration to a single NIC.