rc.conf revision 85494
1#!/bin/sh
2# $FreeBSD: head/release/picobsd/floppy.tree/etc/rc.conf 85494 2001-10-25 17:40:03Z luigi $
3#
4# rc.conf for picobsd.
5# $main_ether and $main_if are set from rc to the ethernet address and
6# name of the first ethernet interface, if available, so a simple
7# here-document below can be used for autoconfiguration.
8# Remaining parameters are set using a switch.
9
10rc_conf_set_defaults() {
11syslogd_enable="NO"
12pccard_enable="NO"
13swapfile="NO"		# Set to name of swapfile if aux swapfile desired.
14firewall_enable="NO"		# firewall type (see /etc/rc.firewall) or NO
15tcp_extensions="NO"		# Allow RFC1323 & RFC1644 extensions (or NO).
16ifconfig_lo0="inet 127.0.0.1"	# default loopback device configuration.
17#ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
18### Network daemons options: ###
19sshd_enable="YES"		# if present...
20inetd_enable="YES"		# Run the network daemon dispatcher (or NO)
21inetd_flags=""			# Optional flags to inetd
22snmpd_enable="NO"		# Run the SNMP daemon (or NO)
23snmpd_flags="-C -c /etc/snmpd.conf"	# Optional flags to snmpd
24### Network routing options: ###
25defaultrouter="NO"		# Set to default gateway (or NO).
26static_routes=""		# Set to static route list (or leave empty).
27gateway_enable="NO"		# Set to YES if this host will be a gateway.
28arpproxy_all=""			# replaces obsolete kernel option ARP_PROXYALL.
29default_mask="0xffffff00"
30}
31
32# the following lets the user specify a name and ip for his system
33read_address() {
34    echo "Please enter a hostname and IP address for your system $main_ether"
35    read hostname the_ip
36    if [ "X$hostname" != "X" ] ; then
37	echo "# $main_ether $hostname" >> /etc/hosts
38	echo "$the_ip $hostname" >> /etc/hosts
39    else
40	hostname=default
41    fi
42}
43
44# set "ether" using $1 (interface name) as search key
45get_ether() {
46    local key
47    key=$1
48    ether=""
49    set `ifconfig ${key}`
50    while [ "$1" != "" ] ; do
51    if [ "$1" = "ether" ] ; then
52	ether=$2
53	break
54    else
55	shift
56    fi
57    done
58}
59
60# set "hostname" using $1 (ethernet address) as search key in /etc/hosts
61fetch_hostname() {
62    local a b c key junk
63    key=$1     # search key
64    hostname=""
65    while read a b c junk ; do
66    if [ "$a" = "#ethertable" ] ; then
67	hostname="."
68    elif [ "X$hostname" = "X." -a "X$a" = "X#" ] ; then
69	case X${key} in
70	X${b} ) # so we can use wildcards
71	    hostname=$c
72	    break
73	    ;;
74	esac
75    fi
76    done < /etc/hosts
77    echo "fetch_hostname for <${key}> returns <${hostname}>"
78}
79
80# sets "mask" using $1 (netmask name) as the search key in /etc/networks
81fetch_mask() {
82    local a b c key
83    key=$1     # search key, typically hostname-netmask
84    mask=""
85    while read a b c; do # key mask otherstuff
86	case X${key} in
87	X${a} ) # we can use wildcards
88	    mask=$b
89	    break
90	    ;;
91	esac
92    done < /etc/networks
93    if [ "${mask}" = "" ] ; then
94	mask=${default_mask}
95    fi
96    echo "fetch_mask for <${key}> returns <${mask}>"
97}
98
99
100set_main_interface() {
101    fetch_hostname ${main_ether}
102
103    if [ "X$hostname" = "X" -o "X$hostname" = "X." ] ; then
104	if [ "X$main_ether" = "X" ] ; then
105	    echo "No ethernets found, using localhost"
106	    hostname=localhost
107	else
108	    read_address
109	fi
110    fi
111    fetch_mask ${hostname}-netmask
112
113    eval ifconfig_${main_if}=\" \${hostname} netmask \${mask}\"
114    network_interfaces=`ifconfig -l`
115}
116
117set_all_interfaces() {
118    local i ether hostname mask
119
120    for i in `ifconfig -l` ; do
121	get_ether $i
122	fetch_hostname ${ether}
123	fetch_mask ${hostname}-netmask
124	if [ "${ether}" != "" -a "${hostname}" != "" ] ; then
125	    eval ifconfig_${i}=\" \${hostname} netmask \${mask}\"
126	fi
127    done
128}
129
130rc_conf_set_defaults
131
132### Allow local configuration override at the very end here ##
133### can make use of a case statement to set per-host things.
134if [ -f /etc/rc.conf.local ]; then
135	. /etc/rc.conf.local
136fi
137