1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-24 19:49:54 +02:00

wap54g support

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
This commit is contained in:
mbm 2004-09-07 05:54:07 +00:00
parent 437d48bef2
commit 6500719d9c
15 changed files with 86 additions and 76 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -1,7 +1,7 @@
#!/bin/sh
. /etc/functions.sh
WAN=$(nvram_get wan_ifname)
WAN=$(nvram get wan_ifname)
IPT=/usr/sbin/iptables

View File

@ -0,0 +1,2 @@
#!/bin/sh
/usr/sbin/dnsmasq

View File

@ -1,4 +1,2 @@
#!/bin/sh
/usr/sbin/telnetd -l /bin/login
/usr/sbin/httpd -p 80 -h /www -r WRT54G Router
/usr/sbin/dnsmasq

View File

@ -0,0 +1,2 @@
#!/bin/sh
/usr/sbin/telnetd -l /bin/login

View File

@ -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

View File

@ -1,3 +1,3 @@
src openwrt http://openwrt.ksilebo.net/ipkg
src openwrt http://openwrt.org/ipkg
dest root /
dest ram /tmp

View 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
}
[ -z "$(nvram_get lan_ifname)" ] && {
lan_ifname="br0"
lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
# hacks for wap54g hardware
[ "$(nvram get boardnum)" = "2" ] || \
[ "$(nvram get boardnum)" = "1024" ] && {
debug "### wap54g hack ###"
NVRAM_wan_ifname="none"
}
[ -z "$(nvram_get wan_ifname)" ] && {
wan_ifname="vlan1"
wan_proto="dhcp"
# defaults if lan_ifname is missing
[ -z "$(nvram get lan_ifname)" ] && {
NVRAM_lan_ifname="br0"
NVRAM_lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
}
# 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"
}

View File

@ -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

View 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

View File

@ -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

View File

@ -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
;;
@ -52,11 +52,11 @@
${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

View File

@ -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