Browse Source

Start the rework of the /etc/netstart shell script.

General changes:
- apply a similar 'style' as used in the installer scripts
- improve comments to be more to the point, remove where code is obvious
- document usage of functions if they have arguments
- rename variables where it improves readability
- replace really old-school shell code with more contemporary idioms
Other changes:
- No need to care about "autoboot" because netstart doesn't inherit the
positional parameters from /etc/rc anymore. /etc/rc executes netstart
instead of sourcing it since r1.439.
- Use simpler for-loop to process list of interfaces with ifstart.
OK halex@
OPENBSD_5_9
rpe 9 years ago
parent
commit
6b0cd0e880
1 changed files with 9 additions and 17 deletions
  1. +9
    -17
      src/etc/netstart

+ 9
- 17
src/etc/netstart View File

@ -1,6 +1,6 @@
#!/bin/sh - #!/bin/sh -
# #
# $OpenBSD: netstart,v 1.158 2015/10/26 19:24:04 rpe Exp $
# $OpenBSD: netstart,v 1.159 2015/11/01 15:37:18 rpe Exp $
# Turn off Strict Bourne shell mode. # Turn off Strict Bourne shell mode.
set +o sh set +o sh
@ -169,14 +169,8 @@ _rc_parse_conf
# If we were invoked with a list of interface names, just reconfigure these # If we were invoked with a list of interface names, just reconfigure these
# interfaces (or bridges) and return. # interfaces (or bridges) and return.
if [[ $1 == autoboot ]]; then
shift
fi
if [ $# -gt 0 ]; then
while [ $# -gt 0 ]; do
ifstart $1
shift
done
if (($# > 0)); then
for _if; do ifstart $_if; done
ifautoconf ifautoconf
return return
fi fi
@ -184,9 +178,7 @@ fi
# Otherwise, process with the complete network initialization. # Otherwise, process with the complete network initialization.
# /etc/myname contains my symbolic name. # /etc/myname contains my symbolic name.
if [ -f /etc/myname ]; then
hostname "$(stripcom /etc/myname)"
fi
[[ -f /etc/myname ]] && hostname "$(stripcom /etc/myname)"
# Set the address for the loopback interface. Bringing the interface up, # Set the address for the loopback interface. Bringing the interface up,
# automatically invokes the IPv6 address ::1. # automatically invokes the IPv6 address ::1.
@ -287,7 +279,7 @@ NO:NO)
NO:YES) NO:YES)
;; ;;
*:NO) *:NO)
maddr=`if [ "$multicast_host" = "YES" ]; then
maddr=$(if [[ $multicast_host == YES ]]; then
ed -s '!route -qn show -inet' <<EOF ed -s '!route -qn show -inet' <<EOF
/^default/p /^default/p
EOF EOF
@ -295,8 +287,8 @@ EOF
ed -s "!ifconfig $multicast_host" <<EOF ed -s "!ifconfig $multicast_host" <<EOF
/^ inet /p /^ inet /p
EOF EOF
fi 2>/dev/null`
if [ "X${maddr}" != "X" ]; then
fi 2>/dev/null)
if [[ -n $maddr ]]; then
set $maddr set $maddr
route -qn add -net 224.0.0.0/4 -interface $2 >/dev/null route -qn add -net 224.0.0.0/4 -interface $2 >/dev/null
else else
@ -320,10 +312,10 @@ ifmstart "pppoe tun tap gif gre bridge pflow"
# Reject 127/8 other than 127.0.0.1. # Reject 127/8 other than 127.0.0.1.
route -qn add -net 127 127.0.0.1 -reject >/dev/null route -qn add -net 127 127.0.0.1 -reject >/dev/null
if [ "$ip6kernel" = "YES" ]; then
if [[ $ip6kernel == YES ]]; then
# This is to make sure DAD is completed before going further. # This is to make sure DAD is completed before going further.
count=0 count=0
while [ $((count++)) -lt 10 -a "x"`sysctl -n net.inet6.ip6.dad_pending` != "x0" ]; do
while ((count++ < 10 && $(sysctl -n net.inet6.ip6.dad_pending) != 0)); do
sleep 1 sleep 1
done done
fi fi

Loading…
Cancel
Save