#!/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. default_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 } # set "ether" using $1 (interface name) as search key get_ether() { local key key=$1 ether="" set `ifconfig ${key}` while [ "$1" != "" ] ; do if [ "$1" = "ether" ] ; then ether=$2 break else shift fi done } # read content from /etc/hosts into an array (needed later in fetch_hostname) read_hosts() { local i a b c key junk i="" while read a b c junk ; do if [ "$a" = "#ethertable" ] ; then i=0 elif [ "$i" != "" -a "X$a" = "X#" -a "$b" != "" ] ; then eval eth_${i}=$b eval eth_host_${i}=$c i=$(($i+1)) fi done < /etc/hosts } # set "hostname" using $1 (ethernet address) as search key in /etc/hosts fetch_hostname() { local i b key key=$1 i=0 b="x" if [ "${eth_0}" = "" ] ; then read_hosts fi hostname="" while [ "$b" != "" -a "${hostname}" = "" ] ; do eval b=\${eth_${i}} case X${key} in X${b} ) # so we can use wildcards eval hostname=\${eth_host_${i}} break ;; esac i=$(($i+1)) done echo "fetch_hostname for <${key}> returns <${hostname}>" } # sets "mask" using $1 (netmask name) as the search key in /etc/networks fetch_mask() { local a b key junk key=$1 # search key, typically hostname-netmask mask="" while read a b junk; do # key mask otherstuff case X${key} in X${a} ) # we can use wildcards mask=$b break ;; esac done < /etc/networks if [ "${mask}" = "" ] ; then mask=${default_mask} fi echo "fetch_mask for <${key}> returns <${mask}>" } set_main_interface() { fetch_hostname ${main_ether} 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 fetch_mask ${hostname}-netmask eval ifconfig_${main_if}=\" \${hostname} netmask \${mask}\" network_interfaces=`ifconfig -l` } set_all_interfaces() { local i ether hostname mask for i in `ifconfig -l` ; do get_ether $i fetch_hostname ${ether} fetch_mask ${hostname}-netmask if [ "${ether}" != "" -a "${hostname}" != "" ] ; then eval ifconfig_${i}=\" \${hostname} netmask \${mask}\" fi done } rc_conf_set_defaults ### 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