summaryrefslogtreecommitdiffstats
path: root/release/picobsd/floppy.tree/etc/rc.conf.defaults
blob: 8b8bdf3f0e96ea6a79bc89aaa7adf27f07ab1812 (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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/bin/sh
# $FreeBSD$
#
# rc.conf for picobsd. This is sourced from /etc/rc1, and is supposed to
# contain only shell functions that are used later in /etc/rc1.

# set default values for variables. Boolean values should be either
# NO or YES -- other values are not guaranteed to work.

rc_conf_set_defaults() {
hostname=""			# Should not need to set it
syslogd_enable="NO"
pccard_enable="NO"
swapfile=""			# name of swapfile if aux swapfile desired.

# Network interface configurations: ifconfig_${interface}[_aliasNN]
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: they are only run if present.
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"

### Other network features
firewall_enable="NO"
firewall_quiet="NO"		# be quiet if set.
firewall_type=""		# Standard types or absolute pathname.
tcp_extensions="NO"		# Allow RFC1323 & RFC1644 extensions (or NO).

### Overrides for some files in /etc. Leave empty if no override,
### set variable (remember to use multiple lines) to override content.

host_conf="hosts
bind"
resolv_conf=""
}

# Try to identify the system by using the MAC address and name of the
# first ethernet interface, made available as $main_eth $main_if
find_system_id() {
    main_ether=""
    for main_if in `ifconfig -l` ; do
	set `ifconfig $main_if`
	while [ "$1" != "" ] ; do
	    if [ $1 = "ether" ] ; then
		main_ether=$2
		break 2
	    else
		shift
	    fi
	done
    done
}

# 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 [ "${hostname}" != "" ] ; 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 a couple of arrays
# (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 "$a" = "#" -a "$b" != "" ] ; then
            eval eth_${i}=$b
            eval eth_host_${i}=$c
            i=$(($i+1))
        fi
    done < /etc/hosts
}

# set ${hostname} using $1 (MAC address) as search key in /etc/hosts
# Returns empty value if $1 is empty
fetch_hostname() {
    local i b key
    hostname=""
    [ "$1" = "" ] && return
    key=$1
    i=0
    b="x"
    [ "${eth_0}" = "" ] && read_hosts # fill cache.
    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} )	# The X is so we can use wildcards in ${a}
	    mask=$b
	    break
	    ;;
	esac
    done < /etc/networks
    if [ "${mask}" = "" ] ; then
	mask=${default_mask}
    fi
    echo "fetch_mask for <${key}> returns <${mask}>"
}

# set hostname, and ifconfig_${main_if} (whose MAC is ${main_ether})
# if not found, read from console
set_main_interface() {
    if [ -z "${hostname}" ] ; then
	if [ -z "${main_ether}" ] ; then
	    echo "No ethernets found, using localhost"
	    hostname=localhost
	    return
	fi
	fetch_hostname ${main_ether}
    fi

    [ -z "${hostname}" -o "${hostname}" = "." ] && read_address
    
    fetch_mask ${hostname}-netmask

    eval ifconfig_${main_if}=\" \${hostname} netmask \${mask}\"
    network_interfaces=`ifconfig -l`
}

# set ifconfig_${interface} for all other interfaces
set_all_interfaces() {
    local i ether hostname mask

    for i in `ifconfig -l` ; do
	if [ "$i" != "${main_if}" ] ; then
	    get_ether $i
	    fetch_hostname ${ether}
	    fetch_mask ${hostname}-netmask
	    [ -n "${ether}" -a -n "${hostname}" ] && \
		eval ifconfig_${i}=\" \${hostname} netmask \${mask}\"
	fi
    done
}
OpenPOWER on IntegriCloud