netconf(8): rewrite
When possible, network drivers are now started automatically. That means that netconf(8)'s network driver selection has become obsolete. This patch changes netconf(8) to allow the user to specify a network configuration (currently one of DHCP IPv4+IPv6, DHCP IPv4-only, manual IPv4-only) for any hardware network interfaces that are currently present. Selection of network drivers that require manual configuration first (mainly old ISA cards) is still supported, but now as a special case. Change-Id: I6208fc75192eb7f0b061862aaf7507f71a620da4
This commit is contained in:
parent
60299d873c
commit
9a8b4f5601
@ -1,79 +1,37 @@
|
|||||||
.TH NETCONF 8
|
.Dd February 22, 2017
|
||||||
.SH NAME
|
.Dt NETCONF 8
|
||||||
netconf - a script to configure the network
|
.Os
|
||||||
.SH SYNOPSIS
|
.Sh NAME
|
||||||
.B netconf
|
.Nm netconf
|
||||||
.RB [\-q]
|
.Nd configure the network interactively
|
||||||
.RB [\-p
|
.Sh SYNOPSIS
|
||||||
.RI <prefix>]
|
.Nm
|
||||||
.RB [\-e
|
.Op Fl lh
|
||||||
.RI <num>]
|
.Op Fl p Ar prefix
|
||||||
.RB [\-a]
|
.Sh DESCRIPTION
|
||||||
|
The
|
||||||
.B netconf
|
.Nm
|
||||||
.RB [\-H
|
utility allows the root user to configure the network in an interactive mode.
|
||||||
.RI <hostname>
|
.Sh OPTIONS
|
||||||
.RB ]
|
.Bl -tag -width XpXprefixXX
|
||||||
.RB \-i
|
.It Fl l
|
||||||
.RI <ip>
|
Print a list of configurable interfaces.
|
||||||
.RB \-n
|
.It Fl h
|
||||||
.RI <mask>
|
Print usage.
|
||||||
.RB \-g
|
.It Fl p Ar prefix
|
||||||
.RI <gw>
|
Set a path prefix for configuration files (e.g., /mnt).
|
||||||
.RB \-d
|
.El
|
||||||
.RI "<prim dns>"
|
.Sh SEE ALSO
|
||||||
.RB [\-s
|
.Xr ifconfig.if 5 ,
|
||||||
.RI "<sec dns> ]"
|
.Xr resolv.conf 5 ,
|
||||||
|
.Xr ifconfig 8 ,
|
||||||
.B netconf
|
.Xr route 8 ,
|
||||||
.RB [\-c]
|
.Xr dhcpcd 8
|
||||||
|
.Sh BUGS
|
||||||
.SH DESCRIPTION
|
IPv6 support is limited at this time.
|
||||||
.B Netconf
|
.Sh AUTHORS
|
||||||
allows the root user to configure the network. It defaults to an interactive
|
Original version by Thomas Veerman <thomas@minix3.org>.
|
||||||
mode. However, command line options can be used to answer some of the
|
.Pp
|
||||||
questions.
|
NetBSD networking rewrite by David van Moolenbroek <david@minix3.org>.
|
||||||
.SH OPTIONS
|
.Pp
|
||||||
.TP
|
Original manual page by Leith Brandeland <lb.minix@gmail.com>.
|
||||||
.B \-q
|
|
||||||
Limit generated output
|
|
||||||
.TP
|
|
||||||
.B \-p
|
|
||||||
Path prefix for configuration files.
|
|
||||||
.TP
|
|
||||||
.B \-e
|
|
||||||
Ethernet card
|
|
||||||
.TP
|
|
||||||
.B \-a
|
|
||||||
Use DHCP. (Will override -H, -i, -n, -g, -d, and -s flags)
|
|
||||||
.TP
|
|
||||||
.B \-H
|
|
||||||
Hostname
|
|
||||||
.TP
|
|
||||||
.B \-i
|
|
||||||
IP address
|
|
||||||
.TP
|
|
||||||
.B \-n
|
|
||||||
Netmask
|
|
||||||
.TP
|
|
||||||
.B \-g
|
|
||||||
Default Gateway
|
|
||||||
.TP
|
|
||||||
.B \-d
|
|
||||||
Primary DNS
|
|
||||||
.TP
|
|
||||||
.B \-s
|
|
||||||
Secondary DNS
|
|
||||||
.TP
|
|
||||||
.B \-h
|
|
||||||
Usage
|
|
||||||
.TP
|
|
||||||
.B \-c
|
|
||||||
Prints list of supported ethernet cards
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
ifconfig(8),
|
|
||||||
dhcpd(8)
|
|
||||||
.SH NOTES
|
|
||||||
Must be the root user to execute this script.
|
|
||||||
.SH AUTHOR
|
|
||||||
Leith Brandeland <lb.minix@gmail.com>
|
|
||||||
|
@ -1,319 +1,363 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# netconf 0.1 - Configure network
|
# netconf 0.2 - Configure network
|
||||||
#
|
#
|
||||||
# Changes:
|
# Changes:
|
||||||
|
# v0.2: rewrite for NetBSD network infrastructure
|
||||||
|
# - the primary choice is now for an interface, not a network card;
|
||||||
|
# - manual driver configuration is now an exception;
|
||||||
|
# - the menu transition system is slightly more solid;
|
||||||
|
# - all non-interactive functionality has been removed.
|
||||||
#
|
#
|
||||||
|
|
||||||
# Get system config
|
# Get system config
|
||||||
. /etc/rc.conf
|
. /etc/rc.conf
|
||||||
|
|
||||||
LOCALRC=/usr/etc/rc.local
|
LOCALRC=/usr/etc/rc.local
|
||||||
INETCONF=/etc/inet.conf
|
IFCONF=/etc/ifconfig.
|
||||||
RCNET=/etc/rc.net
|
RESOLVCONF=/etc/resolv.conf
|
||||||
HOSTS=/etc/hosts
|
|
||||||
HOSTNAME=/etc/hostname.file
|
HOSTNAME=/etc/hostname.file
|
||||||
USRKBFILE=/.usrkb
|
USRKBFILE=/.usrkb
|
||||||
LSPCI=/tmp/lspci.$$
|
|
||||||
DEVICES=/tmp/devices.$$
|
|
||||||
|
|
||||||
step1=""
|
|
||||||
step2=""
|
|
||||||
step3=""
|
|
||||||
v=1 # verbosity
|
|
||||||
manual_opts=0
|
|
||||||
prefix=""
|
prefix=""
|
||||||
cd="no" # running from cd?
|
cd="no" # running from cd?
|
||||||
|
changed="no" # have any ifconfig.if(5) files been changed?
|
||||||
eth=""
|
|
||||||
driver=""
|
|
||||||
driverargs=""
|
|
||||||
|
|
||||||
config=""
|
|
||||||
manual=""
|
|
||||||
dhcp="no"
|
|
||||||
|
|
||||||
hostname=""
|
|
||||||
hostname_prev=""
|
|
||||||
ip=""
|
|
||||||
ip_prev=""
|
|
||||||
netmask=""
|
|
||||||
netmask_prev=""
|
|
||||||
gateway=""
|
|
||||||
dns1=""
|
|
||||||
dns2=""
|
|
||||||
|
|
||||||
# Provide some sane defaults
|
|
||||||
hostname_default=`uname -n`
|
|
||||||
test -z "$hostname_default" && hostname_default="Minix"
|
|
||||||
ip_default="10.0.0.1"
|
|
||||||
netmask_default="255.255.255.0"
|
|
||||||
gateway_default=""
|
|
||||||
|
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
cat >&2 <<'EOF'
|
cat >&2 <<'EOF'
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
netconf [-q] [-p <prefix>] [-e <num>] [-a]
|
netconf [-lh] [-p <prefix>]
|
||||||
netconf [-H <name> -i <ip> -n <mask> -g <gw> -d <prim dns> [-s <sec dns>]]
|
|
||||||
|
|
||||||
flags:
|
flags:
|
||||||
-q Limit generated output
|
-l Print a list of configurable interfaces
|
||||||
-p Path prefix for configuration files (e.g., during install -p mnt is used as files are mounted on /mnt).
|
-h Print this help file
|
||||||
-e Ethernet card
|
-p Set a path prefix for all configuration files (e.g., /mnt)
|
||||||
-a Use DHCP (-H, -i, -n, -g, -d, and -s flags are discarded)
|
|
||||||
-H Hostname
|
|
||||||
-i IP address
|
|
||||||
-n Netmask
|
|
||||||
-g Default gateway
|
|
||||||
-d Primary DNS
|
|
||||||
-s Secondary DNS
|
|
||||||
-h Shows this help file
|
|
||||||
-c Shows a list of ethernet cards supported
|
|
||||||
|
|
||||||
By default netconf starts in Interactive mode. By providing parameters on the
|
|
||||||
command line, some questions can be omitted.
|
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
card()
|
backup_file()
|
||||||
{
|
{
|
||||||
card_number=$1
|
# Do not make backups if we're running from CD.
|
||||||
card_name=$2
|
if [ "$cd" != "yes" -a -f "$1" ]; then
|
||||||
card_avail=0
|
mv "$1" "$1~" || exit 1
|
||||||
shift 2
|
echo
|
||||||
while [ $# -gt 0 ]
|
echo "Backed up $1 to $1~"
|
||||||
do
|
|
||||||
cat $LSPCI | grep > /dev/null "^$1" && card_avail=1
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
if [ $card_avail -gt 0 ]
|
|
||||||
then
|
|
||||||
card_mark="*"
|
|
||||||
eth_default=$card_number
|
|
||||||
else
|
|
||||||
card_mark=" "
|
|
||||||
fi
|
fi
|
||||||
printf "%2d. %s %s\n" "$card_number" "$card_mark" "$card_name"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
first_pcicard=5
|
select_number()
|
||||||
|
|
||||||
cards()
|
|
||||||
{
|
{
|
||||||
# Run lspci once to a temp file for use in 'card' function
|
while true; do
|
||||||
lspci >$LSPCI 2>/dev/null || true
|
echo -n "$4 [$3] "
|
||||||
|
read input
|
||||||
card 0 "No Ethernet card (no networking)"
|
case "$input" in
|
||||||
card 1 "3Com 501 or 3Com 509 based card"
|
'')
|
||||||
card 2 "Realtek 8029 based card (also emulated by Qemu)" "10EC:8029"
|
return $3
|
||||||
card 3 "NE2000, 3com 503 or WD based card (also emulated by Qemu, Bochs)"
|
;;
|
||||||
card 4 "lan8710a (on BeagleBone, BeagleBone Black)"
|
*[!0-9]*)
|
||||||
n=$first_pcicard
|
;;
|
||||||
for pcicard in $pci_list
|
*)
|
||||||
do var=\$pci_descr$pcicard; descr="`eval echo $var`"
|
[ $input -ge $1 -a $input -le $2 ] && return $input
|
||||||
var=\$pci_pcilist$pcicard; pcilist="`eval echo $var`"
|
;;
|
||||||
card $n "$descr" $pcilist
|
esac
|
||||||
n="`expr $n + 1`"
|
done
|
||||||
done
|
|
||||||
|
|
||||||
card $first_after_pci "Different Ethernet card (no networking)"
|
|
||||||
|
|
||||||
# Remove temporary lspci output
|
|
||||||
rm -f $LSPCI
|
|
||||||
}
|
}
|
||||||
|
|
||||||
warn()
|
interfaces()
|
||||||
{
|
{
|
||||||
echo -e "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b ! $1"
|
# Get a list of interfaces that are not virtual (i.e., cloners). There
|
||||||
}
|
# is always one virtual interface type ("lo", loopback).
|
||||||
|
cloners_regex='^('`ifconfig -C | sed 's/ /[0-9]|/g'`'[0-9])'
|
||||||
|
iflist=`ifconfig -l | tr ' ' '\n' | grep -vE "$cloners_regex"`
|
||||||
|
|
||||||
config_pci_cards() {
|
ifcount=0
|
||||||
rm -f $DEVICES
|
ifunconf=0 # the first interface with no configuration file, or 0
|
||||||
|
if [ -z "$iflist" ]; then
|
||||||
n=0
|
echo " No network hardware interfaces detected!"
|
||||||
|
else
|
||||||
# Collect configs from network devices
|
for if in $iflist; do
|
||||||
for dir in $SYSTEM_CONF_DIRS
|
ifcount=$(($ifcount + 1))
|
||||||
do for f in $dir/$SYSTEM_CONF_SUBDIR/*
|
if [ -r $IFCONF$if ]; then
|
||||||
do if [ -f $f ]
|
info="($1)"
|
||||||
then printconfig $f | grep 'type net.*pci device'
|
else
|
||||||
|
[ $ifunconf -eq 0 ] && ifunconf=$ifcount
|
||||||
|
info=""
|
||||||
fi
|
fi
|
||||||
|
printf "%2d. %-8s %s\n" $ifcount "$if" "$info"
|
||||||
done
|
done
|
||||||
done >$DEVICES
|
fi
|
||||||
while read devline
|
|
||||||
do pcilist="`echo $devline | sed 's/.*pci device //' | sed 's/,.*//'`"
|
|
||||||
descr="`echo $devline | sed 's/.*,descr //' | sed 's/,.*//'`"
|
|
||||||
label="`echo $devline | sed 's/.*service //' | sed 's/,.*//'`"
|
|
||||||
pci_list="$pci_list $n"
|
|
||||||
eval "pci_pcilist$n=\"$pcilist\""
|
|
||||||
eval "pci_descr$n=\"$descr\""
|
|
||||||
eval "pci_label$n=\"$label\""
|
|
||||||
n="`expr $n + 1`"
|
|
||||||
done <$DEVICES
|
|
||||||
|
|
||||||
first_after_pci=`expr $first_pcicard + $n`
|
|
||||||
|
|
||||||
rm -f $DEVICES
|
|
||||||
}
|
}
|
||||||
|
|
||||||
do_step1()
|
do_step1()
|
||||||
{
|
{
|
||||||
eth_default=0
|
echo "
|
||||||
|
The following network interfaces are available for configuration. These are
|
||||||
|
interfaces corresponding to network drivers that are currently running. If no
|
||||||
|
interface is listed for your network card here, then either MINIX 3 does not
|
||||||
|
support your card, or, if it is not a plug-and-play device, it may require
|
||||||
|
manual configuration first.
|
||||||
|
|
||||||
# Ask user about networking
|
Please choose the interface you would like to configure, or another option.
|
||||||
echo "MINIX 3 currently supports the following Ethernet cards. PCI cards detected"
|
"
|
||||||
echo "by MINIX are marked with *. Please choose: "
|
interfaces "already configured"
|
||||||
echo ""
|
echo
|
||||||
cards
|
manual_choice=$(($ifcount + 1))
|
||||||
echo ""
|
quit_choice=$(($ifcount + 2))
|
||||||
|
printf "%2d. Manually configure an ethernet driver\n" $manual_choice
|
||||||
|
printf "%2d. Quit\n\n" $quit_choice
|
||||||
|
|
||||||
while [ "$step1" != ok ]; do
|
default_choice=$ifunconf
|
||||||
echo -n "Ethernet card? [$eth_default] "; read eth
|
[ $default_choice -eq 0 ] && default_choice=$quit_choice
|
||||||
test -z $eth && eth=$eth_default
|
|
||||||
|
|
||||||
drv_params $eth
|
select_number 1 $quit_choice $default_choice "Interface choice?"
|
||||||
test -n "$driver" && step1="ok"
|
choice=$?
|
||||||
done
|
|
||||||
|
case $choice in
|
||||||
|
$manual_choice)
|
||||||
|
step=do_stepM
|
||||||
|
;;
|
||||||
|
$quit_choice)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
ifchoice="$(echo $iflist | cut -d' ' -f$choice)"
|
||||||
|
step=do_step2
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
drv_params()
|
do_stepM()
|
||||||
{
|
{
|
||||||
# If this is a known pci device, we only have to set
|
# TODO: it would be nice if this list changed on a per-platform basis..
|
||||||
# the driver.
|
echo "
|
||||||
if [ $1 -ge $first_pcicard -a $1 -lt $first_after_pci ]
|
MINIX 3 has drivers for a limited number of older cards that require manual
|
||||||
then pcicard="`expr $1 - $first_pcicard`"
|
configuration. They are shown below. Please choose one of the listed options.
|
||||||
var=\$pci_label$pcicard; driver="`eval echo $var`"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Other possibilities.
|
1. 3Com 501 or 3Com 509 based ISA card (i386)
|
||||||
case "$1" in
|
2. NE2000, 3Com 503, or WD based ISA card (i386) (emulated by Bochs, Qemu)
|
||||||
0) driver=psip0; ;;
|
|
||||||
1) driver=dpeth; driverargs="#dpeth_arg='DPETH0=port:irq:memory'";
|
3. Go back to interface selection
|
||||||
test "$v" = 1 && echo ""
|
4. Quit
|
||||||
test "$v" = 1 && echo "Note: After installing, edit $LOCALRC to the right configuration."
|
"
|
||||||
|
|
||||||
|
select_number 1 4 4 "Card choice?"
|
||||||
|
|
||||||
|
case $? in
|
||||||
|
1)
|
||||||
|
driver=dpeth
|
||||||
|
driverargs="#dpeth_args='DPETH0=port:irq:memory'"
|
||||||
|
echo "
|
||||||
|
Note: After installing, edit $LOCALRC to the right configuration."
|
||||||
;;
|
;;
|
||||||
2) driver=dp8390; driverargs="dp8390_arg='DPETH0=pci'"; ;;
|
2)
|
||||||
3) driver=dp8390; driverargs="dp8390_arg='DPETH0=300:9'";
|
driver=dp8390
|
||||||
test "$v" = 1 && echo ""
|
driverargs="dp8390_args='DPETH0=300:9'"
|
||||||
test "$v" = 1 && echo "Note: After installing, edit $LOCALRC to the right configuration."
|
echo "
|
||||||
test "$v" = 1 && echo "You may then also have to edit /etc/system.conf ."
|
Note: After installing, edit $LOCALRC to the right configuration.
|
||||||
test "$v" = 1 && echo "For now, the defaults for emulation by Bochs/Qemu have been set."
|
You may then also have to edit /etc/system.conf.d/dp8390 to match.
|
||||||
|
For now, the defaults for emulation by Bochs/Qemu have been set."
|
||||||
;;
|
;;
|
||||||
4) driver=lan8710a; ;;
|
3)
|
||||||
$first_after_pci) driver="psip0"; ;;
|
step=do_step1
|
||||||
*) warn "choose a number"
|
return
|
||||||
esac
|
;;
|
||||||
|
4)
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
backup_file "$LOCALRC"
|
||||||
|
echo "# Generated by netconf(8). Edit as necessary." > $LOCALRC
|
||||||
|
echo "netdriver='"$driver"'" >> $LOCALRC
|
||||||
|
echo "$driverargs" >> $LOCALRC
|
||||||
|
|
||||||
|
# $LOCALRC typically expands to /mnt/usr/etc/rc.local, so leave room..
|
||||||
|
echo "
|
||||||
|
A template to start the driver has been written to $LOCALRC . As
|
||||||
|
noted above, you may have to edit it. Once you are done editing, reboot the
|
||||||
|
system, after which the driver will be started. Once the driver is running,
|
||||||
|
you can run 'netconf' to configure the corresponding network interface."
|
||||||
}
|
}
|
||||||
|
|
||||||
do_step2()
|
do_step2()
|
||||||
{
|
{
|
||||||
echo ""
|
iffile="$IFCONF$ifchoice"
|
||||||
echo "Configure network using DHCP or manually?"
|
|
||||||
echo ""
|
|
||||||
echo "1. Automatically using DHCP"
|
|
||||||
echo "2. Manually"
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
while [ "$step2" != ok ]
|
echo "
|
||||||
do
|
Configure interface $ifchoice using DHCP or manually?
|
||||||
echo -n "Configure method? [1] "; read config
|
|
||||||
test -z $config && config=1
|
|
||||||
|
|
||||||
case "$config" in
|
For now, the choice here is primarily about IPv4. With DHCP it is possible to
|
||||||
1) step2="ok"; dhcp="yes" ; ;;
|
enable IPv6 as well. Even if the local network has no IPv6 facilities, enabling
|
||||||
2) step2="ok"; manual="do"; ;;
|
IPv6 should do no harm. For IPv6-only mode or any other configuration that is
|
||||||
*) warn "choose a number"
|
not supported here, you will have to edit $iffile yourself.
|
||||||
|
|
||||||
|
1. Automatically using DHCP (IPv4 + IPv6)
|
||||||
|
2. Automatically using DHCP (IPv4 only)
|
||||||
|
3. Manually (IPv4 only)"
|
||||||
|
|
||||||
|
if [ -r "$iffile" ]; then
|
||||||
|
echo " 4. Remove current configuration"
|
||||||
|
remove_choice=4
|
||||||
|
goback_choice=5
|
||||||
|
quit_choice=6
|
||||||
|
else
|
||||||
|
remove_choice=X
|
||||||
|
goback_choice=4
|
||||||
|
quit_choice=5
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
printf "%2d. Go back to interface selection\n" $goback_choice
|
||||||
|
printf "%2d. Quit\n\n" $quit_choice
|
||||||
|
|
||||||
|
select_number 1 $quit_choice 1 "Configuration choice?"
|
||||||
|
|
||||||
|
case $? in
|
||||||
|
1)
|
||||||
|
backup_file "$iffile"
|
||||||
|
echo 'up' > $iffile
|
||||||
|
echo '!dhcpcd -qM $int' >> $iffile
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Interface $ifchoice configured for DHCP (IPv4 + IPv6)."
|
||||||
|
step=do_step3
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
backup_file "$iffile"
|
||||||
|
echo 'up' > $iffile
|
||||||
|
echo '!dhcpcd -qM -4 $int' >> $iffile
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Interface $ifchoice configured for DHCP (IPv4 only)."
|
||||||
|
step=do_step3
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
# Query user for settings
|
||||||
|
#
|
||||||
|
# Some of these settings (hostname, nameservers) do not apply
|
||||||
|
# to just the selected interface. Still, they are what one has
|
||||||
|
# to specify for a complete manual configuration. In order to
|
||||||
|
# make manual configuration of multiple interfaces less
|
||||||
|
# frustrating in this regard, offer defaults that match what
|
||||||
|
# may just have been set already.
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Hostname
|
||||||
|
if [ -r $HOSTNAME ]; then
|
||||||
|
hostname_default=$(cat $HOSTNAME)
|
||||||
|
else
|
||||||
|
hostname_default="minix"
|
||||||
|
fi
|
||||||
|
echo -n "Hostname [$hostname_default]: "
|
||||||
|
read hostname
|
||||||
|
if [ -z "$hostname" ]; then
|
||||||
|
hostname="$hostname_default"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# IP address
|
||||||
|
ip=""
|
||||||
|
while [ -z "$ip" ]; do
|
||||||
|
echo -n "IP address []: "
|
||||||
|
read ip
|
||||||
|
done
|
||||||
|
|
||||||
|
# Netmask
|
||||||
|
echo -n "Netmask (optional) []: "
|
||||||
|
read netmask
|
||||||
|
[ -n "$netmask" ] && netmask=" netmask $netmask"
|
||||||
|
|
||||||
|
# Gateway (no gateway is fine for local networking)
|
||||||
|
echo -n "Gateway (optional) []: "
|
||||||
|
read gateway
|
||||||
|
|
||||||
|
# DNS Servers
|
||||||
|
dns1_default="$(grep '^nameserver' $RESOLVCONF 2>/dev/null | \
|
||||||
|
sed '1q' | awk '{print $2}')"
|
||||||
|
dns2_default="$(grep '^nameserver' $RESOLVCONF 2>/dev/null | \
|
||||||
|
sed '2q;d' | awk '{print $2}')"
|
||||||
|
|
||||||
|
echo -n "Primary DNS Server [$dns1_default]: "
|
||||||
|
read dns1
|
||||||
|
[ -z "$dns1" ] && dns1="$dns1_default"
|
||||||
|
|
||||||
|
if [ -n "$dns1" ]; then
|
||||||
|
echo -n "Secondary DNS Server (optional) [$dns2_default]: "
|
||||||
|
read dns2
|
||||||
|
[ -z "$dns2" ] && dns2="$dns2_default"
|
||||||
|
else
|
||||||
|
dns2=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
backup_file "$HOSTNAME"
|
||||||
|
echo "$hostname" > $HOSTNAME
|
||||||
|
hostname "$hostname"
|
||||||
|
|
||||||
|
backup_file "$iffile"
|
||||||
|
echo 'up' > $iffile
|
||||||
|
echo "inet $ip$netmask" >> $iffile
|
||||||
|
if [ -n "$gateway" ]; then
|
||||||
|
echo "!route -q add default $gateway" >> $iffile
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$dns1" ]; then
|
||||||
|
backup_file "$RESOLVCONF"
|
||||||
|
echo "nameserver $dns1" > $RESOLVCONF
|
||||||
|
if [ -n "$dns2" ]; then
|
||||||
|
echo "nameserver $dns2" >> $RESOLVCONF
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Interface $ifchoice configured manually."
|
||||||
|
step=do_step3
|
||||||
|
;;
|
||||||
|
$remove_choice)
|
||||||
|
backup_file "$iffile"
|
||||||
|
rm -f "$iffile"
|
||||||
|
echo
|
||||||
|
echo "Removed configuration for interface $ifchoice."
|
||||||
|
step=do_step3
|
||||||
|
;;
|
||||||
|
$goback_choice)
|
||||||
|
step=do_step1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
|
||||||
|
|
||||||
# Use manual parameters?
|
|
||||||
if [ -n "$manual" ]; then
|
|
||||||
# Query user for settings
|
|
||||||
# Hostname
|
|
||||||
if [ -z $hostname_prev ]; then
|
|
||||||
hostname_prev=$hostname_default
|
|
||||||
fi
|
|
||||||
echo -n "Hostname [$hostname_prev]: "
|
|
||||||
read hostname
|
|
||||||
if [ ! -z $hostname ]; then
|
|
||||||
hostname_prev=$hostname
|
|
||||||
else
|
|
||||||
hostname=$hostname_prev
|
|
||||||
fi
|
|
||||||
|
|
||||||
# IP address
|
|
||||||
if [ -z $ip_prev ]; then
|
|
||||||
ip_prev=$ip_default
|
|
||||||
fi
|
|
||||||
echo -n "IP address [$ip_prev]: "
|
|
||||||
read ip
|
|
||||||
if [ ! -z $ip ]; then
|
|
||||||
ip_prev=$ip
|
|
||||||
else
|
|
||||||
ip=$ip_prev
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Netmask
|
|
||||||
if [ -z $netmask_prev ]; then
|
|
||||||
netmask_prev=$netmask_default
|
|
||||||
fi
|
|
||||||
echo -n "Netmask [$netmask_prev]: "
|
|
||||||
read netmask
|
|
||||||
if [ ! -z $netmask ]; then
|
|
||||||
netmask_prev=$netmask
|
|
||||||
else
|
|
||||||
netmask=$netmask_prev
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Gateway (no gateway is fine for local networking)
|
|
||||||
echo -n "Gateway: "
|
|
||||||
read gateway
|
|
||||||
|
|
||||||
# DNS Servers
|
|
||||||
echo -n "Primary DNS Server [$dns1_prev]: "
|
|
||||||
read dns1
|
|
||||||
test -z "$dns1" && test -n "$dns1_prev" && dns1=$dns1_prev
|
|
||||||
if [ ! -z "$dns1" ]; then
|
|
||||||
dns1_prev=$dns1
|
|
||||||
|
|
||||||
echo -n "Secondary DNS Server [$dns2_prev]: "
|
|
||||||
read dns2
|
|
||||||
if [ ! -z $dns2 ]; then
|
|
||||||
dns2_prev=$dns2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# If no primary DNS, then also no secondary DNS
|
|
||||||
dns2=""
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Find pci cards we know about
|
do_step3()
|
||||||
config_pci_cards
|
{
|
||||||
|
|
||||||
|
# We get here only if one of the ifconfig.if(5) files have changed.
|
||||||
|
changed="yes"
|
||||||
|
|
||||||
|
echo "
|
||||||
|
Do you want to configure additional interfaces?
|
||||||
|
|
||||||
|
You can also invoke the 'netconf' command as root at any later time.
|
||||||
|
|
||||||
|
1. Go back to interface selection
|
||||||
|
2. Quit
|
||||||
|
"
|
||||||
|
|
||||||
|
# Note that "quit" is deliberately the default choice: most people will
|
||||||
|
# want to configure at most one interface, and keep pressing Enter in
|
||||||
|
# order to make it through the setup procedure as easily as possible.
|
||||||
|
select_number 1 2 2 "Menu choice?"
|
||||||
|
|
||||||
|
[ $? -eq 1 ] && step=do_step1
|
||||||
|
}
|
||||||
|
|
||||||
# Parse options
|
# Parse options
|
||||||
while getopts ":qe:p:aH:i:n:g:d:s:hc" arg; do
|
while getopts "p:hl" arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
q) v=0; ;;
|
|
||||||
e) ethernet=$OPTARG;
|
|
||||||
test "$ethernet" -ge 0 -a "$ethernet" -le 7 2>/dev/null || usage
|
|
||||||
drv_params $ethernet
|
|
||||||
;;
|
|
||||||
p) prefix=$OPTARG; ;;
|
p) prefix=$OPTARG; ;;
|
||||||
a) dhcp="yes"; ;;
|
|
||||||
H) hostname=$OPTARG; manual_opts=`expr $manual_opts '+' 1`;;
|
|
||||||
i) ip=$OPTARG; manual_opts=`expr $manual_opts '+' 1`;;
|
|
||||||
n) netmask=$OPTARG; manual_opts=`expr $manual_opts '+' 1`;;
|
|
||||||
g) gateway=$OPTARG; manual_opts=`expr $manual_opts '+' 1`;;
|
|
||||||
d) dns1=$OPTARG; ;;
|
|
||||||
s) dns2=$OPTARG; ;;
|
|
||||||
h) usage ;;
|
h) usage ;;
|
||||||
c) echo -e "The following cards are supported by Minix:\n";
|
l) echo "The following network hardware interfaces are detected:"
|
||||||
cards; exit 0
|
echo
|
||||||
|
interfaces "configured"
|
||||||
|
exit 0
|
||||||
;;
|
;;
|
||||||
\?) echo "Unknown option -$OPTARG"; usage ;;
|
\?) echo "Unknown option -$OPTARG"; usage ;;
|
||||||
:) echo "Missing required argument for -$OPTARG"; usage ;;
|
:) echo "Missing required argument for -$OPTARG"; usage ;;
|
||||||
@ -321,28 +365,24 @@ while getopts ":qe:p:aH:i:n:g:d:s:hc" arg; do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Verify parameter count
|
|
||||||
if [ "$dhcp" != "yes" ] ; then
|
|
||||||
if [ $manual_opts -gt 0 ] ; then
|
|
||||||
test $manual_opts -eq 4 -a -n "$dns1" || usage
|
|
||||||
manual="do"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$prefix" ] ; then
|
if [ -n "$prefix" ] ; then
|
||||||
LOCALRC=$prefix$LOCALRC
|
if [ ! -d $prefix ]; then
|
||||||
INETCONF=$prefix$INETCONF
|
|
||||||
RCNET=$prefix$RCNET
|
|
||||||
HOSTS=$prefix$HOSTS
|
|
||||||
HOSTNAME=$prefix$HOSTNAME
|
|
||||||
if [ ! -f $INETCONF ]; then
|
|
||||||
echo -e "It seems the supplied prefix (\`$prefix') is invalid."
|
echo -e "It seems the supplied prefix (\`$prefix') is invalid."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
LOCALRC=$prefix$LOCALRC
|
||||||
|
IFCONF=$prefix$IFCONF
|
||||||
|
RESOLVCONF=$prefix$RESOLVCONF
|
||||||
|
HOSTNAME=$prefix$HOSTNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ `whoami` != root ] ; then
|
if [ `whoami` != root ] ; then
|
||||||
test "$v" = 1 && echo "Please run netconf as root."
|
echo "Please run netconf as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! ifconfig -l >/dev/null 2>&1; then
|
||||||
|
echo "Unable to obtain a list of interfaces. Is the LWIP service running?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -351,52 +391,25 @@ if [ -f "$USRKBFILE" ] ; then
|
|||||||
cd="yes" # We are running from CD
|
cd="yes" # We are running from CD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do we know what ethernet card to use?
|
# The interactive program.
|
||||||
test -z "$ethernet" && do_step1
|
step=do_step1
|
||||||
|
while [ $step != exit ]; do
|
||||||
|
proc=$step
|
||||||
|
step=exit
|
||||||
|
$proc
|
||||||
|
done
|
||||||
|
|
||||||
# If no parameters are supplied and we're not using DHCP, query for settings
|
# Skip printing this last bit of information if it will not actually work. The
|
||||||
test $manual_opts -eq 0 -a "$dhcp" = "no" && do_step2
|
# fact that it will not work on the CD (i.e. from the setup program) at least
|
||||||
|
# yet, is also the reason why we do not simply issue the command ourselves
|
||||||
# Store settings.
|
# right now. We might reconsider this later.
|
||||||
# Do not make backups if we're running from CD
|
if [ "$changed" = "yes" -a -z "$prefix" ]; then
|
||||||
test "$cd" != "yes" && test -f $INETCONF && mv $INETCONF "$INETCONF~" &&
|
echo
|
||||||
test "$v" = 1 && echo "Backed up $INETCONF to $INETCONF~"
|
echo "One or more of the interface configuration files have been changed."
|
||||||
test "$cd" != "yes" && test -f $LOCALRC && mv $LOCALRC "$LOCALRC~" &&
|
echo "You can use the command 'service network restart' to reload them now."
|
||||||
test "$v" = 1 && echo "Backed up $LOCALRC to $LOCALRC~"
|
|
||||||
|
|
||||||
if [ "$driver" = "psip0" ]; then
|
|
||||||
echo "psip0 { default; } ;" > $INETCONF
|
|
||||||
else
|
|
||||||
echo "eth0 $driver 0 { default; } ;" > $INETCONF
|
|
||||||
fi
|
|
||||||
echo "$driverargs" > $LOCALRC
|
|
||||||
|
|
||||||
if [ -n "$manual" ]
|
|
||||||
then
|
|
||||||
# Backup config file if it exists and we're not running from CD
|
|
||||||
test "$cd" != "yes" && test -f $RCNET && mv $RCNET "$RCNET~" &&
|
|
||||||
test "$v" = 1 && echo "Backed up $RCNET to $RCNET~"
|
|
||||||
test "$cd" != "yes" && test -f $HOSTS && mv $HOSTS "$HOSTS~" &&
|
|
||||||
test "$v" = 1 && echo "Backed up $HOSTS to $HOSTS~"
|
|
||||||
|
|
||||||
# Store manual config
|
|
||||||
echo "ifconfig -I /dev/ip0 -n $netmask -h $ip" > $RCNET
|
|
||||||
test ! -z $gateway && echo "add_route -g $gateway" >> $RCNET
|
|
||||||
echo "daemonize nonamed -L" >> $RCNET
|
|
||||||
test ! -z $dns1 && echo -e "$ip\t%nameserver\t#$hostname" > $HOSTS
|
|
||||||
test ! -z $dns1 && echo -e "$dns1\t%nameserver\t#DNS 1" >> $HOSTS
|
|
||||||
test ! -z $dns2 && echo -e "$dns2\t%nameserver\t#DNS 2" >> $HOSTS
|
|
||||||
echo -e "\n$ip\t$hostname" >> $HOSTS
|
|
||||||
echo $hostname > $HOSTNAME
|
|
||||||
else
|
|
||||||
test "$cd" != "yes" && test -f "$RCNET" && mv "$RCNET" "$RCNET~" &&
|
|
||||||
test "$v" = 1 && echo "Moved $RCNET to $RCNET~ to use default settings"
|
|
||||||
test "$cd" != "yes" && test -f $HOSTS && mv $HOSTS "$HOSTS~" &&
|
|
||||||
test "$v" = 1 && echo "Backed up $HOSTS to $HOSTS~"
|
|
||||||
test -f "$HOSTS~" && grep -v "%nameserver" "$HOSTS~" > $HOSTS
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
test "$cd" != "yes" && test "$v" = 1 && echo "
|
# Aesthetics.
|
||||||
You might have to reboot for the changes to take effect."
|
echo
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
service dp8390
|
service dp8390
|
||||||
{
|
{
|
||||||
|
type net;
|
||||||
|
descr "Realtek 8029 based card";
|
||||||
system
|
system
|
||||||
IRQCTL # 19
|
IRQCTL # 19
|
||||||
DEVIO # 21
|
DEVIO # 21
|
||||||
|
@ -8,9 +8,9 @@ created July 2013, JPEmbedded (info@jpembedded.eu)
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
* INSTALLATION: *
|
* INSTALLATION: *
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
To install LAN8710A for BeagleBone under MINIX you execute 'netconf' as
|
To configure LAN8710A for BeagleBone under MINIX you execute 'netconf' as
|
||||||
usual. Select the LAN8710A driver from the list. Restart the system
|
usual. If an interface 'cpsw0' is listed, the driver is running and you can
|
||||||
and the driver should work.
|
configure it however you wish.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
* TESTS: *
|
* TESTS: *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user