1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-19 04:08:25 +02:00

openwrt root filesystem

git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@211 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
mbm 2005-02-06 00:52:16 +00:00
parent 4aba84e6f0
commit c31ac521e4
21 changed files with 1516 additions and 165 deletions

View File

@ -0,0 +1,54 @@
#!/bin/sh
# $Id$
[ -f "/tmp/.firstboot" ] && {
echo "firstboot is already running"
return
}
touch /tmp/.firstboot
jdev=$(mount | awk '/jffs2/ {print $3}')
if [ -z "$jdev" ]; then
echo -n "Creating jffs2 partition... "
mtd erase OpenWrt >&-
mount -t jffs2 /dev/mtdblock/4 /jffs
echo "done"
cd /jffs
else
echo "firstboot has already been run"
echo "jffs2 partition is mounted, only resetting files"
cd $jdev
fi
exec 2>/dev/null
mount /dev/mtdblock/2 /rom -o ro
echo -n "creating directories... "
{
cd /rom
find . -type d
cd -
} | xargs mkdir
echo "done"
echo -n "setting up symlinks... "
for file in $(cd /rom; find * -type f; find * -type l;)
do {
ln -sf /rom/$file $file
} done
echo "done"
touch /tmp/resolv.conf
ln -s /tmp/resolv.conf /etc/resolv.conf
umount /rom
mount none /jffs/proc -t proc
pivot_root /jffs /jffs/rom
mount none /dev -t devfs
mount none /tmp -t ramfs
umount /rom/proc
umount /rom/tmp
umount /rom/dev

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec ash --login

View File

@ -0,0 +1,6 @@
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M

View File

@ -0,0 +1,24 @@
# filter what we send upstream
domain-needed
bogus-priv
filterwin2k
# allow /etc/hosts and dhcp lookups via *.lan
local=/lan/
domain=lan
# no dhcp / dns queries from the wan
except-interface=vlan1
# enable dhcp (start,end,netmask,leasetime)
dhcp-authoritative
dhcp-range=192.168.1.100,192.168.1.250,255.255.255.0,12h
dhcp-leasefile=/tmp/dhcp.leases
# use /etc/ethers for static hosts; same format as --dhcp-host
# <hwaddr> [<hostname>] <ipaddr>
read-ethers
# other useful options:
# default route(s): dhcp-option=3,192.168.1.1,192.168.1.2
# dns server(s): dhcp-option=6,192.168.1.1,192.168.1.2

View File

@ -0,0 +1,33 @@
#!/bin/ash
alias debug=${DEBUG:-:}
# allow env to override nvram
nvram () {
case $1 in
get) eval "echo \${NVRAM_$2:-\$(command nvram get $2)}";;
*) command nvram $*;;
esac
}
. /etc/nvram.overrides
# valid interface?
if_valid () {
ifconfig "$1" >&- 2>&- ||
[ "${1%%[0-9]}" = "br" ] ||
{
[ "${1%%[0-9]}" = "vlan" ] && (
i=${1#vlan}
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)
debug "# vlan$i => $vif"
$DEBUG ifconfig $vif up
$DEBUG vconfig add $vif $i 2>&-
)
} ||
{ echo -e "# $1 ignored: can't find/create"; false; }
}

View File

@ -0,0 +1,25 @@
#!/bin/sh
klogd
syslogd -C 16
sysctl -p
echo "S" > /proc/jffs2_bbc
mkdir -p /var/run
[ "$(nvram get il0macaddr)" = "00:90:4c:5f:00:2a" ] && {
# if default wifi mac, set two higher than the lan mac
nvram set il0macaddr=$(nvram get et0macaddr|
awk '{OFS=FS=":";for(x=7,y=2;--x;){$x=sprintf("%02x",(y+="0x"$x)%256);y/=256}print}')
}
insmod et
insmod wl
ifconfig lo 127.0.0.1 up
ifconfig eth0 promisc
HOSTNAME=$(nvram get wan_hostname)
HOSTNAME=${HOSTNAME%%.*}
echo ${HOSTNAME:=OpenWrt} > /proc/sys/kernel/hostname
vconfig set_name_type VLAN_PLUS_VID_NO_PAD

View File

@ -1,35 +1,15 @@
#!/bin/sh
#
# Start the network....
#
start() {
echo "Starting network..."
/sbin/ifup -a
}
stop() {
echo -n "Stopping network..."
/sbin/ifdown -a
}
restart() {
stop
start
}
. /etc/functions.sh
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
start|restart)
ifup lan
ifup wan
ifup wifi
wifi up
for route in $(nvram get static_route); do {
eval "set $(echo $route | sed 's/:/ /g')"
$DEBUG route add -net $1 netmask $2 gw $3 metric $4 dev $5
} done
;;
esac
exit $?

View File

@ -0,0 +1,23 @@
#!/bin/sh
. /etc/functions.sh
WAN=$(nvram get wan_ifname)
IPT=/usr/sbin/iptables
for T in filter nat mangle ; do
$IPT -t $T -F
$IPT -t $T -X
done
$IPT -t filter -A INPUT -m state --state INVALID -j DROP
$IPT -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -t filter -A INPUT -p icmp -j ACCEPT
$IPT -t filter -A INPUT -i $WAN -p tcp -j REJECT --reject-with tcp-reset
$IPT -t filter -A INPUT -i $WAN -j REJECT --reject-with icmp-port-unreachable
$IPT -t filter -A FORWARD -m state --state INVALID -j DROP
$IPT -t filter -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
$IPT -t filter -A FORWARD -i $WAN -m state --state NEW,INVALID -j DROP
$IPT -t filter -A FORWARD -o $WAN -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
$IPT -t nat -A POSTROUTING -o $WAN -j MASQUERADE

View File

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

View File

@ -0,0 +1,2 @@
#!/bin/sh
/usr/sbin/httpd -p 80 -h /www -r WRT54G Router

View File

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

View File

@ -0,0 +1,7 @@
#!/bin/sh
# automagically run firstboot
[ -z "$FAILSAFE" ] && {
{ mount | grep jffs2 1>&-; } || firstboot
}
# set leds to normal state
echo "0x00" > /proc/sys/diag

View File

@ -1,6 +1,5 @@
#!/bin/sh
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
@ -10,18 +9,17 @@ for i in /etc/init.d/S??* ;do
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done

View File

@ -1,47 +1,3 @@
# /etc/inittab
#
# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
#
# Note: BusyBox init doesn't support runlevels. The runlevels field is
# completely ignored by BusyBox init. If you want runlevels, use
# sysvinit.
#
# Format for each entry: <id>:<runlevels>:<action>:<process>
#
# id == tty to run on, or empty for /dev/console
# runlevels == ignored
# action == one of sysinit, respawn, askfirst, wait, and once
# process == program to run
# Startup the system
null::sysinit:/bin/mount -o remount,rw /
null::sysinit:/bin/mount -t proc proc /proc
null::sysinit:/bin/mount -a
null::sysinit:/bin/hostname -F /etc/hostname
null::sysinit:/sbin/ifconfig lo 127.0.0.1 up
null::sysinit:/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo
# now run any rc scripts
::sysinit:/etc/init.d/rcS
# Set up a couple of getty's
tty1::respawn:/sbin/getty 38400 tty1
tty2::respawn:/sbin/getty 38400 tty2
# Put a getty on the serial port
#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
# Logging junk
null::sysinit:/bin/touch /var/log/messages
null::respawn:/sbin/syslogd -n -m 0
null::respawn:/sbin/klogd -n
tty3::respawn:/usr/bin/tail -f /var/log/messages
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
null::shutdown:/usr/bin/killall klogd
null::shutdown:/usr/bin/killall syslogd
null::shutdown:/bin/umount -a -r
null::shutdown:/sbin/swapoff -a
::shutdown:/sbin/halt
ttys/0::respawn:/bin/login

View File

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

View File

@ -0,0 +1,62 @@
# NVRAM overrides
#
# This file handles the NVRAM quirks of various hardware.
# THIS FILE IS NOT A REPLACEMENT FOR NVRAM
# linksys bug; remove when not using static configuration for lan
NVRAM_lan_proto="static"
# hacks for wrt54g 1.x hardware
[ "$(nvram get boardnum)" = "42" ] && \
[ "$(nvram get boardtype)" = "bcm94710dev" ] && {
# remap eth0 => vlan2, eth1 => vlan1
# for all *_ifname(s)
debug "### wrt54g 1.x hack ###"
NVRAM_vlan1hwname="et0"
NVRAM_vlan2hwname="et0"
FAILSAFE_ifnames="vlan1 vlan2 eth2"
remap () {
eval NVRAM_$1=\"$(nvram get $1 | awk 'gsub("eth0","vlan2") gsub("eth1","vlan1")')\"
}
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"
FAILSAFE_ifnames="eth0 eth1"
}
# 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 "### YOU ARE IN FAILSAFE MODE ####"
NVRAM_lan_ifname="br0"
NVRAM_lan_ifnames=${FAILSAFE_ifnames:-"vlan0 vlan1 eth1"}
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

@ -0,0 +1,20 @@
#!/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) = 1 ] ; then
export FAILSAFE=true
while :; do { echo $(((X=(X+1)%8)%2)) > /proc/sys/diag; sleep $((X==0)); } done &
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
fi
mount none /tmp -t ramfs
exec /sbin/init

View File

@ -1,48 +1,9 @@
# ~/.bashrc: executed by bash(1) for non-login interactive shells.
#!/bin/sh
[ -f /etc/banner ] && cat /etc/banner
export PATH=\
/bin:\
/sbin:\
/usr/bin:\
/usr/sbin:\
/usr/bin/X11:\
/usr/local/bin
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PS1='\u@\h:\w\$ '
# If running interactively, then:
if [ "$PS1" ]; then
if [ "$BASH" ]; then
export PS1="[\u@\h \W]\\$ "
alias ll='/bin/ls --color=tty -laFh'
alias ls='/bin/ls --color=tty -F'
export LS_COLORS='no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.png=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:';
else
if [ "`id -u`" -eq 0 ]; then
export PS1='# '
else
export PS1='$ '
fi
fi
export USER=`id -un`
export LOGNAME=$USER
export HOSTNAME=`/bin/hostname`
export HISTSIZE=1000
export HISTFILESIZE=1000
export PAGER='/bin/more '
export EDITOR='/bin/vi'
export INPUTRC=/etc/inputrc
export DMALLOC_OPTIONS=debug=0x34f47d83,inter=100,log=logfile
### Some aliases
alias ps2='ps facux '
alias ps1='ps faxo "%U %t %p %a" '
alias af='ps af'
alias cls='clear'
alias df='df -h'
alias indent='indent -bad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs -npsl -nsc -nsob -nss -ts4 '
#alias bc='bc -l'
alias minicom='minicom -c on'
alias calc='calc -Cd '
alias bc='calc -Cd '
fi;
alias less=more
alias vim=vi
ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }

View File

@ -0,0 +1,7 @@
kernel.panic = 3
net.ipv4.ip_forward = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 120
net.ipv4.tcp_timestamps = 0

View File

@ -1,39 +1,38 @@
#!/bin/sh
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
# (slightly modified)
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
RESOLV_CONF="/tmp/resolv.conf"
case "$1" in
deconfig)
/sbin/ifconfig $interface 0.0.0.0
;;
deconfig)
ifconfig $interface 0.0.0.0
;;
renew|bound)
/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
renew|bound)
ifconfig $interface $ip \
${broadcast:+broadcast $broadcast} \
${subnet:+netmask $subnet}
if [ -n "$router" ] ; then
echo "deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do
:
done
if [ -n "$router" ] ; then
echo "deleting routers"
while route del default gw 0.0.0.0 dev $interface ; do
:
done
for i in $router ; do
route add default gw $i dev $interface
done
fi
for i in $router ; do
route add default gw $i dev $interface
done
fi
echo -n > $RESOLV_CONF
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
for i in $dns ; do
echo adding dns $i
echo nameserver $i >> $RESOLV_CONF
done
;;
echo -n > $RESOLV_CONF
${domain:+echo search $domain >> $RESOLV_CONF}
for i in $dns ; do
echo adding dns $i
echo nameserver $i >> $RESOLV_CONF
done
;;
esac
exit 0