diff options
-rw-r--r-- | release/picobsd/floppy.tree/etc/rc.conf | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/release/picobsd/floppy.tree/etc/rc.conf b/release/picobsd/floppy.tree/etc/rc.conf index 2926b09..40e88d1 100644 --- a/release/picobsd/floppy.tree/etc/rc.conf +++ b/release/picobsd/floppy.tree/etc/rc.conf @@ -48,43 +48,61 @@ get_ether() { ether="" set `ifconfig ${key}` while [ "$1" != "" ] ; do - if [ "$1" = "ether" ] ; then - ether=$2 - break - else - shift - fi + if [ "$1" = "ether" ] ; then + ether=$2 + break + else + shift + fi done } +# read content from /etc/hosts into an array (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 "X$a" = "X#" -a "$b" != "" ] ; then + eval eth_${i}=$b + eval eth_host_${i}=$c + i=$(($i+1)) + fi + done < /etc/hosts +} + # set "hostname" using $1 (ethernet address) as search key in /etc/hosts fetch_hostname() { - local a b c key junk - key=$1 # search key - hostname="" - while read a b c junk ; 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 + local i b key + key=$1 + i=0 + b="x" + if [ "${eth_0}" = "" ] ; then + read_hosts fi - done < /etc/hosts + hostname="" + 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 c key - key=$1 # search key, typically hostname-netmask + local a b key junk + key=$1 # search key, typically hostname-netmask mask="" - while read a b c; do # key mask otherstuff + while read a b junk; do # key mask otherstuff case X${key} in - X${a} ) # we can use wildcards + X${a} ) # we can use wildcards mask=$b break ;; |