bsdinstall netconfig: avoid duplicate entries in rc.conf

This uses sysrc to write and update configuration variables in the
temporary configuration file for network access, ._rc.conf.net. This
replaces the previous mechanism, which was simply appending new values
as they were updated.

PR:		212396
Reviewed by:	emaste
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D42194
This commit is contained in:
Pierre Pronchery 2023-10-13 17:45:19 +02:00 committed by Ed Maste
parent 01ab86f7e6
commit 60b37735f3
3 changed files with 4 additions and 4 deletions

View file

@ -81,7 +81,7 @@ exec 5>&-
IFCONFIG_PREFIX=""
if is_wireless_if $INTERFACE; then
NEXT_WLAN_IFACE=wlan0 # XXX
echo wlans_$INTERFACE=\"$NEXT_WLAN_IFACE\" >> $BSDINSTALL_TMPETC/._rc.conf.net
sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net wlans_$INTERFACE "$NEXT_WLAN_IFACE"
IFCONFIG_PREFIX="WPA "
if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then
ifconfig $NEXT_WLAN_IFACE create wlandev $INTERFACE
@ -115,7 +115,7 @@ fi
# In case wlanconfig left an option and we do not support IPv4 we need to write
# it out on its own. We cannot write it out with IPv6 as that suffix.
if [ ${IPV4_AVAIL} -eq 0 -a -n ${IFCONFIG_PREFIX} ]; then
echo ifconfig_${INTERFACE}=\"${IFCONFIG_PREFIX}\" >> $BSDINSTALL_TMPETC/._rc.conf.net
sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net ifconfig_$INTERFACE "${IFCONFIG_PREFIX}"
fi
if [ ${IPV6_AVAIL} -eq 1 ]; then
bsddialog --backtitle "$OSNAME Installer" --title 'Network Configuration' \

View file

@ -63,7 +63,7 @@ if [ $? -eq $BSDDIALOG_OK ]; then
exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}"
fi
fi
echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/._rc.conf.net
sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net ifconfig_$INTERFACE "${IFCONFIG_PREFIX}DHCP"
exit 0
fi

View file

@ -73,7 +73,7 @@ while : ; do
continue
fi
fi
echo ifconfig_${INTERFACE}_ipv6=\"inet6 accept_rtadv\" >> $BSDINSTALL_TMPETC/._rc.conf.net
sysrc -f $BSDINSTALL_TMPETC/._rc.conf.net ifconfig_${INTERFACE}_ipv6 "inet6 accept_rtadv"
exit 0
else
break