Sync with FreeBSD. This removes the need for perl.
[dragonfly.git] / release / picobsd / floppy.tree / etc / rc.conf.defaults
1 #!/bin/sh
2 # $FreeBSD: src/release/picobsd/floppy.tree/etc/rc.conf.defaults,v 1.1.2.2 2002/03/09 18:27:39 luigi Exp $
3 # $DragonFly: src/release/picobsd/floppy.tree/etc/Attic/rc.conf.defaults,v 1.2 2003/06/17 04:27:20 dillon Exp $
4 #
5 # rc.conf for picobsd. This is sourced from /etc/rc1, and is supposed to
6 # contain only shell functions that are used later in /etc/rc1.
7
8 # set default values for variables. Boolean values should be either
9 # NO or YES -- other values are not guaranteed to work.
10
11 rc_conf_set_defaults() {
12 hostname=""                     # Should not need to set it
13 syslogd_enable="NO"
14 pccard_enable="NO"
15 swapfile=""                     # name of swapfile if aux swapfile desired.
16
17 # Network interface configurations: ifconfig_${interface}[_aliasNN]
18 ifconfig_lo0="inet 127.0.0.1"   # default loopback device configuration.
19 #ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry.
20
21 ### Network daemons options: they are only run if present.
22 sshd_enable="YES"               # if present...
23 inetd_enable="YES"              # Run the network daemon dispatcher (or NO)
24 inetd_flags=""                  # Optional flags to inetd
25 snmpd_enable="NO"               # Run the SNMP daemon (or NO)
26 snmpd_flags="-C -c /etc/snmpd.conf"     # Optional flags to snmpd
27
28 ### Network routing options: ###
29 defaultrouter="NO"              # Set to default gateway (or NO).
30 static_routes=""                # Set to static route list (or leave empty).
31 gateway_enable="NO"             # Set to YES if this host will be a gateway.
32 arpproxy_all=""                 # replaces obsolete kernel option ARP_PROXYALL.
33 default_mask="0xffffff00"
34
35 ### Other network features
36 firewall_enable="NO"
37 firewall_quiet="NO"             # be quiet if set.
38 firewall_type=""                # Standard types or absolute pathname.
39 tcp_extensions="NO"             # Allow RFC1323 & RFC1644 extensions (or NO).
40
41 ### Overrides for some files in /etc. Leave empty if no override,
42 ### set variable (remember to use multiple lines) to override content.
43
44 host_conf="hosts
45 bind"
46 resolv_conf=""
47 }
48
49 # Try to identify the system by using the MAC address and name of the
50 # first ethernet interface, made available as $main_eth $main_if
51 find_system_id() {
52     main_ether=""
53     for main_if in `ifconfig -l` ; do
54         set `ifconfig $main_if`
55         while [ "$1" != "" ] ; do
56             if [ $1 = "ether" ] ; then
57                 main_ether=$2
58                 break 2
59             else
60                 shift
61             fi
62         done
63     done
64 }
65
66 # the following lets the user specify a name and ip for his system
67 read_address() {
68     echo "Please enter a hostname and IP address for your system $main_ether"
69     read hostname the_ip
70     if [ "${hostname}" != "" ] ; then
71         echo "# $main_ether $hostname" >> /etc/hosts
72         echo "$the_ip $hostname" >> /etc/hosts
73     else
74         hostname=default
75     fi
76 }
77
78 # set "ether" using $1 (interface name) as search key
79 get_ether() {
80     local key
81     key=$1
82     ether=""
83     set `ifconfig ${key}`
84     while [ "$1" != "" ] ; do
85         if [ "$1" = "ether" ] ; then
86             ether=$2
87             break
88         else
89             shift
90         fi
91     done
92 }
93
94 # read content from /etc/hosts into a couple of arrays
95 # (needed later in fetch_hostname)
96 read_hosts() {
97     local i a b c key junk
98     i=""
99     while read a b c junk ; do
100         if [ "$a" = "#ethertable" ] ; then
101             i=0
102         elif [ "$i" != "" -a "$a" = "#" -a "$b" != "" ] ; then
103             eval eth_${i}=$b
104             eval eth_host_${i}=$c
105             i=$(($i+1))
106         fi
107     done < /etc/hosts
108 }
109
110 # set ${hostname} using $1 (MAC address) as search key in /etc/hosts
111 # Returns empty value if $1 is empty
112 fetch_hostname() {
113     local i b key
114     hostname=""
115     [ "$1" = "" ] && return
116     key=$1
117     i=0
118     b="x"
119     [ "${eth_0}" = "" ] && read_hosts # fill cache.
120     while [ "$b" != "" -a "${hostname}" = "" ] ; do
121         eval b=\${eth_${i}}
122         case X${key} in
123         X${b} ) # so we can use wildcards
124             eval hostname=\${eth_host_${i}}
125             break
126             ;;
127         esac
128         i=$(($i+1))
129     done
130     echo "fetch_hostname for <${key}> returns <${hostname}>"
131 }
132
133 # sets "mask" using $1 (netmask name) as the search key in /etc/networks
134 fetch_mask() {
135     local a b key junk
136     key=$1      # search key, typically hostname-netmask
137     mask=""
138     while read a b junk; do # key mask otherstuff
139         case X${key} in
140         X${a} ) # The X is so we can use wildcards in ${a}
141             mask=$b
142             break
143             ;;
144         esac
145     done < /etc/networks
146     if [ "${mask}" = "" ] ; then
147         mask=${default_mask}
148     fi
149     echo "fetch_mask for <${key}> returns <${mask}>"
150 }
151
152 # set hostname, and ifconfig_${main_if} (whose MAC is ${main_ether})
153 # if not found, read from console
154 set_main_interface() {
155     if [ -z "${hostname}" ] ; then
156         if [ -z "${main_ether}" ] ; then
157             echo "No ethernets found, using localhost"
158             hostname=localhost
159             return
160         fi
161         fetch_hostname ${main_ether}
162     fi
163
164     [ -z "${hostname}" -o "${hostname}" = "." ] && read_address
165     
166     fetch_mask ${hostname}-netmask
167
168     eval ifconfig_${main_if}=\" \${hostname} netmask \${mask}\"
169     network_interfaces=`ifconfig -l`
170 }
171
172 # set ifconfig_${interface} for all other interfaces
173 set_all_interfaces() {
174     local i ether hostname mask
175
176     for i in `ifconfig -l` ; do
177         if [ "$i" != "${main_if}" ] ; then
178             get_ether $i
179             fetch_hostname ${ether}
180             fetch_mask ${hostname}-netmask
181             [ -n "${ether}" -a -n "${hostname}" ] && \
182                 eval ifconfig_${i}=\" \${hostname} netmask \${mask}\"
183         fi
184     done
185 }