summaryrefslogtreecommitdiffstats
path: root/openwrt/target/default/target_skeleton/etc/init.d
diff options
context:
space:
mode:
Diffstat (limited to 'openwrt/target/default/target_skeleton/etc/init.d')
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S10boot25
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S40network44
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S45firewall23
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S50dnsmasq2
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S50httpd2
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S50telnet2
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/S99done7
-rwxr-xr-xopenwrt/target/default/target_skeleton/etc/init.d/rcS26
8 files changed, 85 insertions, 46 deletions
diff --git a/openwrt/target/default/target_skeleton/etc/init.d/S10boot b/openwrt/target/default/target_skeleton/etc/init.d/S10boot
new file mode 100755
index 000000000..81379bed4
--- /dev/null
+++ b/openwrt/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/openwrt/target/default/target_skeleton/etc/init.d/S40network b/openwrt/target/default/target_skeleton/etc/init.d/S40network
index d835d9c72..a8144a837 100755
--- a/openwrt/target/default/target_skeleton/etc/init.d/S40network
+++ b/openwrt/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/openwrt/target/default/target_skeleton/etc/init.d/S45firewall b/openwrt/target/default/target_skeleton/etc/init.d/S45firewall
new file mode 100755
index 000000000..49b9df000
--- /dev/null
+++ b/openwrt/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/openwrt/target/default/target_skeleton/etc/init.d/S50dnsmasq b/openwrt/target/default/target_skeleton/etc/init.d/S50dnsmasq
new file mode 100755
index 000000000..995c1b6e7
--- /dev/null
+++ b/openwrt/target/default/target_skeleton/etc/init.d/S50dnsmasq
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/dnsmasq
diff --git a/openwrt/target/default/target_skeleton/etc/init.d/S50httpd b/openwrt/target/default/target_skeleton/etc/init.d/S50httpd
new file mode 100755
index 000000000..fd66f8032
--- /dev/null
+++ b/openwrt/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/openwrt/target/default/target_skeleton/etc/init.d/S50telnet b/openwrt/target/default/target_skeleton/etc/init.d/S50telnet
new file mode 100755
index 000000000..29af5040a
--- /dev/null
+++ b/openwrt/target/default/target_skeleton/etc/init.d/S50telnet
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/sbin/telnetd -l /bin/login
diff --git a/openwrt/target/default/target_skeleton/etc/init.d/S99done b/openwrt/target/default/target_skeleton/etc/init.d/S99done
new file mode 100755
index 000000000..8811e99bf
--- /dev/null
+++ b/openwrt/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/openwrt/target/default/target_skeleton/etc/init.d/rcS b/openwrt/target/default/target_skeleton/etc/init.d/rcS
index de411534d..9510e941a 100755
--- a/openwrt/target/default/target_skeleton/etc/init.d/rcS
+++ b/openwrt/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
-