Changeset 423fe6b in clfs-embedded for BOOK/bootscripts


Ignore:
Timestamp:
Sep 9, 2009, 3:35:48 PM (15 years ago)
Author:
Maarten Lankhorst <mlankhorst@…>
Branches:
master
Children:
884672b
Parents:
9a6cb5a
git-author:
Maarten Lankhorst <mlankhorst@…> (09/09/09 15:34:11)
git-committer:
Maarten Lankhorst <mlankhorst@…> (09/09/09 15:35:48)
Message:

add a udhcpc.conf script to make udhcpc actually useful

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BOOK/bootscripts/common/network.xml

    r9a6cb5a r423fe6b  
    4242
    4343# set to gateway IP address
    44 GATEWAY=192.168.0.1</literal>
     44GATEWAY=192.168.0.1
     45
     46# Interfaces to add to br0 bridge
     47# Leave commented to not setup a network bridge
     48# Substitute br0 for eth0 in the interface.eth0 sample below to bring up br0
     49# instead
     50# bcm47xx with vlans:
     51#BRIDGE_INTERFACES="eth0.0 eth0.1 wlan0"
     52# Other access point with a wired eth0 and a wireless wlan0 interface:
     53#BRIDGE_INTERFACES="eth0 wlan0"
     54</literal>
    4555EOF</userinput></screen>
    4656
     
    8797    Broadcast Address for the Subnet Mask of the IP Range being used on
    8898    this interface.</para>
     99
     100  </sect2>
     101
     102  <sect2 id="udhcpc.conf">
     103    <title>Creating the ${CLFS}/etc/udhcpc.conf File</title>
     104
     105    <indexterm zone="udhcpc.conf">
     106      <primary sortas="e-/etc/udhcpc.conf">/etc/udhcpc.conf</primary>
     107    </indexterm>
     108
     109    <para>For DHCP to work properly a configuration script is needed.
     110    Create a sample udhcpc.conf:</para>
     111
     112<screen><userinput>mkdir ${CLFS}/etc/network.d &amp;&amp;
     113cat &gt; ${CLFS}/etc/network.d/interface.eth0 &lt;&lt; "EOF"
     114<literal>#!/bin/sh
     115# udhcpc Interface Configuration
     116# Based on http://lists.debian.org/debian-boot/2002/11/msg00500.html
     117# udhcpc script edited by Tim Riker &lt;Tim@Rikers.org&gt;
     118
     119[ -z "$1" ] &amp;&amp; echo "Error: should be called from udhcpc" &amp;&amp; exit 1
     120
     121RESOLV_CONF="/etc/resolv.conf"
     122RESOLV_BAK="/etc/resolv.bak"
     123
     124[ -n "$broadcast" ] &amp;&amp; BROADCAST="broadcast $broadcast"
     125[ -n "$subnet" ] &amp;&amp; NETMASK="netmask $subnet"
     126
     127case "$1" in
     128        deconfig)
     129                if [ -f "$RESOLV_BAK" ]; then
     130                        mv "$RESOLV_BAK" "$RESOLV_CONF"
     131                fi
     132                /sbin/ifconfig $interface 0.0.0.0
     133                ;;
     134
     135        renew|bound)
     136                /sbin/ifconfig $interface $ip $BROADCAST $NETMASK
     137
     138                if [ -n "$router" ] ; then
     139                        while route del default gw 0.0.0.0 dev $interface ; do
     140                                true
     141                        done
     142
     143                        for i in $router ; do
     144                                route add default gw $i dev $interface
     145                        done
     146                fi
     147
     148                if [ ! -f "$RESOLV_BAK" ] &amp;&amp; [ -f "$RESOLV_CONF" ]; then
     149                        mv "$RESOLV_CONF" "$RESOLV_BAK"
     150                fi
     151
     152                echo -n &gt; $RESOLV_CONF
     153                [ -n "$domain" ] &amp;&amp; echo search $domain &gt;&gt; $RESOLV_CONF
     154                for i in $dns ; do
     155                        echo nameserver $i &gt;&gt; $RESOLV_CONF
     156                done
     157                ;;
     158esac
     159
     160exit 0
     161</literal>EOF
     162
     163chmod +x ${CLFS}/etc/udhcpc.conf</userinput></screen>
    89164
    90165  </sect2>
Note: See TracChangeset for help on using the changeset viewer.