rc.conf revision 84432
1#!/bin/sh 2# $FreeBSD: head/release/picobsd/floppy.tree/etc/rc.conf 84432 2001-10-04 00:46:44Z 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 63 key=$1 # search key 64 hostname="" 65 while read a b c ; 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} 78 79# sets "mask" using $1 (netmask name) as the search key in /etc/networks 80fetch_mask() { 81 local a b c key 82 key=$1 # search key, typically hostname-netmask 83 mask="" 84 while read a b c; do # key mask otherstuff 85 case X${key} in 86 X${a} ) # we can use wildcards 87 mask=$b 88 break 89 ;; 90 esac 91 done < /etc/networks 92} 93 94 95set_main_interface() { 96 fetch_hostname ${main_ether} 97 98 if [ "X$hostname" = "X" -o "X$hostname" = "X." ] ; then 99 if [ "X$main_ether" = "X" ] ; then 100 echo "No ethernets found, using localhost" 101 hostname=localhost 102 else 103 read_address 104 fi 105 fi 106 fetch_mask ${hostname}-netmask 107 if [ "${mask}" = "" ] ; then 108 mask=${default_mask} 109 fi 110 111 eval ifconfig_${main_if}=\" \${hostname} netmask \${mask}\" 112 network_interfaces=`ifconfig -l` 113} 114 115set_all_interfaces() { 116 local i ether hostname mask 117 118 for i in `ifconfig -l` ; do 119 get_ether $i 120 fetch_hostname ${ether} 121 fetch_mask ${hostname}-netmask 122 if [ "${ether}" != "" -a "${hostname}" != "" ] ; then 123 eval ifconfig_${i}=\" \${hostname} netmask \${mask}\" 124 fi 125 done 126} 127 128rc_conf_set_defaults 129 130### Allow local configuration override at the very end here ## 131### can make use of a case statement to set per-host things. 132if [ -f /etc/rc.conf.local ]; then 133 . /etc/rc.conf.local 134fi 135