diff options
author | Robert Peichaer <rpe@cvs.openbsd.org> | 2013-06-10 21:19:30 +0000 |
---|---|---|
committer | Robert Peichaer <rpe@cvs.openbsd.org> | 2013-06-10 21:19:30 +0000 |
commit | 287f2a50e689d5649d0aed727be0fe5494f7469e (patch) | |
tree | 648226789685aaaa9dd0e9614c3240312ae34471 /distrib/miniroot/install.sub | |
parent | e4bea35ba5d41e3fda90f2f739796dcbb20d0d9d (diff) |
rework v6_defroute()
- simplify search for an existing ipv6 def. route
- ensure, that $_routers holds a sorted and unique list
- show 'list #' in prompt only if there's a list to select from
- zap IFS/_oifs dance and simplify select loop
- set ipv6 def. route in v6_defroute() instead of in v6_config()
thanks naddy@ and todd@ for their feedback
ok sthen@, krw@ on a similar diff
with help from and ok halex@
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r-- | distrib/miniroot/install.sub | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 22441438ff5..ab4a0ca6a8c 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.680 2013/06/04 00:42:23 halex Exp $ +# $OpenBSD: install.sub,v 1.681 2013/06/10 21:19:29 rpe Exp $ # $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback @@ -875,9 +875,6 @@ v6_config() { addhostent "$_addr" "$_name" v6_defroute $_ifs - [[ $resp == none ]] && return - route -n add -inet6 -host default "$resp" || return - echo "$resp" >>/tmp/mygate } v4_defroute() { @@ -906,32 +903,22 @@ v4_defroute() { } v6_defroute() { - local _if=$1 _routers _oifs + local _if=$1 _resp _routers - if [[ -z $(route -n show -inet6 | sed -ne '/^default */{s///; s/ .*//; p;}') ]]; then - resp=none - return - fi + route -n show -inet6 | egrep -q '^default[[:space:]]' && return - if [[ -x /sbin/ping6 ]]; then - _routers=$(ping6 -n -c 2 ff02::2%$_if 2>&1 | - sed -ne '/bytes from/{s/^.*from //;s/,.*$//;p;}') - fi + _routers=$(bsort $(ping6 -n -c 2 ff02::2%$_if 2>/dev/null | + sed -ne '/bytes from/{s/^.*from //;s/,.*$//;p;}' | + sed -ne 'G;s/\n/&&/;/^\(.*\n\).*\n\1/d;h;P')) - _oifs=$IFS - IFS= - PS3="IPv6 default router? (list #, IPv6 address or 'none'): " - select i in $_routers; do - case $i in - "") resp=$REPLY - [[ -n $resp ]] && break - ;; - *) resp=$i - break - ;; - esac + local PS3="IPv6 default router? (${_routers:+list #, }IPv6 address or 'none'): " + select _resp in $_routers; do + [[ ${_resp:=$REPLY} == *:* ]] && break + [[ $_resp == none ]] && return done - IFS=$_oifs + + route -n add -inet6 -host default "$_resp" && + echo "$_resp" >>/tmp/mygate } # Much of this is gratuitously stolen from /etc/netstart. |