summaryrefslogtreecommitdiff
path: root/target/default/target_skeleton/etc
diff options
context:
space:
mode:
authormbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-02-06 00:52:16 +0000
committermbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73>2005-02-06 00:52:16 +0000
commitc31ac521e420aa0cfd3ddbc0859b29b0e2a3ff3e (patch)
tree7f74d65e19595fd3b6a258f82ced9c9c964df586 /target/default/target_skeleton/etc
parent4aba84e6f06f55c77ff8dbbcf0de172c6c14d03b (diff)
openwrt root filesystem
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@211 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/default/target_skeleton/etc')
-rw-r--r--target/default/target_skeleton/etc/banner6
-rw-r--r--target/default/target_skeleton/etc/dnsmasq.conf24
-rwxr-xr-xtarget/default/target_skeleton/etc/functions.sh33
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S10boot25
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S40network44
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S45firewall23
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S50dnsmasq2
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S50httpd2
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S50telnet2
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/S99done7
-rwxr-xr-xtarget/default/target_skeleton/etc/init.d/rcS26
-rw-r--r--target/default/target_skeleton/etc/inittab48
-rw-r--r--target/default/target_skeleton/etc/ipkg.conf3
-rw-r--r--target/default/target_skeleton/etc/nvram.overrides62
-rwxr-xr-xtarget/default/target_skeleton/etc/preinit20
-rw-r--r--target/default/target_skeleton/etc/profile53
-rw-r--r--target/default/target_skeleton/etc/sysctl.conf7
17 files changed, 249 insertions, 138 deletions
diff --git a/target/default/target_skeleton/etc/banner b/target/default/target_skeleton/etc/banner
new file mode 100644
index 0000000000..2b2b2c015b
--- /dev/null
+++ b/target/default/target_skeleton/etc/banner
@@ -0,0 +1,6 @@
+ _______ ________ __
+ | |.-----.-----.-----.| | | |.----.| |_
+ | - || _ | -__| || | | || _|| _|
+ |_______|| __|_____|__|__||________||__| |____|
+ |__| W I R E L E S S F R E E D O M
+
diff --git a/target/default/target_skeleton/etc/dnsmasq.conf b/target/default/target_skeleton/etc/dnsmasq.conf
new file mode 100644
index 0000000000..293edc600a
--- /dev/null
+++ b/target/default/target_skeleton/etc/dnsmasq.conf
@@ -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
diff --git a/target/default/target_skeleton/etc/functions.sh b/target/default/target_skeleton/etc/functions.sh
new file mode 100755
index 0000000000..75500a2aab
--- /dev/null
+++ b/target/default/target_skeleton/etc/functions.sh
@@ -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; }
+}
diff --git a/target/default/target_skeleton/etc/init.d/S10boot b/target/default/target_skeleton/etc/init.d/S10boot
new file mode 100755
index 0000000000..81379bed4b
--- /dev/null
+++ b/target/default/target_skeleton/etc/init.d/S10boot
@@ -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
diff --git a/target/default/target_skeleton/etc/init.d/S40network b/target/default/target_skeleton/etc/init.d/S40network
index d835d9c72a..a8144a8375 100755
--- a/target/default/target_skeleton/etc/init.d/S40network
+++ b/target/default/target_skeleton/etc/init.d/S40network
@@ -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 $?
-
diff --git a/target/default/target_skeleton/etc/init.d/S45firewall b/target/default/target_skeleton/etc/init.d/S45firewall
new file mode 100755
index 0000000000..49b9df0004
--- /dev/null
+++ b/target/default/target_skeleton/etc/init.d/S45firewall
@@ -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
diff --git a/target/default/target_skeleton/etc/init.d/S50dnsmasq b/target/default/target_skeleton/etc/init.d/S50dnsmasq
new file mode 100755
index 0000000000..995c1b6e7a
--- /dev/null
+++ b/target/default/target_skeleton/etc/init.d/S50dnsmasq
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/dnsmasq
diff --git a/target/default/target_skeleton/etc/init.d/S50httpd b/target/default/target_skeleton/etc/init.d/S50httpd
new file mode 100755
index 0000000000..fd66f8032f
--- /dev/null
+++ b/target/default/target_skeleton/etc/init.d/S50httpd
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/httpd -p 80 -h /www -r WRT54G Router
diff --git a/target/default/target_skeleton/etc/init.d/S50telnet b/target/default/target_skeleton/etc/init.d/S50telnet
new file mode 100755
index 0000000000..29af5040a3
--- /dev/null
+++ b/target/default/target_skeleton/etc/init.d/S50telnet
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/telnetd -l /bin/login
diff --git a/target/default/target_skeleton/etc/init.d/S99done b/target/default/target_skeleton/etc/init.d/S99done
new file mode 100755
index 0000000000..8811e99bff
--- /dev/null
+++ b/target/default/target_skeleton/etc/init.d/S99done
@@ -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
diff --git a/target/default/target_skeleton/etc/init.d/rcS b/target/default/target_skeleton/etc/init.d/rcS
index de411534da..9510e941a5 100755
--- a/target/default/target_skeleton/etc/init.d/rcS
+++ b/target/default/target_skeleton/etc/init.d/rcS
@@ -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
-
diff --git a/target/default/target_skeleton/etc/inittab b/target/default/target_skeleton/etc/inittab
index a6c014e751..238c3d7e9b 100644
--- a/target/default/target_skeleton/etc/inittab
+++ b/target/default/target_skeleton/etc/inittab
@@ -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
diff --git a/target/default/target_skeleton/etc/ipkg.conf b/target/default/target_skeleton/etc/ipkg.conf
new file mode 100644
index 0000000000..31a5fdfe1b
--- /dev/null
+++ b/target/default/target_skeleton/etc/ipkg.conf
@@ -0,0 +1,3 @@
+src openwrt http://openwrt.org/ipkg
+dest root /
+dest ram /tmp
diff --git a/target/default/target_skeleton/etc/nvram.overrides b/target/default/target_skeleton/etc/nvram.overrides
new file mode 100644
index 0000000000..acbba30a41
--- /dev/null
+++ b/target/default/target_skeleton/etc/nvram.overrides
@@ -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"
+}
diff --git a/target/default/target_skeleton/etc/preinit b/target/default/target_skeleton/etc/preinit
new file mode 100755
index 0000000000..6e6a9c998a
--- /dev/null
+++ b/target/default/target_skeleton/etc/preinit
@@ -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
diff --git a/target/default/target_skeleton/etc/profile b/target/default/target_skeleton/etc/profile
index cc2e0beb87..29cd340b3e 100644
--- a/target/default/target_skeleton/etc/profile
+++ b/target/default/target_skeleton/etc/profile
@@ -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 $*; }
diff --git a/target/default/target_skeleton/etc/sysctl.conf b/target/default/target_skeleton/etc/sysctl.conf
new file mode 100644
index 0000000000..8552a4ba32
--- /dev/null
+++ b/target/default/target_skeleton/etc/sysctl.conf
@@ -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