netconfig_ipv4 (6a068746777241722b2b32c5d0bc443a2a64d80b) | netconfig_ipv4 (bc4a673f89b9c5d4eb0be86cf4206a6b09fd2ca3) |
---|---|
1#!/bin/sh 2#- 3# Copyright (c) 2011 Nathan Whitehorn | 1#!/bin/sh 2#- 3# Copyright (c) 2011 Nathan Whitehorn |
4# Copyright (c) 2013 Devin Teske |
|
4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 1. Redistributions of source code must retain the above copyright 10# notice, this list of conditions and the following disclaimer. 11# 2. Redistributions in binary form must reproduce the above copyright --- 8 unchanged lines hidden (view full) --- 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# 27# $FreeBSD$ | 5# All rights reserved. 6# 7# Redistribution and use in source and binary forms, with or without 8# modification, are permitted provided that the following conditions 9# are met: 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 2. Redistributions in binary form must reproduce the above copyright --- 8 unchanged lines hidden (view full) --- 21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26# SUCH DAMAGE. 27# 28# $FreeBSD$ |
29# 30############################################################ INCLUDES |
|
28 | 31 |
29: ${DIALOG_OK=0} 30: ${DIALOG_CANCEL=1} 31: ${DIALOG_HELP=2} 32: ${DIALOG_EXTRA=3} 33: ${DIALOG_ITEM_HELP=4} 34: ${DIALOG_ESC=255} | 32BSDCFG_SHARE="/usr/share/bsdconfig" 33. $BSDCFG_SHARE/common.subr || exit 1 34f_dprintf "%s: loading includes..." "$0" 35f_include $BSDCFG_SHARE/dialog.subr |
35 | 36 |
37############################################################ MAIN 38 |
|
36INTERFACE=$1 37IFCONFIG_PREFIX="$2" 38test -z "$IFCONFIG_PREFIX" || IFCONFIG_PREFIX="$2 " 39case "${INTERFACE}" in 40"") dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' \ 41 --msgbox 'No interface specified for IPv4 configuration.' 0 0 42 exit 1 43 ;; 44esac 45 46dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0 47if [ $? -eq $DIALOG_OK ]; then 48 echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/._rc.conf.net 49 50 if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then 51 dialog --backtitle 'FreeBSD Installer' --infobox "Acquiring DHCP lease..." 0 0 | 39INTERFACE=$1 40IFCONFIG_PREFIX="$2" 41test -z "$IFCONFIG_PREFIX" || IFCONFIG_PREFIX="$2 " 42case "${INTERFACE}" in 43"") dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' \ 44 --msgbox 'No interface specified for IPv4 configuration.' 0 0 45 exit 1 46 ;; 47esac 48 49dialog --backtitle 'FreeBSD Installer' --title 'Network Configuration' --yesno 'Would you like to use DHCP to configure this interface?' 0 0 50if [ $? -eq $DIALOG_OK ]; then 51 echo ifconfig_$INTERFACE=\"${IFCONFIG_PREFIX}DHCP\" >> $BSDINSTALL_TMPETC/._rc.conf.net 52 53 if [ ! -z $BSDINSTALL_CONFIGCURRENT ]; then 54 dialog --backtitle 'FreeBSD Installer' --infobox "Acquiring DHCP lease..." 0 0 |
52 dhclient $INTERFACE 2>> $BSDINSTALL_LOG | 55 err=$( dhclient $INTERFACE 2>&1 ) |
53 if [ $? -ne 0 ]; then | 56 if [ $? -ne 0 ]; then |
57 f_dprintf "%s" "$err" |
|
54 dialog --backtitle 'FreeBSD Installer' --msgbox "DHCP lease acquisition failed." 0 0 55 exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}" 56 fi 57 fi 58 exit 0 59fi 60 61IP_ADDRESS=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $2); }'` --- 19 unchanged lines hidden (view full) --- 81 . $BSDINSTALL_TMPETC/._rc.conf.net 82 ifconfig $INTERFACE `eval echo \\\$ifconfig_$INTERFACE` 83 if [ -n "${defaultrouter}" ]; then 84 route delete -inet default 85 route add -inet default $defaultrouter 86 fi 87fi 88 | 58 dialog --backtitle 'FreeBSD Installer' --msgbox "DHCP lease acquisition failed." 0 0 59 exec $0 ${INTERFACE} "${IFCONFIG_PREFIX}" 60 fi 61 fi 62 exit 0 63fi 64 65IP_ADDRESS=`ifconfig $INTERFACE inet | awk '/inet/ {printf("%s\n", $2); }'` --- 19 unchanged lines hidden (view full) --- 85 . $BSDINSTALL_TMPETC/._rc.conf.net 86 ifconfig $INTERFACE `eval echo \\\$ifconfig_$INTERFACE` 87 if [ -n "${defaultrouter}" ]; then 88 route delete -inet default 89 route add -inet default $defaultrouter 90 fi 91fi 92 |
93################################################################################ 94# END 95################################################################################ |
|