wap54g support
authormbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 7 Sep 2004 05:54:07 +0000 (05:54 +0000)
committermbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Tue, 7 Sep 2004 05:54:07 +0000 (05:54 +0000)
separate S50services into individual files
move nvram_get to 'nvram get' making nvram overrides more transparent

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@155 3c298f89-4303-0410-b956-a3cf2f4a3e73

16 files changed:
obsolete-buildroot/sources/openwrt/root/etc/functions.sh
obsolete-buildroot/sources/openwrt/root/etc/init.d/S10boot
obsolete-buildroot/sources/openwrt/root/etc/init.d/S40network
obsolete-buildroot/sources/openwrt/root/etc/init.d/S45firewall
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50dnsmasq [new file with mode: 0755]
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50httpd [new file with mode: 0755]
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50services [deleted file]
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50telnet [new file with mode: 0755]
obsolete-buildroot/sources/openwrt/root/etc/init.d/S99done
obsolete-buildroot/sources/openwrt/root/etc/ipkg.conf
obsolete-buildroot/sources/openwrt/root/etc/nvram.overrides
obsolete-buildroot/sources/openwrt/root/etc/preinit
obsolete-buildroot/sources/openwrt/root/etc/profile
obsolete-buildroot/sources/openwrt/root/sbin/ifdown
obsolete-buildroot/sources/openwrt/root/sbin/ifup
obsolete-buildroot/sources/openwrt/root/sbin/wifi

index 79db1da..6da7df2 100755 (executable)
@@ -3,8 +3,11 @@
 alias debug=${DEBUG:-:}
 
 # allow env to override nvram
-nvram_get () {
- eval "echo \${$1:-\$(nvram get $1)}"
+nvram () {
+  case $1 in
+    get) eval "echo \${NVRAM_$2:-\$(command nvram get $2)}";;
+    *) command nvram $*;;
+  esac
 }
 . /etc/nvram.overrides
 
@@ -12,8 +15,8 @@ nvram_get () {
 if_valid () (
   [ "${1%%[0-9]}" = "vlan" ] && {
     i=${1#vlan}
-    hwname=$(nvram_get vlan${i}hwname)
-    hwaddr=$(nvram_get ${hwname}macaddr)
+    hwname=$(nvram get vlan${i}hwname)
+    hwaddr=$(nvram get ${hwname}macaddr)
     [ -z "$hwaddr" ] && return 1
 
     vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
index 0d8f2e2..b650c94 100755 (executable)
@@ -1,14 +1,14 @@
 #!/bin/sh
+syslogd -C 16 
 sysctl -p
 echo "S" > /proc/jffs2_bbc
 
 mkdir -p /var/run
 
-# networking stub
 [ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
-  # force unique wireless mac
+  # if default wifi mac, set two higher than the lan mac
   nvram set il0macaddr=$(nvram get et0macaddr|
-  awk '{OFS=FS=":";for(x=6,y=2;x;x--){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
+  awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
 }
 
 insmod et
@@ -18,12 +18,7 @@ ifconfig lo 127.0.0.1 up
 ifconfig eth0 promisc
 
 HOSTNAME=$(nvram get wan_hostname)
-DOMAINNAME=${HOSTNAME##*.}
 HOSTNAME=${HOSTNAME%%.*}
-
 echo ${HOSTNAME:=OpenWrt} > /proc/sys/kernel/hostname
-echo ${DOMAINNAME:=lan}   > /proc/sys/kernel/domainname
 
 vconfig set_name_type VLAN_PLUS_VID_NO_PAD
-
-syslogd -C 16 
index 5a6ca72..a8144a8 100755 (executable)
@@ -7,9 +7,9 @@ case "$1" in
     ifup wifi
     wifi up
 
-    for route in $(nvram_get static_route); do {
+    for route in $(nvram get static_route); do {
       eval "set $(echo $route | sed 's/:/ /g')"
-      route add -net $1 netmask $2 gw $3 metric $4 dev $5
+      $DEBUG route add -net $1 netmask $2 gw $3 metric $4 dev $5
     } done
     ;;
 esac
index 4885c7c..49b9df0 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 . /etc/functions.sh
 
-WAN=$(nvram_get wan_ifname)
+WAN=$(nvram get wan_ifname)
 
 IPT=/usr/sbin/iptables
 
diff --git a/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50dnsmasq b/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50dnsmasq
new file mode 100755 (executable)
index 0000000..995c1b6
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/dnsmasq
diff --git a/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50httpd b/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50httpd
new file mode 100755 (executable)
index 0000000..fd66f80
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/httpd -p 80 -h /www -r WRT54G Router
diff --git a/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50services b/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50services
deleted file mode 100755 (executable)
index bdd1102..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-/usr/sbin/telnetd -l /bin/login
-/usr/sbin/httpd -p 80 -h /www -r WRT54G Router
-/usr/sbin/dnsmasq
diff --git a/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50telnet b/obsolete-buildroot/sources/openwrt/root/etc/init.d/S50telnet
new file mode 100755 (executable)
index 0000000..29af504
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/telnetd -l /bin/login
index 73a4da4..8811e99 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
+# automagically run firstboot
 [ -z "$FAILSAFE" ] && {
        { mount | grep jffs2 1>&-; } || firstboot
 }
-# turn off DMZ led
+# set leds to normal state
 echo "0x00" > /proc/sys/diag
index c3581d7..31a5fdf 100644 (file)
@@ -1,3 +1,3 @@
-src openwrt http://openwrt.ksilebo.net/ipkg
+src openwrt http://openwrt.org/ipkg
 dest root /
 dest ram /tmp
index f59e780..e3a3217 100644 (file)
@@ -1,53 +1,60 @@
 # NVRAM overrides
-# This file handles the NVRAM quirks of various hardware.
 #
+# This file handles the NVRAM quirks of various hardware.
 # THIS FILE IS NOT A REPLACEMENT FOR NVRAM
 
-# linksys bug has lan doing dhcp; force static
-lan_proto="static"
+# linksys bug; remove when not using static configuration for lan
+NVRAM_lan_proto="static"
 
-# hacks for 1.x hardware
+# hacks for wrt54g 1.x hardware
 [ "$(nvram get boardnum)"  = "42" ] && \
 [ "$(nvram get boardtype)" = "bcm94710dev" ] && {
-  debug "### 1.x hardware hack ###"
-  vlan1hwname="et0"
-  vlan2hwname="et0"
-
-  # we remap old device names to new
-  # it's recommended that you continue to
-  # use the old names to preserve backwards
-  # compatibility
+
+  # remap eth0 => vlan2, eth1 => vlan1
+  # for all *_ifname(s)
+
+  debug "### wrt54g 1.x hack ###"
+  NVRAM_vlan1hwname="et0"
+  NVRAM_vlan2hwname="et0"
+
   remap () {
-    eval $1=\"$(nvram_get $1 | awk 'gsub("eth0","vlan2") gsub("eth1","vlan1")')\"
+    eval NVRAM_$1=\"$(nvram get $1 | awk 'gsub("eth0","vlan2") gsub("eth1","vlan1")')\"
   }
 
-  remap lan_ifname
-  remap lan_ifnames
-  remap wifi_ifname
-  remap wifi_ifnames
-  remap wan_ifname
-  remap wan_ifnames
-  remap pppoe_ifname
+  for type in lan wifi wan pppoe
+  do
+  remap ${type}_ifname
+  remap ${type}_ifnames
+  done
+}
+
+# hacks for wap54g hardware
+[ "$(nvram get boardnum)"  = "2" ] || \
+[ "$(nvram get boardnum)"  = "1024" ] && {
+  debug "### wap54g hack ###"
+  NVRAM_wan_ifname="none"
 }
 
-[ -z "$(nvram_get lan_ifname)" ] && {
-  lan_ifname="br0"
-  lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
+# defaults if lan_ifname is missing
+[ -z "$(nvram get lan_ifname)" ] && {
+  NVRAM_lan_ifname="br0"
+  NVRAM_lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
 }
 
-[ -z "$(nvram_get wan_ifname)" ] && {
-   wan_ifname="vlan1"
-   wan_proto="dhcp"
+# defaults if wan_ifname is missing
+[ -z "$(nvram get wan_ifname)" ] && {
+   NVRAM_wan_ifname="vlan1"
+   NVRAM_wan_proto="dhcp"
 }
 
 # failsafe if reset is held
 [ "$FAILSAFE" = "true" ] && {
   echo "### FAILSAFE MODE ####"
-  lan_ifname="br0"
-  lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
-  lan_ipaddr="192.168.1.1"
-  lan_netmask="255.255.255.0"
-  lan_hwaddr="00:0B:AD:0A:DD:00"
-  wan_ifname="none"
-  wifi_ifname="none"
+  NVRAM_lan_ifname="br0"
+  NVRAM_lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
+  NVRAM_lan_ipaddr="192.168.1.1"
+  NVRAM_lan_netmask="255.255.255.0"
+  NVRAM_lan_hwaddr="00:0B:AD:0A:DD:00"
+  NVRAM_wan_ifname="none"
+  NVRAM_wifi_ifname="none"
 }
index 748b606..1500f19 100755 (executable)
@@ -1,17 +1,19 @@
 #!/bin/sh
+# executed from squashfs before init to 
+# transfer root to the jffs2 partition
 mount none /proc -t proc
 insmod diag
 echo 0x01 > /proc/sys/diag
 sleep 1
-if [ $(cat /proc/sys/reset) = 0 ] ; then
+if [ $(cat /proc/sys/reset) = 1 ] ; then
+  export FAILSAFE=true
+else
   mtd unlock mtd4
   mount -t jffs2 /dev/mtdblock/4 /jffs
   pivot_root /jffs /jffs/rom
   mount none /dev -t devfs
   mount none /proc -t proc
   umount rom/proc rom/dev
-else
-  export FAILSAFE=true
 fi
 mount none /tmp -t ramfs
 exec /sbin/init
index 68adf54..fdccce1 100644 (file)
@@ -4,5 +4,5 @@
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 export PS1='\u@\h:\w\$ '
 
-alias less='more'
-alias vim='vi'
+alias less=more
+alias vim=vi
index 4c7e982..e59e057 100755 (executable)
@@ -2,7 +2,7 @@
 . /etc/functions.sh
   type=$1
   debug "### ifdown $type ###"
-  if=$(nvram_get ${type}_ifname)
+  if=$(nvram get ${type}_ifname)
   if_valid $if || return
   kill $(cat /var/run/${if}.pid 2>&-) 2>&-
   $DEBUG ifconfig $if down
index 34e19af..6b4a774 100755 (executable)
@@ -3,36 +3,36 @@
   type=$1
   debug "### ifup $type ###"
 
-  if=$(nvram_get ${type}_ifname)
+  if=$(nvram get ${type}_ifname)
   if [ "${if%%[0-9]}" = "ppp" ]; then
-    if=$(nvram_get pppoe_ifname)
+    if=$(nvram get pppoe_ifname)
   fi
 
   if_valid $if || return
 
   $DEBUG ifconfig $if down
   if [ "${if%%[0-9]}" = "br" ]; then
-    stp=$(nvram_get ${type}_stp)
+    stp=$(nvram get ${type}_stp)
     $DEBUG brctl delbr $if
     $DEBUG brctl addbr $if
     $DEBUG brctl setfd $if 0
     $DEBUG brctl stp $if ${stp:-0}
-    for sif in $(nvram_get ${type}_ifnames); do {
+    for sif in $(nvram get ${type}_ifnames); do {
       if_valid $sif || continue
       $DEBUG ifconfig $sif 0.0.0.0 up
       $DEBUG brctl addif $if $sif
     } done
   fi
 
-  mac=$(nvram_get ${type}_hwaddr)
+  mac=$(nvram get ${type}_hwaddr)
   ${mac:+$DEBUG ifconfig $if hw ether $mac}
 
-  if_proto=$(nvram_get ${type}_proto)
+  if_proto=$(nvram get ${type}_proto)
   case "$if_proto" in
     static)
-      ip=$(nvram_get ${type}_ipaddr)
-      netmask=$(nvram_get ${type}_netmask)
-      gateway=$(nvram_get ${type}_gateway)
+      ip=$(nvram get ${type}_ipaddr)
+      netmask=$(nvram get ${type}_netmask)
+      gateway=$(nvram get ${type}_gateway)
 
       $DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
       ${gateway:+$DEBUG route add default gw $gateway}
@@ -40,7 +40,7 @@
       [ -f /etc/resolv.conf ] && return
 
       debug "# --- creating /etc/resolv.conf ---"
-      for dns in $(nvram_get ${type}_dns); do {
+      for dns in $(nvram get ${type}_dns); do {
        echo "nameserver $dns" >> /etc/resolv.conf
       } done
     ;;
       ${DEBUG:-eval} "udhcpc -i $if -b -p $pidfile &" 
     ;;
     pppoe)
-      username=$(nvram_get ppp_username)
-      password=$(nvram_get ppp_passwd)
-      redial=$(nvram_get ppp_redialperiod)
-      idletime=$(nvram_get ppp_idletime)
-      mtu=$(nvram_get wan_mtu)
+      username=$(nvram get ppp_username)
+      password=$(nvram get ppp_passwd)
+      redial=$(nvram get ppp_redialperiod)
+      idletime=$(nvram get ppp_idletime)
+      mtu=$(nvram get wan_mtu)
 
       $DEBUG ifconfig $if 0.0.0.0 up
 
index 03ec66e..6360fff 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/ash
-  alias debug=${DEBUG:-:}
-  debug "### wifi $1 ###"
-  if=$(awk 'sub(":","") {print $1}' /proc/net/wireless)
-  $DEBUG wlconf $if $1
+alias debug=${DEBUG:-:}
+debug "### wifi $1 ###"
+if=$(awk 'sub(":","") {print $1}' /proc/net/wireless)
+$DEBUG wlconf $if $1
This page took 0.046207 seconds and 4 git commands to generate.