e8b19bc63e
/etc/hosts to map MAC addresses to hostnames. Main use is to get addresses for vmware interfaces.
76 lines
2.4 KiB
Bash
76 lines
2.4 KiB
Bash
#!/bin/sh
|
|
# $FreeBSD$
|
|
#
|
|
# rc.conf for picobsd.
|
|
# $main_ether and $main_if are set from rc to the ethernet address and
|
|
# name of the first ethernet interface, if available, so a simple
|
|
# here-document below can be used for autoconfiguration.
|
|
# Remaining parameters are set using a switch.
|
|
|
|
rc_conf_set_defaults() {
|
|
syslogd_enable="NO"
|
|
pccard_enable="NO"
|
|
swapfile="NO" # Set to name of swapfile if aux swapfile desired.
|
|
firewall_enable="NO" # firewall type (see /etc/rc.firewall) or NO
|
|
tcp_extensions="NO" # Allow RFC1323 & RFC1644 extensions (or NO).
|
|
ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration.
|
|
#ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
|
|
### Network daemons options: ###
|
|
sshd_enable="YES" # if present...
|
|
inetd_enable="YES" # Run the network daemon dispatcher (or NO)
|
|
inetd_flags="" # Optional flags to inetd
|
|
snmpd_enable="NO" # Run the SNMP daemon (or NO)
|
|
snmpd_flags="-C -c /etc/snmpd.conf" # Optional flags to snmpd
|
|
### Network routing options: ###
|
|
defaultrouter="NO" # Set to default gateway (or NO).
|
|
static_routes="" # Set to static route list (or leave empty).
|
|
gateway_enable="NO" # Set to YES if this host will be a gateway.
|
|
arpproxy_all="" # replaces obsolete kernel option ARP_PROXYALL.
|
|
mask="0xffffff00"
|
|
}
|
|
|
|
# the following lets the user specify a name and ip for his system
|
|
read_address() {
|
|
echo "Please enter a hostname and IP address for your system $main_ether"
|
|
read hostname the_ip
|
|
if [ "X$hostname" != "X" ] ; then
|
|
echo "# $main_ether $hostname" >> /etc/hosts
|
|
echo "$the_ip $hostname" >> /etc/hosts
|
|
else
|
|
hostname=default
|
|
fi
|
|
}
|
|
|
|
rc_conf_set_defaults
|
|
|
|
hostname=""
|
|
while read a b c ; do
|
|
if [ "$a" = "#ethertable" ] ; then
|
|
hostname="."
|
|
elif [ "X$hostname" = "X." -a "X$a" = "X#" ] ; then
|
|
case X${main_ether} in
|
|
X${b} ) # so we can use wildcards
|
|
hostname=$c
|
|
break
|
|
;;
|
|
esac
|
|
fi
|
|
done < /etc/hosts
|
|
if [ "X$hostname" = "X" -o "X$hostname" = "X." ] ; then
|
|
if [ "X$main_ether" = "X" ] ; then
|
|
echo "No ethernets found, using localhost"
|
|
hostname=localhost
|
|
else
|
|
read_address
|
|
fi
|
|
fi
|
|
|
|
eval ifconfig_${main_if}=\" \$hostname netmask \$mask\"
|
|
network_interfaces=`ifconfig -l`
|
|
|
|
### Allow local configuration override at the very end here ##
|
|
### can make use of a case statement to set per-host things.
|
|
if [ -f /etc/rc.conf.local ]; then
|
|
. /etc/rc.conf.local
|
|
fi
|