blob: 67477bd22f40a957654ed56b561c7afb7eb247d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
#!/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
}
# set "hostname" using $1 (ethernet address) as search key in /etc/hosts
fetch_hostname() {
local a b c key
key=$1 # search key
hostname=""
while read a b c ; do
if [ "$a" = "#ethertable" ] ; then
hostname="."
elif [ "X$hostname" = "X." -a "X$a" = "X#" ] ; then
case X${key} in
X${b} ) # so we can use wildcards
hostname=$c
break
;;
esac
fi
done < /etc/hosts
}
# sets "mask" using $1 (netmask name) as the search key in /etc/networks
fetch_mask() {
local a b c key
key=$1 # search key, typically hostname-netmask
mask=""
while read a b c; do # key mask otherstuff
case X${key} in
X${a} ) # we can use wildcards
mask=$b
break
;;
esac
done < /etc/networks
}
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
if [ "${mask}" = "" ] ; then
mask=${default_mask}
fi
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
|