ADAPTATION rc.d script

  • Main task to make all board depended names to much ZRouter.org standard names:
    1. wan0 - name for default WAN interface (Example: ifconfig vlan0 name wan0)
    2. lan0 - default LAN interface
    3. wifi0 - wireless main device from which VAPs will be cloned (ath0, bwn0, ral0, etc)
  • Preset GPIO pins (f.e. Invert Input on some GPIO pin and request interrupt reporting via devd)
  • Import, apply MAC addresses if required (many device has no EEPROMs for their NICs)
  • Set device hostname
#!/bin/sh

# PROVIDE: ADAPTATION

. /etc/rc.subr
. /etc/network.subr

name="ADAPTATION" 
start_cmd="adapt_start" 

adapt_start()
{

    # Ethernet switch setup here 
    gpioctl -f /dev/gpioc0 -c 10 IN II PU INT

    # Import MAC addresses with known names
#    kenv LAN_MAC_ADDR=`kenv ethaddr`
#    kenv WAN_MAC_ADDR=`kenv wanmac`

    ifconfig arge0 name lan0
    ifconfig arge1 name wan0
    ifconfig ath0 name wifi0

    ifconfig lan0 ether `kenv LAN_MAC_ADDR`
    ifconfig wan0 ether `kenv WAN_MAC_ADDR`
#    ifconfig wifi0 ether `kenv WLAN_MAC_ADDR`

    hostname `kenv HostName`

}

load_rc_config $name

run_rc_command $*