wap54g support separate S50services into individual files move nvram_get to 'nvram get' making nvram overrides more transparent
SVN-Revision: 155
This commit is contained in:
parent
d212c93fcd
commit
fbdcc34275
15 changed files with 86 additions and 76 deletions
|
@ -3,8 +3,11 @@
|
||||||
alias debug=${DEBUG:-:}
|
alias debug=${DEBUG:-:}
|
||||||
|
|
||||||
# allow env to override nvram
|
# allow env to override nvram
|
||||||
nvram_get () {
|
nvram () {
|
||||||
eval "echo \${$1:-\$(nvram get $1)}"
|
case $1 in
|
||||||
|
get) eval "echo \${NVRAM_$2:-\$(command nvram get $2)}";;
|
||||||
|
*) command nvram $*;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
. /etc/nvram.overrides
|
. /etc/nvram.overrides
|
||||||
|
|
||||||
|
@ -12,8 +15,8 @@ nvram_get () {
|
||||||
if_valid () (
|
if_valid () (
|
||||||
[ "${1%%[0-9]}" = "vlan" ] && {
|
[ "${1%%[0-9]}" = "vlan" ] && {
|
||||||
i=${1#vlan}
|
i=${1#vlan}
|
||||||
hwname=$(nvram_get vlan${i}hwname)
|
hwname=$(nvram get vlan${i}hwname)
|
||||||
hwaddr=$(nvram_get ${hwname}macaddr)
|
hwaddr=$(nvram get ${hwname}macaddr)
|
||||||
[ -z "$hwaddr" ] && return 1
|
[ -z "$hwaddr" ] && return 1
|
||||||
|
|
||||||
vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
|
vif=$(ifconfig -a | awk '/^eth.*'$hwaddr'/ {print $1; exit}' IGNORECASE=1)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
syslogd -C 16
|
||||||
sysctl -p
|
sysctl -p
|
||||||
echo "S" > /proc/jffs2_bbc
|
echo "S" > /proc/jffs2_bbc
|
||||||
|
|
||||||
mkdir -p /var/run
|
mkdir -p /var/run
|
||||||
|
|
||||||
# networking stub
|
|
||||||
[ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
|
[ "$(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|
|
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
|
insmod et
|
||||||
|
@ -18,12 +18,7 @@ ifconfig lo 127.0.0.1 up
|
||||||
ifconfig eth0 promisc
|
ifconfig eth0 promisc
|
||||||
|
|
||||||
HOSTNAME=$(nvram get wan_hostname)
|
HOSTNAME=$(nvram get wan_hostname)
|
||||||
DOMAINNAME=${HOSTNAME##*.}
|
|
||||||
HOSTNAME=${HOSTNAME%%.*}
|
HOSTNAME=${HOSTNAME%%.*}
|
||||||
|
|
||||||
echo ${HOSTNAME:=OpenWrt} > /proc/sys/kernel/hostname
|
echo ${HOSTNAME:=OpenWrt} > /proc/sys/kernel/hostname
|
||||||
echo ${DOMAINNAME:=lan} > /proc/sys/kernel/domainname
|
|
||||||
|
|
||||||
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
|
vconfig set_name_type VLAN_PLUS_VID_NO_PAD
|
||||||
|
|
||||||
syslogd -C 16
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ case "$1" in
|
||||||
ifup wifi
|
ifup wifi
|
||||||
wifi up
|
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')"
|
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
|
} done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
. /etc/functions.sh
|
. /etc/functions.sh
|
||||||
|
|
||||||
WAN=$(nvram_get wan_ifname)
|
WAN=$(nvram get wan_ifname)
|
||||||
|
|
||||||
IPT=/usr/sbin/iptables
|
IPT=/usr/sbin/iptables
|
||||||
|
|
||||||
|
|
2
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50dnsmasq
Executable file
2
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50dnsmasq
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
/usr/sbin/dnsmasq
|
|
@ -1,4 +1,2 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
/usr/sbin/telnetd -l /bin/login
|
|
||||||
/usr/sbin/httpd -p 80 -h /www -r WRT54G Router
|
/usr/sbin/httpd -p 80 -h /www -r WRT54G Router
|
||||||
/usr/sbin/dnsmasq
|
|
2
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50telnet
Executable file
2
obsolete-buildroot/sources/openwrt/root/etc/init.d/S50telnet
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
/usr/sbin/telnetd -l /bin/login
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# automagically run firstboot
|
||||||
[ -z "$FAILSAFE" ] && {
|
[ -z "$FAILSAFE" ] && {
|
||||||
{ mount | grep jffs2 1>&-; } || firstboot
|
{ mount | grep jffs2 1>&-; } || firstboot
|
||||||
}
|
}
|
||||||
# turn off DMZ led
|
# set leds to normal state
|
||||||
echo "0x00" > /proc/sys/diag
|
echo "0x00" > /proc/sys/diag
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
src openwrt http://openwrt.ksilebo.net/ipkg
|
src openwrt http://openwrt.org/ipkg
|
||||||
dest root /
|
dest root /
|
||||||
dest ram /tmp
|
dest ram /tmp
|
||||||
|
|
|
@ -1,53 +1,60 @@
|
||||||
# NVRAM overrides
|
# 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
|
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM
|
||||||
|
|
||||||
# linksys bug has lan doing dhcp; force static
|
# linksys bug; remove when not using static configuration for lan
|
||||||
lan_proto="static"
|
NVRAM_lan_proto="static"
|
||||||
|
|
||||||
# hacks for 1.x hardware
|
# hacks for wrt54g 1.x hardware
|
||||||
[ "$(nvram get boardnum)" = "42" ] && \
|
[ "$(nvram get boardnum)" = "42" ] && \
|
||||||
[ "$(nvram get boardtype)" = "bcm94710dev" ] && {
|
[ "$(nvram get boardtype)" = "bcm94710dev" ] && {
|
||||||
debug "### 1.x hardware hack ###"
|
|
||||||
vlan1hwname="et0"
|
|
||||||
vlan2hwname="et0"
|
|
||||||
|
|
||||||
# we remap old device names to new
|
# remap eth0 => vlan2, eth1 => vlan1
|
||||||
# it's recommended that you continue to
|
# for all *_ifname(s)
|
||||||
# use the old names to preserve backwards
|
|
||||||
# compatibility
|
debug "### wrt54g 1.x hack ###"
|
||||||
|
NVRAM_vlan1hwname="et0"
|
||||||
|
NVRAM_vlan2hwname="et0"
|
||||||
|
|
||||||
remap () {
|
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
|
for type in lan wifi wan pppoe
|
||||||
remap lan_ifnames
|
do
|
||||||
remap wifi_ifname
|
remap ${type}_ifname
|
||||||
remap wifi_ifnames
|
remap ${type}_ifnames
|
||||||
remap wan_ifname
|
done
|
||||||
remap wan_ifnames
|
|
||||||
remap pppoe_ifname
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -z "$(nvram_get lan_ifname)" ] && {
|
# hacks for wap54g hardware
|
||||||
lan_ifname="br0"
|
[ "$(nvram get boardnum)" = "2" ] || \
|
||||||
lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
|
[ "$(nvram get boardnum)" = "1024" ] && {
|
||||||
|
debug "### wap54g hack ###"
|
||||||
|
NVRAM_wan_ifname="none"
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -z "$(nvram_get wan_ifname)" ] && {
|
# defaults if lan_ifname is missing
|
||||||
wan_ifname="vlan1"
|
[ -z "$(nvram get lan_ifname)" ] && {
|
||||||
wan_proto="dhcp"
|
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 if reset is held
|
||||||
[ "$FAILSAFE" = "true" ] && {
|
[ "$FAILSAFE" = "true" ] && {
|
||||||
echo "### FAILSAFE MODE ####"
|
echo "### FAILSAFE MODE ####"
|
||||||
lan_ifname="br0"
|
NVRAM_lan_ifname="br0"
|
||||||
lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
|
NVRAM_lan_ifnames="vlan0 vlan2 eth1 eth2 eth3"
|
||||||
lan_ipaddr="192.168.1.1"
|
NVRAM_lan_ipaddr="192.168.1.1"
|
||||||
lan_netmask="255.255.255.0"
|
NVRAM_lan_netmask="255.255.255.0"
|
||||||
lan_hwaddr="00:0B:AD:0A:DD:00"
|
NVRAM_lan_hwaddr="00:0B:AD:0A:DD:00"
|
||||||
wan_ifname="none"
|
NVRAM_wan_ifname="none"
|
||||||
wifi_ifname="none"
|
NVRAM_wifi_ifname="none"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
# executed from squashfs before init to
|
||||||
|
# transfer root to the jffs2 partition
|
||||||
mount none /proc -t proc
|
mount none /proc -t proc
|
||||||
insmod diag
|
insmod diag
|
||||||
echo 0x01 > /proc/sys/diag
|
echo 0x01 > /proc/sys/diag
|
||||||
sleep 1
|
sleep 1
|
||||||
if [ $(cat /proc/sys/reset) = 0 ] ; then
|
if [ $(cat /proc/sys/reset) = 1 ] ; then
|
||||||
|
export FAILSAFE=true
|
||||||
|
else
|
||||||
mtd unlock mtd4
|
mtd unlock mtd4
|
||||||
mount -t jffs2 /dev/mtdblock/4 /jffs
|
mount -t jffs2 /dev/mtdblock/4 /jffs
|
||||||
pivot_root /jffs /jffs/rom
|
pivot_root /jffs /jffs/rom
|
||||||
mount none /dev -t devfs
|
mount none /dev -t devfs
|
||||||
mount none /proc -t proc
|
mount none /proc -t proc
|
||||||
umount rom/proc rom/dev
|
umount rom/proc rom/dev
|
||||||
else
|
|
||||||
export FAILSAFE=true
|
|
||||||
fi
|
fi
|
||||||
mount none /tmp -t ramfs
|
mount none /tmp -t ramfs
|
||||||
exec /sbin/init
|
exec /sbin/init
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
|
||||||
export PS1='\u@\h:\w\$ '
|
export PS1='\u@\h:\w\$ '
|
||||||
|
|
||||||
alias less='more'
|
alias less=more
|
||||||
alias vim='vi'
|
alias vim=vi
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
. /etc/functions.sh
|
. /etc/functions.sh
|
||||||
type=$1
|
type=$1
|
||||||
debug "### ifdown $type ###"
|
debug "### ifdown $type ###"
|
||||||
if=$(nvram_get ${type}_ifname)
|
if=$(nvram get ${type}_ifname)
|
||||||
if_valid $if || return
|
if_valid $if || return
|
||||||
kill $(cat /var/run/${if}.pid 2>&-) 2>&-
|
kill $(cat /var/run/${if}.pid 2>&-) 2>&-
|
||||||
$DEBUG ifconfig $if down
|
$DEBUG ifconfig $if down
|
||||||
|
|
|
@ -3,36 +3,36 @@
|
||||||
type=$1
|
type=$1
|
||||||
debug "### ifup $type ###"
|
debug "### ifup $type ###"
|
||||||
|
|
||||||
if=$(nvram_get ${type}_ifname)
|
if=$(nvram get ${type}_ifname)
|
||||||
if [ "${if%%[0-9]}" = "ppp" ]; then
|
if [ "${if%%[0-9]}" = "ppp" ]; then
|
||||||
if=$(nvram_get pppoe_ifname)
|
if=$(nvram get pppoe_ifname)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if_valid $if || return
|
if_valid $if || return
|
||||||
|
|
||||||
$DEBUG ifconfig $if down
|
$DEBUG ifconfig $if down
|
||||||
if [ "${if%%[0-9]}" = "br" ]; then
|
if [ "${if%%[0-9]}" = "br" ]; then
|
||||||
stp=$(nvram_get ${type}_stp)
|
stp=$(nvram get ${type}_stp)
|
||||||
$DEBUG brctl delbr $if
|
$DEBUG brctl delbr $if
|
||||||
$DEBUG brctl addbr $if
|
$DEBUG brctl addbr $if
|
||||||
$DEBUG brctl setfd $if 0
|
$DEBUG brctl setfd $if 0
|
||||||
$DEBUG brctl stp $if ${stp:-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
|
if_valid $sif || continue
|
||||||
$DEBUG ifconfig $sif 0.0.0.0 up
|
$DEBUG ifconfig $sif 0.0.0.0 up
|
||||||
$DEBUG brctl addif $if $sif
|
$DEBUG brctl addif $if $sif
|
||||||
} done
|
} done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mac=$(nvram_get ${type}_hwaddr)
|
mac=$(nvram get ${type}_hwaddr)
|
||||||
${mac:+$DEBUG ifconfig $if hw ether $mac}
|
${mac:+$DEBUG ifconfig $if hw ether $mac}
|
||||||
|
|
||||||
if_proto=$(nvram_get ${type}_proto)
|
if_proto=$(nvram get ${type}_proto)
|
||||||
case "$if_proto" in
|
case "$if_proto" in
|
||||||
static)
|
static)
|
||||||
ip=$(nvram_get ${type}_ipaddr)
|
ip=$(nvram get ${type}_ipaddr)
|
||||||
netmask=$(nvram_get ${type}_netmask)
|
netmask=$(nvram get ${type}_netmask)
|
||||||
gateway=$(nvram_get ${type}_gateway)
|
gateway=$(nvram get ${type}_gateway)
|
||||||
|
|
||||||
$DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
|
$DEBUG ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
|
||||||
${gateway:+$DEBUG route add default gw $gateway}
|
${gateway:+$DEBUG route add default gw $gateway}
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
[ -f /etc/resolv.conf ] && return
|
[ -f /etc/resolv.conf ] && return
|
||||||
|
|
||||||
debug "# --- creating /etc/resolv.conf ---"
|
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
|
echo "nameserver $dns" >> /etc/resolv.conf
|
||||||
} done
|
} done
|
||||||
;;
|
;;
|
||||||
|
@ -52,11 +52,11 @@
|
||||||
${DEBUG:-eval} "udhcpc -i $if -b -p $pidfile &"
|
${DEBUG:-eval} "udhcpc -i $if -b -p $pidfile &"
|
||||||
;;
|
;;
|
||||||
pppoe)
|
pppoe)
|
||||||
username=$(nvram_get ppp_username)
|
username=$(nvram get ppp_username)
|
||||||
password=$(nvram_get ppp_passwd)
|
password=$(nvram get ppp_passwd)
|
||||||
redial=$(nvram_get ppp_redialperiod)
|
redial=$(nvram get ppp_redialperiod)
|
||||||
idletime=$(nvram_get ppp_idletime)
|
idletime=$(nvram get ppp_idletime)
|
||||||
mtu=$(nvram_get wan_mtu)
|
mtu=$(nvram get wan_mtu)
|
||||||
|
|
||||||
$DEBUG ifconfig $if 0.0.0.0 up
|
$DEBUG ifconfig $if 0.0.0.0 up
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/ash
|
#!/bin/ash
|
||||||
alias debug=${DEBUG:-:}
|
alias debug=${DEBUG:-:}
|
||||||
debug "### wifi $1 ###"
|
debug "### wifi $1 ###"
|
||||||
if=$(awk 'sub(":","") {print $1}' /proc/net/wireless)
|
if=$(awk 'sub(":","") {print $1}' /proc/net/wireless)
|
||||||
$DEBUG wlconf $if $1
|
$DEBUG wlconf $if $1
|
||||||
|
|
Loading…
Reference in a new issue