diff options
author | James <> | 2013-03-17 12:16:37 +0000 |
---|---|---|
committer | James <> | 2013-03-17 12:16:37 +0000 |
commit | 27b76ab0671089c47506615a796a261e993896a7 (patch) | |
tree | 61213d67e7fa87b20356b23798558e2c4212c42f /package/base-files/files | |
download | trunk-36060-master.tar.gz trunk-36060-master.tar.bz2 trunk-36060-master.zip |
Diffstat (limited to 'package/base-files/files')
226 files changed, 11089 insertions, 0 deletions
diff --git a/package/base-files/files/.svn/entries b/package/base-files/files/.svn/entries new file mode 100644 index 0000000..cee7551 --- /dev/null +++ b/package/base-files/files/.svn/entries @@ -0,0 +1,43 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files +svn://svn.openwrt.org/openwrt + + + +2013-03-14T18:43:58.957223Z +36031 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +lib +dir + +bin +dir + +etc +dir + +sbin +dir + +rom +dir + diff --git a/package/base-files/files/bin/.svn/entries b/package/base-files/files/bin/.svn/entries new file mode 100644 index 0000000..ca70565 --- /dev/null +++ b/package/base-files/files/bin/.svn/entries @@ -0,0 +1,96 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/bin +svn://svn.openwrt.org/openwrt + + + +2012-12-23T22:18:43.337226Z +34875 +jow + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +login.sh +file + + + + +2013-03-17T12:13:21.000000Z +a497a18c3018ef7fe70f088e32c890e7 +2011-11-17T09:40:06.613901Z +29208 +jow +has-props + + + + + + + + + + + + + + + + + + + + +424 + +ipcalc.sh +file + + + + +2013-03-17T12:13:21.000000Z +267ae3ac223b1717a0023773a742b892 +2012-12-23T22:18:43.337226Z +34875 +jow +has-props + + + + + + + + + + + + + + + + + + + + +1453 + diff --git a/package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base b/package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/bin/.svn/prop-base/ipcalc.sh.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/bin/.svn/prop-base/login.sh.svn-base b/package/base-files/files/bin/.svn/prop-base/login.sh.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/bin/.svn/prop-base/login.sh.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base b/package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base new file mode 100644 index 0000000..7463d6b --- /dev/null +++ b/package/base-files/files/bin/.svn/text-base/ipcalc.sh.svn-base @@ -0,0 +1,67 @@ +#!/bin/sh + +awk -f - $* <<EOF +function bitcount(c) { + c=and(rshift(c, 1),0x55555555)+and(c,0x55555555) + c=and(rshift(c, 2),0x33333333)+and(c,0x33333333) + c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f) + c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff) + c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff) + return c +} + +function ip2int(ip) { + for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x]) + return ret +} + +function int2ip(ip,ret,x) { + ret=and(ip,255) + ip=rshift(ip,8) + for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++); + return ret +} + +function compl32(v) { + ret=xor(v, 0xffffffff) + return ret +} + +BEGIN { + slpos=index(ARGV[1],"/") + if (slpos == 0) { + ipaddr=ip2int(ARGV[1]) + netmask=ip2int(ARGV[2]) + } else { + ipaddr=ip2int(substr(ARGV[1],0,slpos-1)) + netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1) + ARGV[4]=ARGV[3] + ARGV[3]=ARGV[2] + } + + network=and(ipaddr,netmask) + broadcast=or(network,compl32(netmask)) + + start=or(network,and(ip2int(ARGV[3]),compl32(netmask))) + limit=network+1 + if (start<limit) start=limit + + end=start+ARGV[4] + limit=or(network,compl32(netmask))-1 + if (end>limit) end=limit + + print "IP="int2ip(ipaddr) + print "NETMASK="int2ip(netmask) + print "BROADCAST="int2ip(broadcast) + print "NETWORK="int2ip(network) + print "PREFIX="32-bitcount(compl32(netmask)) + + # range calculations: + # ipcalc <ip> <netmask> <start> <num> + + if (ARGC > 3) { + print "START="int2ip(start) + print "END="int2ip(end) + } +} +EOF diff --git a/package/base-files/files/bin/.svn/text-base/login.sh.svn-base b/package/base-files/files/bin/.svn/text-base/login.sh.svn-base new file mode 100644 index 0000000..04b3fe2 --- /dev/null +++ b/package/base-files/files/bin/.svn/text-base/login.sh.svn-base @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2006-2011 OpenWrt.org + +if ( ! grep -qs '^root:[!x]\?:' /etc/shadow || \ + ! grep -qs '^root:[!x]\?:' /etc/passwd ) && \ + [ -z "$FAILSAFE" ] +then + echo "Login failed." + exit 0 +else +cat << EOF + === IMPORTANT ============================ + Use 'passwd' to set your login password + this will disable telnet and enable SSH + ------------------------------------------ +EOF +fi + +exec /bin/ash --login diff --git a/package/base-files/files/bin/ipcalc.sh b/package/base-files/files/bin/ipcalc.sh new file mode 100755 index 0000000..7463d6b --- /dev/null +++ b/package/base-files/files/bin/ipcalc.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +awk -f - $* <<EOF +function bitcount(c) { + c=and(rshift(c, 1),0x55555555)+and(c,0x55555555) + c=and(rshift(c, 2),0x33333333)+and(c,0x33333333) + c=and(rshift(c, 4),0x0f0f0f0f)+and(c,0x0f0f0f0f) + c=and(rshift(c, 8),0x00ff00ff)+and(c,0x00ff00ff) + c=and(rshift(c,16),0x0000ffff)+and(c,0x0000ffff) + return c +} + +function ip2int(ip) { + for (ret=0,n=split(ip,a,"\."),x=1;x<=n;x++) ret=or(lshift(ret,8),a[x]) + return ret +} + +function int2ip(ip,ret,x) { + ret=and(ip,255) + ip=rshift(ip,8) + for(;x<3;ret=and(ip,255)"."ret,ip=rshift(ip,8),x++); + return ret +} + +function compl32(v) { + ret=xor(v, 0xffffffff) + return ret +} + +BEGIN { + slpos=index(ARGV[1],"/") + if (slpos == 0) { + ipaddr=ip2int(ARGV[1]) + netmask=ip2int(ARGV[2]) + } else { + ipaddr=ip2int(substr(ARGV[1],0,slpos-1)) + netmask=compl32(2**(32-int(substr(ARGV[1],slpos+1)))-1) + ARGV[4]=ARGV[3] + ARGV[3]=ARGV[2] + } + + network=and(ipaddr,netmask) + broadcast=or(network,compl32(netmask)) + + start=or(network,and(ip2int(ARGV[3]),compl32(netmask))) + limit=network+1 + if (start<limit) start=limit + + end=start+ARGV[4] + limit=or(network,compl32(netmask))-1 + if (end>limit) end=limit + + print "IP="int2ip(ipaddr) + print "NETMASK="int2ip(netmask) + print "BROADCAST="int2ip(broadcast) + print "NETWORK="int2ip(network) + print "PREFIX="32-bitcount(compl32(netmask)) + + # range calculations: + # ipcalc <ip> <netmask> <start> <num> + + if (ARGC > 3) { + print "START="int2ip(start) + print "END="int2ip(end) + } +} +EOF diff --git a/package/base-files/files/bin/login.sh b/package/base-files/files/bin/login.sh new file mode 100755 index 0000000..04b3fe2 --- /dev/null +++ b/package/base-files/files/bin/login.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2006-2011 OpenWrt.org + +if ( ! grep -qs '^root:[!x]\?:' /etc/shadow || \ + ! grep -qs '^root:[!x]\?:' /etc/passwd ) && \ + [ -z "$FAILSAFE" ] +then + echo "Login failed." + exit 0 +else +cat << EOF + === IMPORTANT ============================ + Use 'passwd' to set your login password + this will disable telnet and enable SSH + ------------------------------------------ +EOF +fi + +exec /bin/ash --login diff --git a/package/base-files/files/etc/.svn/entries b/package/base-files/files/etc/.svn/entries new file mode 100644 index 0000000..2c24705 --- /dev/null +++ b/package/base-files/files/etc/.svn/entries @@ -0,0 +1,655 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc +svn://svn.openwrt.org/openwrt + + + +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +services +file + + + + +2013-03-17T12:13:22.000000Z +e30a9085944e0dd94ab277a512298256 +2012-03-18T19:41:57.122166Z +30982 +jow + + + + + + + + + + + + + + + + + + + + + +3017 + +protocols +file + + + + +2013-03-17T12:13:22.000000Z +e1b2c07d83ff5322a6353945a5c4b7e6 +2009-04-17T14:32:29.989894Z +15245 +nico +has-props + + + + + + + + + + + + + + + + + + + + +2478 + +shadow +file + + + + +2013-03-17T12:13:22.000000Z +497b070fd6e487f137756e9bce95b636 +2012-06-05T17:48:41.928094Z +32064 +jow + + + + + + + + + + + + + + + + + + + + + +116 + +init.d +dir + +uci-defaults +dir + +inittab +file + + + + +2013-03-17T12:13:22.000000Z +33da9049fd292d4f373c3df77a50c2dc +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +101 + +shells +file + + + + +2013-03-17T12:13:22.000000Z +725ba6f40dff0612f61ecd3f171bb3e1 +2009-04-17T14:32:29.989894Z +15245 +nico +has-props + + + + + + + + + + + + + + + + + + + + +9 + +rc.common +file + + + + +2013-03-17T12:13:22.000000Z +81ba79776061c56003b97406beeb576d +2012-12-22T18:56:09.693743Z +34866 +nbd +has-props + + + + + + + + + + + + + + + + + + + + +1936 + +group +file + + + + +2013-03-17T12:13:22.000000Z +4a116d818b2f49e14939d581ec786de1 +2011-03-13T19:04:32.620549Z +26136 +nbd +has-props + + + + + + + + + + + + + + + + + + + + +123 + +rc.local +file + + + + +2013-03-17T12:13:22.000000Z +6f8bfdaf36d3ec4aa9be6e96fa61d32b +2009-09-11T21:35:03.611393Z +17571 +jow + + + + + + + + + + + + + + + + + + + + + +132 + +openwrt_release +file + + + + +2013-03-17T12:13:22.000000Z +e65454ea1963a938321e039a13a1133a +2012-04-12T17:31:16.941025Z +31262 +jow + + + + + + + + + + + + + + + + + + + + + +132 + +profile +file + + + + +2013-03-17T12:13:22.000000Z +2729e95cc09e5f2a7ab9daae3d7ba857 +2012-08-08T15:37:34.343715Z +33057 +florian +has-props + + + + + + + + + + + + + + + + + + + + +480 + +hosts +file + + + + +2013-03-17T12:13:22.000000Z +0eea71665fb6890c06421fd13aa3f849 +2010-08-06T08:00:40.788334Z +22508 +hcg +has-props + + + + + + + + + + + + + + + + + + + + +20 + +passwd +file + + + + +2013-03-17T12:13:22.000000Z +8a31e6d3e2d67fc7b99f56055e9d802b +2011-11-14T19:02:01.362297Z +29130 +jow +has-props + + + + + + + + + + + + + + + + + + + + +190 + +openwrt_version +file + + + + +2013-03-17T12:13:22.000000Z +94281d3c396683cba598dd2864d7f87f +2012-04-12T17:31:16.941025Z +31262 +jow + + + + + + + + + + + + + + + + + + + + + +3 + +hotplug.d +dir + +config +dir + +banner +file + + + + +2013-03-17T12:13:22.000000Z +0990d6f5cdf9567cf2db81cec92011be +2012-10-08T13:12:37.637363Z +33666 +kaloz +has-props + + + + + + + + + + + + + + + + + + + + +629 + +sysctl.conf +file + + + + +2013-03-17T12:13:22.000000Z +4db5363559bbed076aed3f7d176963e8 +2013-01-29T10:13:33.182424Z +35368 +cyrus +has-props + + + + + + + + + + + + + + + + + + + + +838 + +preinit +file + + + + +2013-03-17T12:13:22.000000Z +2fba1ae4a1dfa8fb1d2703c0ce56b84f +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +901 + +sysupgrade.conf +file + + + + +2013-03-17T12:13:22.000000Z +f91aef484370cefee501d64b5725c1d2 +2010-10-05T19:24:12.942023Z +23258 +jow + + + + + + + + + + + + + + + + + + + + + +128 + +diag.sh +file + + + + +2013-03-17T12:13:22.000000Z +2db344b4341ef3a5b29ad05327a2039a +2009-04-30T21:00:57.896294Z +15527 +jow + + + + + + + + + + + + + + + + + + + + + +68 + +rc.button +dir + diff --git a/package/base-files/files/etc/.svn/prop-base/banner.svn-base b/package/base-files/files/etc/.svn/prop-base/banner.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/banner.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/group.svn-base b/package/base-files/files/etc/.svn/prop-base/group.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/group.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/hosts.svn-base b/package/base-files/files/etc/.svn/prop-base/hosts.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/hosts.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/inittab.svn-base b/package/base-files/files/etc/.svn/prop-base/inittab.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/inittab.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/passwd.svn-base b/package/base-files/files/etc/.svn/prop-base/passwd.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/passwd.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/preinit.svn-base b/package/base-files/files/etc/.svn/prop-base/preinit.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/preinit.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/.svn/prop-base/profile.svn-base b/package/base-files/files/etc/.svn/prop-base/profile.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/profile.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/protocols.svn-base b/package/base-files/files/etc/.svn/prop-base/protocols.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/protocols.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/rc.common.svn-base b/package/base-files/files/etc/.svn/prop-base/rc.common.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/rc.common.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/.svn/prop-base/shells.svn-base b/package/base-files/files/etc/.svn/prop-base/shells.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/shells.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base b/package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/.svn/prop-base/sysctl.conf.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/.svn/text-base/banner.svn-base b/package/base-files/files/etc/.svn/text-base/banner.svn-base new file mode 100644 index 0000000..3eed7df --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/banner.svn-base @@ -0,0 +1,13 @@ + _______ ________ __ + | |.-----.-----.-----.| | | |.----.| |_ + | - || _ | -__| || | | || _|| _| + |_______|| __|_____|__|__||________||__| |____| + |__| W I R E L E S S F R E E D O M + ----------------------------------------------------- + BARRIER BREAKER (%C, %R) + ----------------------------------------------------- + * 1/2 oz Galliano Pour all ingredients into + * 4 oz cold Coffee an irish coffee mug filled + * 1 1/2 oz Dark Rum with crushed ice. Stir. + * 2 tsp. Creme de Cacao + ----------------------------------------------------- diff --git a/package/base-files/files/etc/.svn/text-base/diag.sh.svn-base b/package/base-files/files/etc/.svn/text-base/diag.sh.svn-base new file mode 100644 index 0000000..8726a43 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/diag.sh.svn-base @@ -0,0 +1,4 @@ +#!/bin/sh +# Copyright (C) 2006-2009 OpenWrt.org + +set_state() { :; } diff --git a/package/base-files/files/etc/.svn/text-base/group.svn-base b/package/base-files/files/etc/.svn/text-base/group.svn-base new file mode 100644 index 0000000..d366851 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/group.svn-base @@ -0,0 +1,10 @@ +root:x:0: +daemon:x:1: +adm:x:4: +mail:x:8: +audio:x:29: +www-data:x:33: +ftp:x:55: +users:x:100: +network:x:101: +nogroup:x:65534: diff --git a/package/base-files/files/etc/.svn/text-base/hosts.svn-base b/package/base-files/files/etc/.svn/text-base/hosts.svn-base new file mode 100644 index 0000000..75721cd --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/hosts.svn-base @@ -0,0 +1 @@ +127.0.0.1 localhost diff --git a/package/base-files/files/etc/.svn/text-base/inittab.svn-base b/package/base-files/files/etc/.svn/text-base/inittab.svn-base new file mode 100644 index 0000000..7817185 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/inittab.svn-base @@ -0,0 +1,3 @@ +::sysinit:/etc/init.d/rcS S boot +::shutdown:/etc/init.d/rcS K shutdown +::askconsole:/bin/ash --login diff --git a/package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base b/package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base new file mode 100644 index 0000000..8ad2d9d --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/openwrt_release.svn-base @@ -0,0 +1,6 @@ +DISTRIB_ID="%D" +DISTRIB_RELEASE="%C" +DISTRIB_REVISION="%R" +DISTRIB_CODENAME="%n" +DISTRIB_TARGET="%S" +DISTRIB_DESCRIPTION="%D %N %V" diff --git a/package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base b/package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base new file mode 100644 index 0000000..4b14f59 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/openwrt_version.svn-base @@ -0,0 +1 @@ +%V diff --git a/package/base-files/files/etc/.svn/text-base/passwd.svn-base b/package/base-files/files/etc/.svn/text-base/passwd.svn-base new file mode 100644 index 0000000..1d06a80 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/passwd.svn-base @@ -0,0 +1,5 @@ +root:x:0:0:root:/root:/bin/ash +daemon:*:1:1:daemon:/var:/bin/false +ftp:*:55:55:ftp:/home/ftp:/bin/false +network:*:101:101:network:/var:/bin/false +nobody:*:65534:65534:nobody:/var:/bin/false diff --git a/package/base-files/files/etc/.svn/text-base/preinit.svn-base b/package/base-files/files/etc/.svn/text-base/preinit.svn-base new file mode 100644 index 0000000..ff26f96 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/preinit.svn-base @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +[ -z "$PREINIT" ] && exec /sbin/init + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +pi_ifname= +pi_ip=192.168.1.1 +pi_broadcast=192.168.1.255 +pi_netmask=255.255.255.0 + +fs_failsafe_ifname= +fs_failsafe_ip=192.168.1.1 +fs_failsafe_broadcast=192.168.1.255 +fs_failsafe_netmask=255.255.255.0 + +fs_failsafe_wait_timeout=2 + +pi_suppress_stderr="y" +pi_init_suppress_stderr="y" +pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin" +pi_init_cmd="/sbin/init" + +. /lib/functions.sh + +boot_hook_init preinit_essential +boot_hook_init preinit_main +boot_hook_init failsafe +boot_hook_init initramfs +boot_hook_init preinit_mount_root + +for pi_source_file in /lib/preinit/*; do + . $pi_source_file +done + +boot_run_hook preinit_essential + +pi_mount_skip_next=false +pi_jffs2_mount_success=false +pi_failsafe_net_message=false + +boot_run_hook preinit_main + diff --git a/package/base-files/files/etc/.svn/text-base/profile.svn-base b/package/base-files/files/etc/.svn/text-base/profile.svn-base new file mode 100644 index 0000000..171adc1 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/profile.svn-base @@ -0,0 +1,15 @@ +#!/bin/sh +[ -f /etc/banner ] && cat /etc/banner + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6) +export HOME=${HOME:-/root} +export PS1='\u@\h:\w\$ ' + +[ -x /bin/more ] || alias more=less +[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi + +[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc + +[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; } +[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } diff --git a/package/base-files/files/etc/.svn/text-base/protocols.svn-base b/package/base-files/files/etc/.svn/text-base/protocols.svn-base new file mode 100644 index 0000000..53fecb6 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/protocols.svn-base @@ -0,0 +1,56 @@ +# Internet (IP) protocols +# +# Updated from http://www.iana.org/assignments/protocol-numbers and other +# sources. +# New protocols will be added on request if they have been officially +# assigned by IANA and are not historical. +# If you need a huge list of used numbers please install the nmap package. + +ip 0 IP # internet protocol, pseudo protocol number +#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883] +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +igp 9 IGP # any private interior gateway (Cisco) +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905] +xtp 36 XTP # Xpress Transfer Protocol +ddp 37 DDP # Datagram Delivery Protocol +idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport +ipv6 41 IPv6 # Internet Protocol, version 6 +ipv6-route 43 IPv6-Route # Routing Header for IPv6 +ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 +idrp 45 IDRP # Inter-Domain Routing Protocol +rsvp 46 RSVP # Reservation Protocol +gre 47 GRE # General Routing Encapsulation +esp 50 IPSEC-ESP # Encap Security Payload [RFC2046] +ah 51 IPSEC-AH # Authentication Header [RFC2402] +skip 57 SKIP # SKIP +ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 +ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 +ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 +rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB) +vmtp 81 VMTP # Versatile Message Transport +eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco) +ospf 89 OSPFIGP # Open Shortest Path First IGP +ax.25 93 AX.25 # AX.25 frames +ipip 94 IPIP # IP-within-IP Encapsulation Protocol +etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378] +encap 98 ENCAP # Yet Another IP encapsulation [RFC1241] +# 99 # any private encryption scheme +pim 103 PIM # Protocol Independent Multicast +ipcomp 108 IPCOMP # IP Payload Compression Protocol +vrrp 112 VRRP # Virtual Router Redundancy Protocol +l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661] +isis 124 ISIS # IS-IS over IPv4 +sctp 132 SCTP # Stream Control Transmission Protocol +fc 133 FC # Fibre Channel + diff --git a/package/base-files/files/etc/.svn/text-base/rc.common.svn-base b/package/base-files/files/etc/.svn/text-base/rc.common.svn-base new file mode 100644 index 0000000..78e2dd4 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/rc.common.svn-base @@ -0,0 +1,116 @@ +#!/bin/sh +# Copyright (C) 2006-2012 OpenWrt.org + +. $IPKG_INSTROOT/lib/functions.sh +. $IPKG_INSTROOT/lib/functions/service.sh + +initscript=$1 +action=${2:-help} +shift 2 + +start() { + return 0 +} + +stop() { + return 0 +} + +reload() { + return 1 +} + +restart() { + trap '' TERM + stop "$@" + start "$@" +} + +boot() { + start "$@" +} + +shutdown() { + stop +} + +disable() { + name="$(basename "${initscript}")" + rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name + rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name +} + +enable() { + name="$(basename "${initscript}")" + disable + [ -n "$START" -o -n "$STOP" ] || { + echo "/etc/init.d/$name does not have a START or STOP value" + return 1 + } + [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" + [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" +} + +enabled() { + name="$(basename "${initscript}")" + [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ] +} + +depends() { + return 0 +} + +help() { + cat <<EOF +Syntax: $initscript [command] + +Available commands: + start Start the service + stop Stop the service + restart Restart the service + reload Reload configuration files (or restart if that fails) + enable Enable service autostart + disable Disable service autostart +$EXTRA_HELP +EOF +} + +# for procd +start_service() { + return 0 +} + +stop_service() { + return 0 +} + +${INIT_TRACE:+set -x} + +. "$initscript" + +[ -n "$USE_PROCD" ] && { + . $IPKG_INSTROOT/lib/functions/procd.sh + + rc_procd() { + procd_open_service "$(basename "$initscript")" "$initscript" + "$@" + procd_close_service + } + + start() { + rc_procd start_service "$@" + } + + stop() { + procd_kill "$(basename "$initscript")" "$1" + } + + reload() { + start + } +} + +ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}" +list_contains ALL_COMMANDS "$action" || action=help +[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :' +$action "$@" diff --git a/package/base-files/files/etc/.svn/text-base/rc.local.svn-base b/package/base-files/files/etc/.svn/text-base/rc.local.svn-base new file mode 100644 index 0000000..5639477 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/rc.local.svn-base @@ -0,0 +1,4 @@ +# Put your custom commands here that should be executed once +# the system init finished. By default this file does nothing. + +exit 0 diff --git a/package/base-files/files/etc/.svn/text-base/services.svn-base b/package/base-files/files/etc/.svn/text-base/services.svn-base new file mode 100644 index 0000000..a12853e --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/services.svn-base @@ -0,0 +1,171 @@ +echo 7/tcp +echo 7/udp +discard 9/tcp +discard 9/udp +daytime 13/tcp +daytime 13/udp +netstat 15/tcp +chargen 19/tcp +chargen 19/udp +ftp-data 20/tcp +ftp 21/tcp +ssh 22/tcp +ssh 22/udp +telnet 23/tcp +smtp 25/tcp +time 37/tcp +time 37/udp +whois 43/tcp +domain 53/tcp +domain 53/udp +bootps 67/tcp +bootps 67/udp +bootpc 68/tcp +bootpc 68/udp +tftp 69/udp +finger 79/tcp +www 80/tcp http +kerberos 88/tcp kerberos5 krb5 kerberos-sec +kerberos 88/udp kerberos5 krb5 kerberos-sec +pop3 110/tcp +pop3 110/udp +sunrpc 111/tcp +sunrpc 111/udp +auth 113/tcp ident +sftp 115/tcp +nntp 119/tcp +ntp 123/tcp +ntp 123/udp +netbios-ns 137/tcp +netbios-ns 137/udp +netbios-dgm 138/tcp +netbios-dgm 138/udp +netbios-ssn 139/tcp +netbios-ssn 139/udp +imap2 143/tcp imap +imap2 143/udp imap +snmp 161/tcp +snmp 161/udp +snmp-trap 162/tcp snmptrap +snmp-trap 162/udp snmptrap +xdmcp 177/tcp +xdmcp 177/udp +bgp 179/tcp +bgp 179/udp +imap3 220/tcp +imap3 220/udp +ldap 389/tcp +ldap 389/udp +https 443/tcp +https 443/udp +microsoft-ds 445/tcp +microsoft-ds 445/udp +isakmp 500/tcp +isakmp 500/udp +rtsp 554/tcp +rtsp 554/udp +ipp 631/tcp +ipp 631/udp +syslog 514/udp +printer 515/tcp spooler +dhcpv6-client 546/tcp +dhcpv6-client 546/udp +dhcpv6-server 547/tcp +dhcpv6-server 547/udp +afpovertcp 548/tcp +afpovertcp 548/udp +nntps 563/tcp snntp +nntps 563/udp snntp +ldaps 636/tcp +ldaps 636/udp +tinc 655/tcp +tinc 655/udp +rsync 873/tcp +rsync 873/udp +ftps-data 989/tcp +ftps 990/tcp +imaps 993/tcp +imaps 993/udp +ircs 994/tcp +ircs 994/udp +pop3s 995/tcp +pop3s 995/udp +socks 1080/tcp +socks 1080/udp +openvpn 1194/tcp +openvpn 1194/udp +l2f 1701/tcp l2tp +l2f 1701/udp l2tp +radius 1812/tcp +radius 1812/udp +radius-acct 1813/tcp radacct +radius-acct 1813/udp radacct +nfs 2049/tcp +nfs 2049/udp +dict 2628/tcp +dict 2628/udp +gpsd 2947/tcp +gpsd 2947/udp +icpv2 3130/tcp icp +icpv2 3130/udp icp +mysql 3306/tcp +mysql 3306/udp +nut 3493/tcp +nut 3493/udp +distcc 3632/tcp +distcc 3632/udp +daap 3689/tcp +daap 3689/udp +svn 3690/tcp subversion +svn 3690/udp subversion +epmd 4369/tcp +epmd 4369/udp +iax 4569/tcp +iax 4569/udp +mtn 4691/tcp +mtn 4691/udp +munin 4949/tcp +sip 5060/tcp +sip 5060/udp +sip-tls 5061/tcp +sip-tls 5061/udp +xmpp-client 5222/tcp jabber-client +xmpp-client 5222/udp jabber-client +xmpp-server 5269/tcp jabber-server +xmpp-server 5269/udp jabber-server +mdns 5353/tcp +mdns 5353/udp +postgresql 5432/tcp postgres +postgresql 5432/udp postgres +x11 6000/tcp +x11 6000/udp +mysql-proxy 6446/tcp +mysql-proxy 6446/udp +bacula-dir 9101/tcp +bacula-dir 9101/udp +bacula-fd 9102/tcp +bacula-fd 9102/udp +bacula-sd 9103/tcp +bacula-sd 9103/udp +nbd 10809/tcp +zabbix-agent 10050/tcp +zabbix-agent 10050/udp +zabbix-trapper 10051/tcp +zabbix-trapper 10051/udp +hkp 11371/tcp +hkp 11371/udp +ssmtp 465/tcp smtps +spamd 783/tcp +zebrasrv 2600/tcp +zebra 2601/tcp +ripd 2602/tcp +ripngd 2603/tcp +ospfd 2604/tcp +bgpd 2605/tcp +ospf6d 2606/tcp +ospfapi 2607/tcp +isisd 2608/tcp +sane-port 6566/tcp sane saned +ircd 6667/tcp +git 9418/tcp + diff --git a/package/base-files/files/etc/.svn/text-base/shadow.svn-base b/package/base-files/files/etc/.svn/text-base/shadow.svn-base new file mode 100644 index 0000000..e989890 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/shadow.svn-base @@ -0,0 +1,5 @@ +root:x:0:0:99999:7::: +daemon:*:0:0:99999:7::: +ftp:*:0:0:99999:7::: +network:*:0:0:99999:7::: +nobody:*:0:0:99999:7::: diff --git a/package/base-files/files/etc/.svn/text-base/shells.svn-base b/package/base-files/files/etc/.svn/text-base/shells.svn-base new file mode 100644 index 0000000..006aa38 --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/shells.svn-base @@ -0,0 +1 @@ +/bin/ash diff --git a/package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base b/package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base new file mode 100644 index 0000000..890e77a --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/sysctl.conf.svn-base @@ -0,0 +1,28 @@ +kernel.panic=3 +net.ipv4.conf.default.arp_ignore=1 +net.ipv4.conf.all.arp_ignore=1 +net.ipv4.ip_forward=1 +net.ipv4.icmp_echo_ignore_broadcasts=1 +net.ipv4.icmp_ignore_bogus_error_responses=1 +net.ipv4.tcp_ecn=0 +net.ipv4.tcp_fin_timeout=30 +net.ipv4.tcp_keepalive_time=120 +net.ipv4.tcp_syncookies=1 +net.ipv4.tcp_timestamps=1 +net.ipv4.tcp_sack=1 +net.ipv4.tcp_dsack=1 + +net.ipv6.conf.default.forwarding=2 +net.ipv6.conf.all.forwarding=2 + +net.netfilter.nf_conntrack_acct=1 +net.netfilter.nf_conntrack_checksum=0 +net.netfilter.nf_conntrack_max=16384 +net.netfilter.nf_conntrack_tcp_timeout_established=3600 +net.netfilter.nf_conntrack_udp_timeout=60 +net.netfilter.nf_conntrack_udp_timeout_stream=180 + +# disable bridge firewalling by default +net.bridge.bridge-nf-call-arptables=0 +net.bridge.bridge-nf-call-ip6tables=0 +net.bridge.bridge-nf-call-iptables=0 diff --git a/package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base b/package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base new file mode 100644 index 0000000..e06fd5e --- /dev/null +++ b/package/base-files/files/etc/.svn/text-base/sysupgrade.conf.svn-base @@ -0,0 +1,5 @@ +## This file contains files and directories that should +## be preserved during an upgrade. + +# /etc/example.conf +# /etc/openvpn/ diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner new file mode 100644 index 0000000..3eed7df --- /dev/null +++ b/package/base-files/files/etc/banner @@ -0,0 +1,13 @@ + _______ ________ __ + | |.-----.-----.-----.| | | |.----.| |_ + | - || _ | -__| || | | || _|| _| + |_______|| __|_____|__|__||________||__| |____| + |__| W I R E L E S S F R E E D O M + ----------------------------------------------------- + BARRIER BREAKER (%C, %R) + ----------------------------------------------------- + * 1/2 oz Galliano Pour all ingredients into + * 4 oz cold Coffee an irish coffee mug filled + * 1 1/2 oz Dark Rum with crushed ice. Stir. + * 2 tsp. Creme de Cacao + ----------------------------------------------------- diff --git a/package/base-files/files/etc/config/.svn/entries b/package/base-files/files/etc/config/.svn/entries new file mode 100644 index 0000000..3648004 --- /dev/null +++ b/package/base-files/files/etc/config/.svn/entries @@ -0,0 +1,96 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/config +svn://svn.openwrt.org/openwrt + + + +2012-04-20T15:05:38.003118Z +31374 +jow + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +system +file + + + + +2013-03-17T12:13:22.000000Z +8195f0ae675038c41766a9ff46e6e22b +2012-04-20T15:05:38.003118Z +31374 +jow + + + + + + + + + + + + + + + + + + + + + +251 + +network +file + + + + +2013-03-17T12:13:22.000000Z +e93532a4bbf699aa1affa01ea827e42c +2007-10-18T13:20:02.347557Z +9345 +florian +has-props + + + + + + + + + + + + + + + + + + + + +291 + diff --git a/package/base-files/files/etc/config/.svn/prop-base/network.svn-base b/package/base-files/files/etc/config/.svn/prop-base/network.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/etc/config/.svn/prop-base/network.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/etc/config/.svn/text-base/network.svn-base b/package/base-files/files/etc/config/.svn/text-base/network.svn-base new file mode 100644 index 0000000..a35fd2e --- /dev/null +++ b/package/base-files/files/etc/config/.svn/text-base/network.svn-base @@ -0,0 +1,14 @@ +# Copyright (C) 2006 OpenWrt.org + +config interface loopback + option ifname lo + option proto static + option ipaddr 127.0.0.1 + option netmask 255.0.0.0 + +config interface lan + option ifname eth0 + option type bridge + option proto static + option ipaddr 192.168.1.1 + option netmask 255.255.255.0 diff --git a/package/base-files/files/etc/config/.svn/text-base/system.svn-base b/package/base-files/files/etc/config/.svn/text-base/system.svn-base new file mode 100644 index 0000000..d2124e4 --- /dev/null +++ b/package/base-files/files/etc/config/.svn/text-base/system.svn-base @@ -0,0 +1,10 @@ +config system + option hostname OpenWrt + option timezone UTC + +config timeserver ntp + list server 0.openwrt.pool.ntp.org + list server 1.openwrt.pool.ntp.org + list server 2.openwrt.pool.ntp.org + list server 3.openwrt.pool.ntp.org + option enable_server 0 diff --git a/package/base-files/files/etc/config/network b/package/base-files/files/etc/config/network new file mode 100644 index 0000000..a35fd2e --- /dev/null +++ b/package/base-files/files/etc/config/network @@ -0,0 +1,14 @@ +# Copyright (C) 2006 OpenWrt.org + +config interface loopback + option ifname lo + option proto static + option ipaddr 127.0.0.1 + option netmask 255.0.0.0 + +config interface lan + option ifname eth0 + option type bridge + option proto static + option ipaddr 192.168.1.1 + option netmask 255.255.255.0 diff --git a/package/base-files/files/etc/config/system b/package/base-files/files/etc/config/system new file mode 100644 index 0000000..d2124e4 --- /dev/null +++ b/package/base-files/files/etc/config/system @@ -0,0 +1,10 @@ +config system + option hostname OpenWrt + option timezone UTC + +config timeserver ntp + list server 0.openwrt.pool.ntp.org + list server 1.openwrt.pool.ntp.org + list server 2.openwrt.pool.ntp.org + list server 3.openwrt.pool.ntp.org + option enable_server 0 diff --git a/package/base-files/files/etc/diag.sh b/package/base-files/files/etc/diag.sh new file mode 100644 index 0000000..8726a43 --- /dev/null +++ b/package/base-files/files/etc/diag.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# Copyright (C) 2006-2009 OpenWrt.org + +set_state() { :; } diff --git a/package/base-files/files/etc/group b/package/base-files/files/etc/group new file mode 100644 index 0000000..d366851 --- /dev/null +++ b/package/base-files/files/etc/group @@ -0,0 +1,10 @@ +root:x:0: +daemon:x:1: +adm:x:4: +mail:x:8: +audio:x:29: +www-data:x:33: +ftp:x:55: +users:x:100: +network:x:101: +nogroup:x:65534: diff --git a/package/base-files/files/etc/hosts b/package/base-files/files/etc/hosts new file mode 100644 index 0000000..75721cd --- /dev/null +++ b/package/base-files/files/etc/hosts @@ -0,0 +1 @@ +127.0.0.1 localhost diff --git a/package/base-files/files/etc/hotplug.d/.svn/entries b/package/base-files/files/etc/hotplug.d/.svn/entries new file mode 100644 index 0000000..507f6d3 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/.svn/entries @@ -0,0 +1,37 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d +svn://svn.openwrt.org/openwrt + + + +2011-10-27T00:21:53.293432Z +28612 +jow + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +iface +dir + +ieee1394 +dir + +usb +dir + diff --git a/package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries new file mode 100644 index 0000000..efb6d1a --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d/ieee1394 +svn://svn.openwrt.org/openwrt + + + +2009-01-30T20:48:42.263830Z +14289 +matein4 + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +10-ieee1394 +file + + + + +2013-03-17T12:13:21.000000Z +f461c4386f0170459c4fb27076b744ff +2009-01-30T20:48:42.263830Z +14289 +matein4 + + + + + + + + + + + + + + + + + + + + + +129 + diff --git a/package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base new file mode 100644 index 0000000..7e142a2 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/ieee1394/.svn/text-base/10-ieee1394.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2009 OpenWrt.org + +case "$ACTION" in + add) + # update LEDs + ;; + remove) + # update LEDs + ;; +esac + diff --git a/package/base-files/files/etc/hotplug.d/ieee1394/10-ieee1394 b/package/base-files/files/etc/hotplug.d/ieee1394/10-ieee1394 new file mode 100644 index 0000000..7e142a2 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/ieee1394/10-ieee1394 @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2009 OpenWrt.org + +case "$ACTION" in + add) + # update LEDs + ;; + remove) + # update LEDs + ;; +esac + diff --git a/package/base-files/files/etc/hotplug.d/iface/.svn/entries b/package/base-files/files/etc/hotplug.d/iface/.svn/entries new file mode 100644 index 0000000..32bba92 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/iface/.svn/entries @@ -0,0 +1,28 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d/iface +svn://svn.openwrt.org/openwrt + + + +2011-10-27T00:21:53.293432Z +28612 +jow + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + diff --git a/package/base-files/files/etc/hotplug.d/usb/.svn/entries b/package/base-files/files/etc/hotplug.d/usb/.svn/entries new file mode 100644 index 0000000..9a5db67 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/usb/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/hotplug.d/usb +svn://svn.openwrt.org/openwrt + + + +2009-01-30T20:48:42.263830Z +14289 +matein4 + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +10-usb +file + + + + +2013-03-17T12:13:22.000000Z +f461c4386f0170459c4fb27076b744ff +2009-01-30T20:48:42.263830Z +14289 +matein4 + + + + + + + + + + + + + + + + + + + + + +129 + diff --git a/package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base b/package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base new file mode 100644 index 0000000..7e142a2 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/usb/.svn/text-base/10-usb.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2009 OpenWrt.org + +case "$ACTION" in + add) + # update LEDs + ;; + remove) + # update LEDs + ;; +esac + diff --git a/package/base-files/files/etc/hotplug.d/usb/10-usb b/package/base-files/files/etc/hotplug.d/usb/10-usb new file mode 100644 index 0000000..7e142a2 --- /dev/null +++ b/package/base-files/files/etc/hotplug.d/usb/10-usb @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2009 OpenWrt.org + +case "$ACTION" in + add) + # update LEDs + ;; + remove) + # update LEDs + ;; +esac + diff --git a/package/base-files/files/etc/init.d/.svn/entries b/package/base-files/files/etc/init.d/.svn/entries new file mode 100644 index 0000000..a74462f --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/entries @@ -0,0 +1,300 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/init.d +svn://svn.openwrt.org/openwrt + + + +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +sysctl +file + + + + +2013-03-17T12:13:21.000000Z +61ac774a7ba9ca439a844b8f8f5a87c6 +2010-01-29T02:17:11.561959Z +19375 +nbd +has-props + + + + + + + + + + + + + + + + + + + + +126 + +boot +file + + + + +2013-03-17T12:13:21.000000Z +ecd43806409d103285be1083496374b9 +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +2060 + +led +file + + + + +2013-03-17T12:13:21.000000Z +c4a6d7e41ae14999903beed3a7020542 +2012-11-25T17:20:49.275876Z +34380 +juhosg +has-props + + + + + + + + + + + + + + + + + + + + +2015 + +sysntpd +file + + + + +2013-03-17T12:13:21.000000Z +16886218f83e3a85155e6b113bddbae3 +2012-04-20T15:05:38.003118Z +31374 +jow +has-props + + + + + + + + + + + + + + + + + + + + +586 + +done +file + + + + +2013-03-17T12:13:21.000000Z +55ac6eecca0123b6831d99276b06e20e +2009-09-11T21:35:03.611393Z +17571 +jow +has-props + + + + + + + + + + + + + + + + + + + + +318 + +rcS +file + + + + +2013-03-17T12:13:21.000000Z +06405a39a9ef1de751366f470d127f77 +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +183 + +umount +file + + + + +2013-03-17T12:13:21.000000Z +941cc99f8ba618f1725aec2f27d6e42b +2012-09-19T15:13:44.228696Z +33477 +florian +has-props + + + + + + + + + + + + + + + + + + + + +102 + +usb +file + + + + +2013-03-17T12:13:21.000000Z +12ca6574c481d2ce0483328532f691b3 +2012-12-19T16:07:46.450520Z +34792 +mirko +has-props + + + + + + + + + + + + + + + + + + + + +160 + diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/boot.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/done.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/led.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/rcS.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/sysctl.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/sysntpd.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/umount.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base b/package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/prop-base/usb.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base new file mode 100644 index 0000000..67db0d2 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/boot.svn-base @@ -0,0 +1,78 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=10 +STOP=98 + +system_config() { + local cfg="$1" + + local hostname conloglevel timezone + + config_get hostname "$cfg" hostname 'OpenWrt' + echo "$hostname" > /proc/sys/kernel/hostname + + config_get conloglevel "$cfg" conloglevel + config_get buffersize "$cfg" buffersize + [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} + + config_get timezone "$cfg" timezone 'UTC' + echo "$timezone" > /tmp/TZ + + config_get zonename "$cfg" zonename + [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime + + # apply timezone to kernel + date -k +} + +apply_uci_config() { + sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults' +} + +start() { + [ -f /proc/mounts ] || /sbin/mount_root + [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc + [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD + + mkdir -p /var/run + mkdir -p /var/log + mkdir -p /var/lock + mkdir -p /var/state + mkdir -p /tmp/.uci + chmod 0700 /tmp/.uci + touch /var/log/wtmp + touch /var/log/lastlog + touch /tmp/resolv.conf.auto + ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf + grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug + [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + + load_modules /etc/modules.d/* + + # allow wifi modules time to settle + sleep 1 + + /sbin/wifi detect > /tmp/wireless.tmp + [ -s /tmp/wireless.tmp ] && { + cat /tmp/wireless.tmp >> /etc/config/wireless + } + rm -f /tmp/wireless.tmp + + apply_uci_config + config_load system + config_foreach system_config system + + # create /dev/root if it doesn't exist + [ -e /dev/root -o -h /dev/root ] || { + rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline) + [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root + } + + # early sysctl to avoid networking races + if [ -d /proc/sys/net/ipv6/conf ]; then + for i in /proc/sys/net/ipv6/conf/*/accept_ra; do + echo 0 > $i + done + fi +} diff --git a/package/base-files/files/etc/init.d/.svn/text-base/done.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/done.svn-base new file mode 100644 index 0000000..8278669 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/done.svn-base @@ -0,0 +1,20 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=95 +boot() { + [ -d /tmp/root ] && { + lock /tmp/.switch2jffs + firstboot switch2jffs + lock -u /tmp/.switch2jffs + } + + # process user commands + [ -f /etc/rc.local ] && { + sh /etc/rc.local + } + + # set leds to normal state + . /etc/diag.sh + set_state done +} diff --git a/package/base-files/files/etc/init.d/.svn/text-base/led.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/led.svn-base new file mode 100644 index 0000000..729796b --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/led.svn-base @@ -0,0 +1,92 @@ +#!/bin/sh /etc/rc.common +# (C) 2008 openwrt.org + +START=96 + +load_led() { + local name + local sysfs + local trigger + local dev + local mode + local default + local delayon + local delayoff + local interval + + config_get sysfs $1 sysfs + config_get name $1 name "$sysfs" + config_get trigger $1 trigger "none" + config_get dev $1 dev + config_get mode $1 mode "link" + config_get_bool default $1 default "nil" + config_get delayon $1 delayon + config_get delayoff $1 delayoff + config_get interval $1 interval "50" + config_get port_state $1 port_state + config_get delay $1 delay "150" + config_get message $1 message "" + + if [ "$trigger" = "rssi" ]; then + # handled by rssileds userspace process + return + fi + + [ -e /sys/class/leds/${sysfs}/brightness ] && { + echo "setting up led ${name}" + [ "$default" != nil ] && { + [ $default -eq 1 ] && + echo 1 >/sys/class/leds/${sysfs}/brightness + [ $default -eq 1 ] || + echo 0 >/sys/class/leds/${sysfs}/brightness + } + echo $trigger > /sys/class/leds/${sysfs}/trigger + case "$trigger" in + "netdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $mode > /sys/class/leds/${sysfs}/mode + } + ;; + + "timer") + [ -n "$delayon" ] && \ + echo $delayon > /sys/class/leds/${sysfs}/delay_on + [ -n "$delayoff" ] && \ + echo $delayoff > /sys/class/leds/${sysfs}/delay_off + ;; + + "usbdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $interval > /sys/class/leds/${sysfs}/activity_interval + } + ;; + + "port_state") + [ -n "$port_state" ] && \ + echo $port_state > /sys/class/leds/${sysfs}/port_state + ;; + + "morse") + echo $message > /sys/class/leds/${sysfs}/message + echo $delay > /sys/class/leds/${sysfs}/delay + ;; + + switch[0-9]*) + local port_mask + + config_get port_mask $1 port_mask + [ -n "$port_mask" ] && \ + echo $port_mask > /sys/class/leds/${sysfs}/port_mask + ;; + esac + } +} + +start() { + [ -e /sys/class/leds/ ] && { + config_load system + config_foreach load_led led + } +} diff --git a/package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base new file mode 100644 index 0000000..9599bbf --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/rcS.svn-base @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +LOGGER="cat" +[ -x /usr/bin/logger ] && LOGGER="logger -p 6 -t sysinit" + +for i in /etc/rc.d/$1*; do + [ -x $i ] && $i $2 2>&1 +done | $LOGGER diff --git a/package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base new file mode 100644 index 0000000..2397790 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/sysctl.svn-base @@ -0,0 +1,7 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=99 +start() { + [ -f /etc/sysctl.conf ] && sysctl -p -e >&- +} diff --git a/package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base new file mode 100644 index 0000000..bb42ef7 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/sysntpd.svn-base @@ -0,0 +1,37 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2011 OpenWrt.org + +START=98 + +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 +SERVICE_PID_FILE=/var/run/sysntpd.pid + +start() { + local peers + local args="-n" + local enable_server + + config_load system + config_get peers ntp server + config_get_bool enable_server ntp enable_server 0 + + if [ $enable_server -ne 0 ]; then + append args "-l" + fi + + if [ -n "$peers" ]; then + local peer + for peer in $peers; do + append args "-p $peer" + done + fi + + if [ "$args" != "-n" ]; then + service_start /usr/sbin/ntpd $args + fi +} + +stop() { + service_stop /usr/sbin/ntpd +} diff --git a/package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base new file mode 100644 index 0000000..5a750b9 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/umount.svn-base @@ -0,0 +1,8 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +STOP=99 +stop() { + sync + umount -a -d -r +} diff --git a/package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base b/package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base new file mode 100644 index 0000000..43cdfd9 --- /dev/null +++ b/package/base-files/files/etc/init.d/.svn/text-base/usb.svn-base @@ -0,0 +1,9 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=39 +start() { + [ -d /proc/bus/usb ] && { + mount -o noatime -t usbfs none /proc/bus/usb + } +} diff --git a/package/base-files/files/etc/init.d/boot b/package/base-files/files/etc/init.d/boot new file mode 100755 index 0000000..67db0d2 --- /dev/null +++ b/package/base-files/files/etc/init.d/boot @@ -0,0 +1,78 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2011 OpenWrt.org + +START=10 +STOP=98 + +system_config() { + local cfg="$1" + + local hostname conloglevel timezone + + config_get hostname "$cfg" hostname 'OpenWrt' + echo "$hostname" > /proc/sys/kernel/hostname + + config_get conloglevel "$cfg" conloglevel + config_get buffersize "$cfg" buffersize + [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize} + + config_get timezone "$cfg" timezone 'UTC' + echo "$timezone" > /tmp/TZ + + config_get zonename "$cfg" zonename + [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime + + # apply timezone to kernel + date -k +} + +apply_uci_config() { + sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults' +} + +start() { + [ -f /proc/mounts ] || /sbin/mount_root + [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc + [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD + + mkdir -p /var/run + mkdir -p /var/log + mkdir -p /var/lock + mkdir -p /var/state + mkdir -p /tmp/.uci + chmod 0700 /tmp/.uci + touch /var/log/wtmp + touch /var/log/lastlog + touch /tmp/resolv.conf.auto + ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf + grep -q debugfs /proc/filesystems && mount -o noatime -t debugfs debugfs /sys/kernel/debug + [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe + + load_modules /etc/modules.d/* + + # allow wifi modules time to settle + sleep 1 + + /sbin/wifi detect > /tmp/wireless.tmp + [ -s /tmp/wireless.tmp ] && { + cat /tmp/wireless.tmp >> /etc/config/wireless + } + rm -f /tmp/wireless.tmp + + apply_uci_config + config_load system + config_foreach system_config system + + # create /dev/root if it doesn't exist + [ -e /dev/root -o -h /dev/root ] || { + rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline) + [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root + } + + # early sysctl to avoid networking races + if [ -d /proc/sys/net/ipv6/conf ]; then + for i in /proc/sys/net/ipv6/conf/*/accept_ra; do + echo 0 > $i + done + fi +} diff --git a/package/base-files/files/etc/init.d/done b/package/base-files/files/etc/init.d/done new file mode 100755 index 0000000..8278669 --- /dev/null +++ b/package/base-files/files/etc/init.d/done @@ -0,0 +1,20 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=95 +boot() { + [ -d /tmp/root ] && { + lock /tmp/.switch2jffs + firstboot switch2jffs + lock -u /tmp/.switch2jffs + } + + # process user commands + [ -f /etc/rc.local ] && { + sh /etc/rc.local + } + + # set leds to normal state + . /etc/diag.sh + set_state done +} diff --git a/package/base-files/files/etc/init.d/led b/package/base-files/files/etc/init.d/led new file mode 100755 index 0000000..729796b --- /dev/null +++ b/package/base-files/files/etc/init.d/led @@ -0,0 +1,92 @@ +#!/bin/sh /etc/rc.common +# (C) 2008 openwrt.org + +START=96 + +load_led() { + local name + local sysfs + local trigger + local dev + local mode + local default + local delayon + local delayoff + local interval + + config_get sysfs $1 sysfs + config_get name $1 name "$sysfs" + config_get trigger $1 trigger "none" + config_get dev $1 dev + config_get mode $1 mode "link" + config_get_bool default $1 default "nil" + config_get delayon $1 delayon + config_get delayoff $1 delayoff + config_get interval $1 interval "50" + config_get port_state $1 port_state + config_get delay $1 delay "150" + config_get message $1 message "" + + if [ "$trigger" = "rssi" ]; then + # handled by rssileds userspace process + return + fi + + [ -e /sys/class/leds/${sysfs}/brightness ] && { + echo "setting up led ${name}" + [ "$default" != nil ] && { + [ $default -eq 1 ] && + echo 1 >/sys/class/leds/${sysfs}/brightness + [ $default -eq 1 ] || + echo 0 >/sys/class/leds/${sysfs}/brightness + } + echo $trigger > /sys/class/leds/${sysfs}/trigger + case "$trigger" in + "netdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $mode > /sys/class/leds/${sysfs}/mode + } + ;; + + "timer") + [ -n "$delayon" ] && \ + echo $delayon > /sys/class/leds/${sysfs}/delay_on + [ -n "$delayoff" ] && \ + echo $delayoff > /sys/class/leds/${sysfs}/delay_off + ;; + + "usbdev") + [ -n "$dev" ] && { + echo $dev > /sys/class/leds/${sysfs}/device_name + echo $interval > /sys/class/leds/${sysfs}/activity_interval + } + ;; + + "port_state") + [ -n "$port_state" ] && \ + echo $port_state > /sys/class/leds/${sysfs}/port_state + ;; + + "morse") + echo $message > /sys/class/leds/${sysfs}/message + echo $delay > /sys/class/leds/${sysfs}/delay + ;; + + switch[0-9]*) + local port_mask + + config_get port_mask $1 port_mask + [ -n "$port_mask" ] && \ + echo $port_mask > /sys/class/leds/${sysfs}/port_mask + ;; + esac + } +} + +start() { + [ -e /sys/class/leds/ ] && { + config_load system + config_foreach load_led led + } +} diff --git a/package/base-files/files/etc/init.d/rcS b/package/base-files/files/etc/init.d/rcS new file mode 100755 index 0000000..9599bbf --- /dev/null +++ b/package/base-files/files/etc/init.d/rcS @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +LOGGER="cat" +[ -x /usr/bin/logger ] && LOGGER="logger -p 6 -t sysinit" + +for i in /etc/rc.d/$1*; do + [ -x $i ] && $i $2 2>&1 +done | $LOGGER diff --git a/package/base-files/files/etc/init.d/sysctl b/package/base-files/files/etc/init.d/sysctl new file mode 100755 index 0000000..2397790 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysctl @@ -0,0 +1,7 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=99 +start() { + [ -f /etc/sysctl.conf ] && sysctl -p -e >&- +} diff --git a/package/base-files/files/etc/init.d/sysntpd b/package/base-files/files/etc/init.d/sysntpd new file mode 100755 index 0000000..bb42ef7 --- /dev/null +++ b/package/base-files/files/etc/init.d/sysntpd @@ -0,0 +1,37 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2011 OpenWrt.org + +START=98 + +SERVICE_DAEMONIZE=1 +SERVICE_WRITE_PID=1 +SERVICE_PID_FILE=/var/run/sysntpd.pid + +start() { + local peers + local args="-n" + local enable_server + + config_load system + config_get peers ntp server + config_get_bool enable_server ntp enable_server 0 + + if [ $enable_server -ne 0 ]; then + append args "-l" + fi + + if [ -n "$peers" ]; then + local peer + for peer in $peers; do + append args "-p $peer" + done + fi + + if [ "$args" != "-n" ]; then + service_start /usr/sbin/ntpd $args + fi +} + +stop() { + service_stop /usr/sbin/ntpd +} diff --git a/package/base-files/files/etc/init.d/umount b/package/base-files/files/etc/init.d/umount new file mode 100755 index 0000000..5a750b9 --- /dev/null +++ b/package/base-files/files/etc/init.d/umount @@ -0,0 +1,8 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +STOP=99 +stop() { + sync + umount -a -d -r +} diff --git a/package/base-files/files/etc/init.d/usb b/package/base-files/files/etc/init.d/usb new file mode 100755 index 0000000..43cdfd9 --- /dev/null +++ b/package/base-files/files/etc/init.d/usb @@ -0,0 +1,9 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006 OpenWrt.org + +START=39 +start() { + [ -d /proc/bus/usb ] && { + mount -o noatime -t usbfs none /proc/bus/usb + } +} diff --git a/package/base-files/files/etc/inittab b/package/base-files/files/etc/inittab new file mode 100644 index 0000000..7817185 --- /dev/null +++ b/package/base-files/files/etc/inittab @@ -0,0 +1,3 @@ +::sysinit:/etc/init.d/rcS S boot +::shutdown:/etc/init.d/rcS K shutdown +::askconsole:/bin/ash --login diff --git a/package/base-files/files/etc/openwrt_release b/package/base-files/files/etc/openwrt_release new file mode 100644 index 0000000..8ad2d9d --- /dev/null +++ b/package/base-files/files/etc/openwrt_release @@ -0,0 +1,6 @@ +DISTRIB_ID="%D" +DISTRIB_RELEASE="%C" +DISTRIB_REVISION="%R" +DISTRIB_CODENAME="%n" +DISTRIB_TARGET="%S" +DISTRIB_DESCRIPTION="%D %N %V" diff --git a/package/base-files/files/etc/openwrt_version b/package/base-files/files/etc/openwrt_version new file mode 100644 index 0000000..4b14f59 --- /dev/null +++ b/package/base-files/files/etc/openwrt_version @@ -0,0 +1 @@ +%V diff --git a/package/base-files/files/etc/passwd b/package/base-files/files/etc/passwd new file mode 100644 index 0000000..1d06a80 --- /dev/null +++ b/package/base-files/files/etc/passwd @@ -0,0 +1,5 @@ +root:x:0:0:root:/root:/bin/ash +daemon:*:1:1:daemon:/var:/bin/false +ftp:*:55:55:ftp:/home/ftp:/bin/false +network:*:101:101:network:/var:/bin/false +nobody:*:65534:65534:nobody:/var:/bin/false diff --git a/package/base-files/files/etc/preinit b/package/base-files/files/etc/preinit new file mode 100755 index 0000000..ff26f96 --- /dev/null +++ b/package/base-files/files/etc/preinit @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +[ -z "$PREINIT" ] && exec /sbin/init + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin + +pi_ifname= +pi_ip=192.168.1.1 +pi_broadcast=192.168.1.255 +pi_netmask=255.255.255.0 + +fs_failsafe_ifname= +fs_failsafe_ip=192.168.1.1 +fs_failsafe_broadcast=192.168.1.255 +fs_failsafe_netmask=255.255.255.0 + +fs_failsafe_wait_timeout=2 + +pi_suppress_stderr="y" +pi_init_suppress_stderr="y" +pi_init_path="/bin:/sbin:/usr/bin:/usr/sbin" +pi_init_cmd="/sbin/init" + +. /lib/functions.sh + +boot_hook_init preinit_essential +boot_hook_init preinit_main +boot_hook_init failsafe +boot_hook_init initramfs +boot_hook_init preinit_mount_root + +for pi_source_file in /lib/preinit/*; do + . $pi_source_file +done + +boot_run_hook preinit_essential + +pi_mount_skip_next=false +pi_jffs2_mount_success=false +pi_failsafe_net_message=false + +boot_run_hook preinit_main + diff --git a/package/base-files/files/etc/profile b/package/base-files/files/etc/profile new file mode 100644 index 0000000..171adc1 --- /dev/null +++ b/package/base-files/files/etc/profile @@ -0,0 +1,15 @@ +#!/bin/sh +[ -f /etc/banner ] && cat /etc/banner + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +export HOME=$(grep -e "^${USER:-root}:" /etc/passwd | cut -d ":" -f 6) +export HOME=${HOME:-/root} +export PS1='\u@\h:\w\$ ' + +[ -x /bin/more ] || alias more=less +[ -x /usr/bin/vim ] && alias vi=vim || alias vim=vi + +[ -z "$KSH_VERSION" -o \! -s /etc/mkshrc ] || . /etc/mkshrc + +[ -x /usr/bin/arp ] || arp() { cat /proc/net/arp; } +[ -x /usr/bin/ldd ] || ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } diff --git a/package/base-files/files/etc/protocols b/package/base-files/files/etc/protocols new file mode 100644 index 0000000..53fecb6 --- /dev/null +++ b/package/base-files/files/etc/protocols @@ -0,0 +1,56 @@ +# Internet (IP) protocols +# +# Updated from http://www.iana.org/assignments/protocol-numbers and other +# sources. +# New protocols will be added on request if they have been officially +# assigned by IANA and are not historical. +# If you need a huge list of used numbers please install the nmap package. + +ip 0 IP # internet protocol, pseudo protocol number +#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883] +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +igp 9 IGP # any private interior gateway (Cisco) +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905] +xtp 36 XTP # Xpress Transfer Protocol +ddp 37 DDP # Datagram Delivery Protocol +idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport +ipv6 41 IPv6 # Internet Protocol, version 6 +ipv6-route 43 IPv6-Route # Routing Header for IPv6 +ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6 +idrp 45 IDRP # Inter-Domain Routing Protocol +rsvp 46 RSVP # Reservation Protocol +gre 47 GRE # General Routing Encapsulation +esp 50 IPSEC-ESP # Encap Security Payload [RFC2046] +ah 51 IPSEC-AH # Authentication Header [RFC2402] +skip 57 SKIP # SKIP +ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6 +ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6 +ipv6-opts 60 IPv6-Opts # Destination Options for IPv6 +rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB) +vmtp 81 VMTP # Versatile Message Transport +eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco) +ospf 89 OSPFIGP # Open Shortest Path First IGP +ax.25 93 AX.25 # AX.25 frames +ipip 94 IPIP # IP-within-IP Encapsulation Protocol +etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378] +encap 98 ENCAP # Yet Another IP encapsulation [RFC1241] +# 99 # any private encryption scheme +pim 103 PIM # Protocol Independent Multicast +ipcomp 108 IPCOMP # IP Payload Compression Protocol +vrrp 112 VRRP # Virtual Router Redundancy Protocol +l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661] +isis 124 ISIS # IS-IS over IPv4 +sctp 132 SCTP # Stream Control Transmission Protocol +fc 133 FC # Fibre Channel + diff --git a/package/base-files/files/etc/rc.button/.svn/entries b/package/base-files/files/etc/rc.button/.svn/entries new file mode 100644 index 0000000..5af1bb6 --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/entries @@ -0,0 +1,130 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/rc.button +svn://svn.openwrt.org/openwrt + + + +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +reset +file + + + + +2013-03-17T12:13:21.000000Z +b003e4351c706679936b223b8c0bf036 +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +277 + +rfkill +file + + + + +2013-03-17T12:13:21.000000Z +581e09365e2fd825aae743ab5e811513 +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +413 + +failsafe +file + + + + +2013-03-17T12:13:21.000000Z +073ed7a5c2da53d10353ba67f2babdc5 +2013-03-13T18:11:19.892934Z +36003 +blogic +has-props + + + + + + + + + + + + + + + + + + + + +37 + diff --git a/package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base b/package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/prop-base/failsafe.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base b/package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/prop-base/reset.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base b/package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/prop-base/rfkill.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base b/package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base new file mode 100644 index 0000000..dcdf7de --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/text-base/failsafe.svn-base @@ -0,0 +1,2 @@ +#!/bin/sh +touch /tmp/failsafe_button diff --git a/package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base b/package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base new file mode 100644 index 0000000..763994d --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/text-base/reset.svn-base @@ -0,0 +1,18 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +. /lib/functions.sh + +logger "$BUTTON pressed for $SEEN seconds" + +if [ "$SEEN" -lt 1 ] +then + echo "REBOOT" > /dev/console + sync + reboot +elif [ "$SEEN" -gt 5 ] +then + echo "FACTORY RESET" > /dev/console + firstboot && reboot & +fi diff --git a/package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base b/package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base new file mode 100644 index 0000000..7a8cfe9 --- /dev/null +++ b/package/base-files/files/etc/rc.button/.svn/text-base/rfkill.svn-base @@ -0,0 +1,23 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +. /lib/functions.sh + +local rfkill_state=0 + +wifi_rfkill_set() { + uci set wireless.$1.disabled=$rfkill_state +} + +wifi_rfkill_check() { + local disabled + config_get disabled $1 disabled + [ "$disabled" = "1" ] || rfkill_state=1 +} + +config_load wireless +config_foreach wifi_rfkill_check wifi-device +config_foreach wifi_rfkill_set wifi-device +uci commit wireless +wifi up diff --git a/package/base-files/files/etc/rc.button/failsafe b/package/base-files/files/etc/rc.button/failsafe new file mode 100755 index 0000000..dcdf7de --- /dev/null +++ b/package/base-files/files/etc/rc.button/failsafe @@ -0,0 +1,2 @@ +#!/bin/sh +touch /tmp/failsafe_button diff --git a/package/base-files/files/etc/rc.button/reset b/package/base-files/files/etc/rc.button/reset new file mode 100755 index 0000000..763994d --- /dev/null +++ b/package/base-files/files/etc/rc.button/reset @@ -0,0 +1,18 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +. /lib/functions.sh + +logger "$BUTTON pressed for $SEEN seconds" + +if [ "$SEEN" -lt 1 ] +then + echo "REBOOT" > /dev/console + sync + reboot +elif [ "$SEEN" -gt 5 ] +then + echo "FACTORY RESET" > /dev/console + firstboot && reboot & +fi diff --git a/package/base-files/files/etc/rc.button/rfkill b/package/base-files/files/etc/rc.button/rfkill new file mode 100755 index 0000000..7a8cfe9 --- /dev/null +++ b/package/base-files/files/etc/rc.button/rfkill @@ -0,0 +1,23 @@ +#!/bin/sh + +[ "${ACTION}" = "released" ] || exit 0 + +. /lib/functions.sh + +local rfkill_state=0 + +wifi_rfkill_set() { + uci set wireless.$1.disabled=$rfkill_state +} + +wifi_rfkill_check() { + local disabled + config_get disabled $1 disabled + [ "$disabled" = "1" ] || rfkill_state=1 +} + +config_load wireless +config_foreach wifi_rfkill_check wifi-device +config_foreach wifi_rfkill_set wifi-device +uci commit wireless +wifi up diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common new file mode 100755 index 0000000..78e2dd4 --- /dev/null +++ b/package/base-files/files/etc/rc.common @@ -0,0 +1,116 @@ +#!/bin/sh +# Copyright (C) 2006-2012 OpenWrt.org + +. $IPKG_INSTROOT/lib/functions.sh +. $IPKG_INSTROOT/lib/functions/service.sh + +initscript=$1 +action=${2:-help} +shift 2 + +start() { + return 0 +} + +stop() { + return 0 +} + +reload() { + return 1 +} + +restart() { + trap '' TERM + stop "$@" + start "$@" +} + +boot() { + start "$@" +} + +shutdown() { + stop +} + +disable() { + name="$(basename "${initscript}")" + rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name + rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name +} + +enable() { + name="$(basename "${initscript}")" + disable + [ -n "$START" -o -n "$STOP" ] || { + echo "/etc/init.d/$name does not have a START or STOP value" + return 1 + } + [ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" + [ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}" +} + +enabled() { + name="$(basename "${initscript}")" + [ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ] +} + +depends() { + return 0 +} + +help() { + cat <<EOF +Syntax: $initscript [command] + +Available commands: + start Start the service + stop Stop the service + restart Restart the service + reload Reload configuration files (or restart if that fails) + enable Enable service autostart + disable Disable service autostart +$EXTRA_HELP +EOF +} + +# for procd +start_service() { + return 0 +} + +stop_service() { + return 0 +} + +${INIT_TRACE:+set -x} + +. "$initscript" + +[ -n "$USE_PROCD" ] && { + . $IPKG_INSTROOT/lib/functions/procd.sh + + rc_procd() { + procd_open_service "$(basename "$initscript")" "$initscript" + "$@" + procd_close_service + } + + start() { + rc_procd start_service "$@" + } + + stop() { + procd_kill "$(basename "$initscript")" "$1" + } + + reload() { + start + } +} + +ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}" +list_contains ALL_COMMANDS "$action" || action=help +[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :' +$action "$@" diff --git a/package/base-files/files/etc/rc.local b/package/base-files/files/etc/rc.local new file mode 100644 index 0000000..5639477 --- /dev/null +++ b/package/base-files/files/etc/rc.local @@ -0,0 +1,4 @@ +# Put your custom commands here that should be executed once +# the system init finished. By default this file does nothing. + +exit 0 diff --git a/package/base-files/files/etc/services b/package/base-files/files/etc/services new file mode 100644 index 0000000..a12853e --- /dev/null +++ b/package/base-files/files/etc/services @@ -0,0 +1,171 @@ +echo 7/tcp +echo 7/udp +discard 9/tcp +discard 9/udp +daytime 13/tcp +daytime 13/udp +netstat 15/tcp +chargen 19/tcp +chargen 19/udp +ftp-data 20/tcp +ftp 21/tcp +ssh 22/tcp +ssh 22/udp +telnet 23/tcp +smtp 25/tcp +time 37/tcp +time 37/udp +whois 43/tcp +domain 53/tcp +domain 53/udp +bootps 67/tcp +bootps 67/udp +bootpc 68/tcp +bootpc 68/udp +tftp 69/udp +finger 79/tcp +www 80/tcp http +kerberos 88/tcp kerberos5 krb5 kerberos-sec +kerberos 88/udp kerberos5 krb5 kerberos-sec +pop3 110/tcp +pop3 110/udp +sunrpc 111/tcp +sunrpc 111/udp +auth 113/tcp ident +sftp 115/tcp +nntp 119/tcp +ntp 123/tcp +ntp 123/udp +netbios-ns 137/tcp +netbios-ns 137/udp +netbios-dgm 138/tcp +netbios-dgm 138/udp +netbios-ssn 139/tcp +netbios-ssn 139/udp +imap2 143/tcp imap +imap2 143/udp imap +snmp 161/tcp +snmp 161/udp +snmp-trap 162/tcp snmptrap +snmp-trap 162/udp snmptrap +xdmcp 177/tcp +xdmcp 177/udp +bgp 179/tcp +bgp 179/udp +imap3 220/tcp +imap3 220/udp +ldap 389/tcp +ldap 389/udp +https 443/tcp +https 443/udp +microsoft-ds 445/tcp +microsoft-ds 445/udp +isakmp 500/tcp +isakmp 500/udp +rtsp 554/tcp +rtsp 554/udp +ipp 631/tcp +ipp 631/udp +syslog 514/udp +printer 515/tcp spooler +dhcpv6-client 546/tcp +dhcpv6-client 546/udp +dhcpv6-server 547/tcp +dhcpv6-server 547/udp +afpovertcp 548/tcp +afpovertcp 548/udp +nntps 563/tcp snntp +nntps 563/udp snntp +ldaps 636/tcp +ldaps 636/udp +tinc 655/tcp +tinc 655/udp +rsync 873/tcp +rsync 873/udp +ftps-data 989/tcp +ftps 990/tcp +imaps 993/tcp +imaps 993/udp +ircs 994/tcp +ircs 994/udp +pop3s 995/tcp +pop3s 995/udp +socks 1080/tcp +socks 1080/udp +openvpn 1194/tcp +openvpn 1194/udp +l2f 1701/tcp l2tp +l2f 1701/udp l2tp +radius 1812/tcp +radius 1812/udp +radius-acct 1813/tcp radacct +radius-acct 1813/udp radacct +nfs 2049/tcp +nfs 2049/udp +dict 2628/tcp +dict 2628/udp +gpsd 2947/tcp +gpsd 2947/udp +icpv2 3130/tcp icp +icpv2 3130/udp icp +mysql 3306/tcp +mysql 3306/udp +nut 3493/tcp +nut 3493/udp +distcc 3632/tcp +distcc 3632/udp +daap 3689/tcp +daap 3689/udp +svn 3690/tcp subversion +svn 3690/udp subversion +epmd 4369/tcp +epmd 4369/udp +iax 4569/tcp +iax 4569/udp +mtn 4691/tcp +mtn 4691/udp +munin 4949/tcp +sip 5060/tcp +sip 5060/udp +sip-tls 5061/tcp +sip-tls 5061/udp +xmpp-client 5222/tcp jabber-client +xmpp-client 5222/udp jabber-client +xmpp-server 5269/tcp jabber-server +xmpp-server 5269/udp jabber-server +mdns 5353/tcp +mdns 5353/udp +postgresql 5432/tcp postgres +postgresql 5432/udp postgres +x11 6000/tcp +x11 6000/udp +mysql-proxy 6446/tcp +mysql-proxy 6446/udp +bacula-dir 9101/tcp +bacula-dir 9101/udp +bacula-fd 9102/tcp +bacula-fd 9102/udp +bacula-sd 9103/tcp +bacula-sd 9103/udp +nbd 10809/tcp +zabbix-agent 10050/tcp +zabbix-agent 10050/udp +zabbix-trapper 10051/tcp +zabbix-trapper 10051/udp +hkp 11371/tcp +hkp 11371/udp +ssmtp 465/tcp smtps +spamd 783/tcp +zebrasrv 2600/tcp +zebra 2601/tcp +ripd 2602/tcp +ripngd 2603/tcp +ospfd 2604/tcp +bgpd 2605/tcp +ospf6d 2606/tcp +ospfapi 2607/tcp +isisd 2608/tcp +sane-port 6566/tcp sane saned +ircd 6667/tcp +git 9418/tcp + diff --git a/package/base-files/files/etc/shadow b/package/base-files/files/etc/shadow new file mode 100644 index 0000000..e989890 --- /dev/null +++ b/package/base-files/files/etc/shadow @@ -0,0 +1,5 @@ +root:x:0:0:99999:7::: +daemon:*:0:0:99999:7::: +ftp:*:0:0:99999:7::: +network:*:0:0:99999:7::: +nobody:*:0:0:99999:7::: diff --git a/package/base-files/files/etc/shells b/package/base-files/files/etc/shells new file mode 100644 index 0000000..006aa38 --- /dev/null +++ b/package/base-files/files/etc/shells @@ -0,0 +1 @@ +/bin/ash diff --git a/package/base-files/files/etc/sysctl.conf b/package/base-files/files/etc/sysctl.conf new file mode 100644 index 0000000..890e77a --- /dev/null +++ b/package/base-files/files/etc/sysctl.conf @@ -0,0 +1,28 @@ +kernel.panic=3 +net.ipv4.conf.default.arp_ignore=1 +net.ipv4.conf.all.arp_ignore=1 +net.ipv4.ip_forward=1 +net.ipv4.icmp_echo_ignore_broadcasts=1 +net.ipv4.icmp_ignore_bogus_error_responses=1 +net.ipv4.tcp_ecn=0 +net.ipv4.tcp_fin_timeout=30 +net.ipv4.tcp_keepalive_time=120 +net.ipv4.tcp_syncookies=1 +net.ipv4.tcp_timestamps=1 +net.ipv4.tcp_sack=1 +net.ipv4.tcp_dsack=1 + +net.ipv6.conf.default.forwarding=2 +net.ipv6.conf.all.forwarding=2 + +net.netfilter.nf_conntrack_acct=1 +net.netfilter.nf_conntrack_checksum=0 +net.netfilter.nf_conntrack_max=16384 +net.netfilter.nf_conntrack_tcp_timeout_established=3600 +net.netfilter.nf_conntrack_udp_timeout=60 +net.netfilter.nf_conntrack_udp_timeout_stream=180 + +# disable bridge firewalling by default +net.bridge.bridge-nf-call-arptables=0 +net.bridge.bridge-nf-call-ip6tables=0 +net.bridge.bridge-nf-call-iptables=0 diff --git a/package/base-files/files/etc/sysupgrade.conf b/package/base-files/files/etc/sysupgrade.conf new file mode 100644 index 0000000..e06fd5e --- /dev/null +++ b/package/base-files/files/etc/sysupgrade.conf @@ -0,0 +1,5 @@ +## This file contains files and directories that should +## be preserved during an upgrade. + +# /etc/example.conf +# /etc/openvpn/ diff --git a/package/base-files/files/etc/uci-defaults/.svn/entries b/package/base-files/files/etc/uci-defaults/.svn/entries new file mode 100644 index 0000000..684e703 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/.svn/entries @@ -0,0 +1,130 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/etc/uci-defaults +svn://svn.openwrt.org/openwrt + + + +2013-01-18T12:46:43.271056Z +35218 +jow + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +12_network-generate-ula +file + + + + +2013-03-17T12:13:21.000000Z +78decd5e0f603eb024b4f4ad020ab3fe +2013-01-18T12:46:43.271056Z +35218 +jow + + + + + + + + + + + + + + + + + + + + + +565 + +11_migrate-sysctl +file + + + + +2013-03-17T12:13:21.000000Z +971ed444a917abd1be86faa1ae82e868 +2013-01-18T12:46:43.271056Z +35218 +jow + + + + + + + + + + + + + + + + + + + + + +451 + +10_migrate-shadow +file + + + + +2013-03-17T12:13:21.000000Z +83550010e2d2318b21225909bb42e771 +2013-01-18T12:46:43.271056Z +35218 +jow + + + + + + + + + + + + + + + + + + + + + +418 + diff --git a/package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base b/package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base new file mode 100644 index 0000000..b7ea571 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/.svn/text-base/10_migrate-shadow.svn-base @@ -0,0 +1,12 @@ +#!/bin/sh + +local ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" +local spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)" + +if [ -n "${ppwd#[\!x]}" ] && [ -z "${spwd#[\!x]}" ]; then + logger -t migrate-shadow "Moving root password hash into shadow database" + sed -i -e "s:^root\:[^\:]*\::root\:x\::" /etc/passwd + sed -i -e "s:^root\:[^\:]*\::root\:$ppwd\::" /etc/shadow +fi + +exit 0 diff --git a/package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base b/package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base new file mode 100644 index 0000000..b3796a4 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/.svn/text-base/11_migrate-sysctl.svn-base @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ ! -f "/rom/etc/sysctl.conf" ] || cmp -s "/rom/etc/sysctl.conf" "/etc/sysctl.conf"; then + exit 0 +fi + +fingerprint="$(md5sum /etc/sysctl.conf)" +fingerprint="${fingerprint%% *}" + +if [ "$fingerprint" = "1b05ebb41f72cb84e5510573cd4aca26" ] || \ + [ "$fingerprint" = "62deb895be1a7f496040187b7c930e4e" ]; then + logger -t migrate-sysctl "Updating sysctl.conf to use current defaults" + cp "/rom/etc/sysctl.conf" "/etc/sysctl.conf" +fi + +exit 0 + diff --git a/package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base b/package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base new file mode 100644 index 0000000..f3e4931 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/.svn/text-base/12_network-generate-ula.svn-base @@ -0,0 +1,18 @@ +#!/bin/sh + +[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0 +# Sometimes results are empty, therefore try until it works... +local r1 r2 r3 +while [ -z "$r1" -o -z "$r2" -o -z "$r3" ]; do + r1=$(printf "%02x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 256))) + r2=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536))) + r3=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536))) +done + +uci -q batch <<-EOF >/dev/null + set network.globals.ula_prefix=fd$r1:$r2:$r3::/48 + commit network +EOF + +exit 0 + diff --git a/package/base-files/files/etc/uci-defaults/10_migrate-shadow b/package/base-files/files/etc/uci-defaults/10_migrate-shadow new file mode 100644 index 0000000..b7ea571 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/10_migrate-shadow @@ -0,0 +1,12 @@ +#!/bin/sh + +local ppwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/passwd)" +local spwd="$(sed -ne '/^root:/s/^root:\([^:]*\):.*$/\1/p' /etc/shadow)" + +if [ -n "${ppwd#[\!x]}" ] && [ -z "${spwd#[\!x]}" ]; then + logger -t migrate-shadow "Moving root password hash into shadow database" + sed -i -e "s:^root\:[^\:]*\::root\:x\::" /etc/passwd + sed -i -e "s:^root\:[^\:]*\::root\:$ppwd\::" /etc/shadow +fi + +exit 0 diff --git a/package/base-files/files/etc/uci-defaults/11_migrate-sysctl b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl new file mode 100644 index 0000000..b3796a4 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/11_migrate-sysctl @@ -0,0 +1,17 @@ +#!/bin/sh + +if [ ! -f "/rom/etc/sysctl.conf" ] || cmp -s "/rom/etc/sysctl.conf" "/etc/sysctl.conf"; then + exit 0 +fi + +fingerprint="$(md5sum /etc/sysctl.conf)" +fingerprint="${fingerprint%% *}" + +if [ "$fingerprint" = "1b05ebb41f72cb84e5510573cd4aca26" ] || \ + [ "$fingerprint" = "62deb895be1a7f496040187b7c930e4e" ]; then + logger -t migrate-sysctl "Updating sysctl.conf to use current defaults" + cp "/rom/etc/sysctl.conf" "/etc/sysctl.conf" +fi + +exit 0 + diff --git a/package/base-files/files/etc/uci-defaults/12_network-generate-ula b/package/base-files/files/etc/uci-defaults/12_network-generate-ula new file mode 100644 index 0000000..f3e4931 --- /dev/null +++ b/package/base-files/files/etc/uci-defaults/12_network-generate-ula @@ -0,0 +1,18 @@ +#!/bin/sh + +[ "$(uci get network.globals.ula_prefix)" != "auto" ] && exit 0 +# Sometimes results are empty, therefore try until it works... +local r1 r2 r3 +while [ -z "$r1" -o -z "$r2" -o -z "$r3" ]; do + r1=$(printf "%02x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 256))) + r2=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536))) + r3=$(printf "%01x" $(($(</dev/urandom tr -dc 0-9 | dd bs=9 count=1) % 65536))) +done + +uci -q batch <<-EOF >/dev/null + set network.globals.ula_prefix=fd$r1:$r2:$r3::/48 + commit network +EOF + +exit 0 + diff --git a/package/base-files/files/lib/.svn/entries b/package/base-files/files/lib/.svn/entries new file mode 100644 index 0000000..21f5ce2 --- /dev/null +++ b/package/base-files/files/lib/.svn/entries @@ -0,0 +1,74 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib +svn://svn.openwrt.org/openwrt + + + +2013-03-14T18:43:58.957223Z +36031 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +functions.sh +file + + + + +2013-03-17T12:13:21.000000Z +fe79064449aba26886754ab55bcb160c +2013-02-17T21:47:03.007046Z +35646 +juhosg +has-props + + + + + + + + + + + + + + + + + + + + +11174 + +upgrade +dir + +functions +dir + +preinit +dir + +firstboot +dir + diff --git a/package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base b/package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/lib/.svn/prop-base/functions.sh.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/lib/.svn/text-base/functions.sh.svn-base b/package/base-files/files/lib/.svn/text-base/functions.sh.svn-base new file mode 100644 index 0000000..f51bfea --- /dev/null +++ b/package/base-files/files/lib/.svn/text-base/functions.sh.svn-base @@ -0,0 +1,543 @@ +#!/bin/sh +# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> +# Copyright (C) 2010 Vertical Communications + + +debug () { + ${DEBUG:-:} "$@" +} + +# newline +N=" +" + +_C=0 +NO_EXPORT=1 +LOAD_STATE=1 +LIST_SEP=" " + +hotplug_dev() { + env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug-call net +} + +append() { + local var="$1" + local value="$2" + local sep="${3:- }" + + eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\"" +} + +list_contains() { + local var="$1" + local str="$2" + local val + + eval "val=\" \${$var} \"" + [ "${val%% $str *}" != "$val" ] +} + +list_remove() { + local var="$1" + local remove="$2" + local val + + eval "val=\" \${$var} \"" + val1="${val%% $remove *}" + [ "$val1" = "$val" ] && return + val2="${val##* $remove }" + [ "$val2" = "$val" ] && return + val="${val1## } ${val2%% }" + val="${val%% }" + eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\"" +} + +config_load() { + [ -n "$IPKG_INSTROOT" ] && return 0 + uci_load "$@" +} + +reset_cb() { + config_cb() { return 0; } + option_cb() { return 0; } + list_cb() { return 0; } +} +reset_cb + +package() { + return 0 +} + +config () { + local cfgtype="$1" + local name="$2" + + export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1)) + name="${name:-cfg$CONFIG_NUM_SECTIONS}" + append CONFIG_SECTIONS "$name" + [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name" + export ${NO_EXPORT:+-n} CONFIG_SECTION="$name" + export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype" +} + +option () { + local varname="$1"; shift + local value="$*" + + export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value" + [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*" +} + +list() { + local varname="$1"; shift + local value="$*" + local len + + config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0 + [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}" + len=$(($len + 1)) + config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value" + config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len" + append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP" + list_cb "$varname" "$*" +} + +config_rename() { + local OLD="$1" + local NEW="$2" + local oldvar + local newvar + + [ -n "$OLD" -a -n "$NEW" ] || return + for oldvar in `set | grep ^CONFIG_${OLD}_ | \ + sed -e 's/\(.*\)=.*$/\1/'` ; do + newvar="CONFIG_${NEW}_${oldvar##CONFIG_${OLD}_}" + eval "export ${NO_EXPORT:+-n} \"$newvar=\${$oldvar}\"" + unset "$oldvar" + done + export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , $NEW ,")" + + [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW" +} + +config_unset() { + config_set "$1" "$2" "" +} + +config_clear() { + local SECTION="$1" + local oldvar + + list_remove CONFIG_SECTIONS "$SECTION" + export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}" + + for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \ + sed -e 's/\(.*\)=.*$/\1/'` ; do + unset $oldvar + done +} + +# config_get <variable> <section> <option> [<default>] +# config_get <section> <option> +config_get() { + case "$3" in + "") eval echo "\${CONFIG_${1}_${2}:-\${4}}";; + *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";; + esac +} + +# config_get_bool <variable> <section> <option> [<default>] +config_get_bool() { + local _tmp + config_get _tmp "$2" "$3" "$4" + case "$_tmp" in + 1|on|true|enabled) _tmp=1;; + 0|off|false|disabled) _tmp=0;; + *) _tmp="$4";; + esac + export ${NO_EXPORT:+-n} "$1=$_tmp" +} + +config_set() { + local section="$1" + local option="$2" + local value="$3" + local old_section="$CONFIG_SECTION" + + CONFIG_SECTION="$section" + option "$option" "$value" + CONFIG_SECTION="$old_section" +} + +config_foreach() { + local ___function="$1" + [ "$#" -ge 1 ] && shift + local ___type="$1" + [ "$#" -ge 1 ] && shift + local section cfgtype + + [ -z "$CONFIG_SECTIONS" ] && return 0 + for section in ${CONFIG_SECTIONS}; do + config_get cfgtype "$section" TYPE + [ -n "$___type" -a "x$cfgtype" != "x$___type" ] && continue + eval "$___function \"\$section\" \"\$@\"" + done +} + +config_list_foreach() { + [ "$#" -ge 3 ] || return 0 + local section="$1"; shift + local option="$1"; shift + local function="$1"; shift + local val + local len + local c=1 + + config_get len "${section}" "${option}_LENGTH" + [ -z "$len" ] && return 0 + while [ $c -le "$len" ]; do + config_get val "${section}" "${option}_ITEM$c" + eval "$function \"\$val\" \"\$@\"" + c="$(($c + 1))" + done +} + +load_modules() { + [ -d /etc/modules.d ] && { + cd /etc/modules.d + sed 's/^[^#]/insmod &/' $* | ash 2>&- || : + } +} + +include() { + local file + + for file in $(ls $1/*.sh 2>/dev/null); do + . $file + done +} + +find_mtd_index() { + local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" + local INDEX="${PART##mtd}" + + echo ${INDEX} +} + +find_mtd_part() { + local INDEX=$(find_mtd_index "$1") + local PREFIX=/dev/mtdblock + + [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ + echo "${INDEX:+$PREFIX$INDEX}" +} + +find_mtd_chardev() { + local INDEX=$(find_mtd_index "$1") + local PREFIX=/dev/mtd + + [ -d /dev/mtd ] && PREFIX=/dev/mtd/ + echo "${INDEX:+$PREFIX$INDEX}" +} + +mtd_get_mac_ascii() +{ + local mtdname="$1" + local key="$2" + local part + local mac_dirty + + . /lib/functions.sh + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2 + return + fi + + mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p') + # "canonicalize" mac + printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x} +} + +mtd_get_mac_binary() { + local mtdname="$1" + local offset="$2" + local part + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_mac_binary: partition $mtdname not found!" >&2 + return + fi + + dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"' +} + +macaddr_add() { + local mac=$1 + local val=$2 + local oui=${mac%:*:*:*} + local nic=${mac#*:*:*:} + + nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') + echo $oui:$nic +} + +macaddr_setbit_la() +{ + local mac=$1 + + printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} +} + +macaddr_2bin() +{ + local mac=$1 + + echo -ne \\x${mac//:/\\x} +} + +strtok() { # <string> { <variable> [<separator>] ... } + local tmp + local val="$1" + local count=0 + + shift + + while [ $# -gt 1 ]; do + tmp="${val%%$2*}" + + [ "$tmp" = "$val" ] && break + + val="${val#$tmp$2}" + + export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1)) + shift 2 + done + + if [ $# -gt 0 -a -n "$val" ]; then + export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1)) + fi + + return $count +} + + +jffs2_mark_erase() { + local part="$(find_mtd_part "$1")" + [ -z "$part" ] && { + echo Partition not found. + return 1 + } + echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1" +} + +uci_apply_defaults() { + cd /etc/uci-defaults || return 0 + files="$(ls)" + [ -z "$files" ] && return 0 + mkdir -p /tmp/.uci + for file in $files; do + ( . "./$(basename $file)" ) && rm -f "$file" + done + uci commit +} + +group_add() { + local name="$1" + local gid="$2" + local rc + [ -f "${IPKG_INSTROOT}/etc/group" ] || return 1 + [ -n "$IPKG_INSTROOT" ] || lock /var/lock/group + echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group + rc=$? + [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group + return $rc +} + +group_exists() { + grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group +} + +user_add() { + local name="${1}" + local uid="${2}" + local gid="${3:-$2}" + local desc="${4:-$1}" + local home="${5:-/var/run/$1}" + local shell="${6:-/bin/false}" + local rc + [ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1 + [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd + echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd + echo "${name}:x:0:0:99999:7:::" >> ${IPKG_INSTROOT}/etc/shadow + rc=$? + [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd + return $rc +} + +user_exists() { + grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd +} + + +pi_include() { + if [ -f "/tmp/overlay/$1" ]; then + . "/tmp/overlay/$1" + elif [ -f "$1" ]; then + . "$1" + elif [ -d "/tmp/overlay/$1" ]; then + if [ -n "$(ls /tmp/overlay/$1/*.sh 2>/dev/null)" ]; then + for src_script in /tmp/overlay/$1/*.sh; do + . "$src_script" + done + fi + elif [ -d "$1" ]; then + if [ -n "$(ls $1/*.sh 2>/dev/null)" ]; then + for src_script in $1/*.sh; do + . "$src_script" + done + fi + else + echo "WARNING: $1 not found" + return 1 + fi + return 0 +} + +boot_hook_splice_start() { + export -n PI_HOOK_SPLICE=1 +} + +boot_hook_splice_finish() { + local hook + for hook in $PI_STACK_LIST; do + local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook" + export -n "${hook}=${v% }" + export -n "${hook}_splice=" + done + export -n PI_HOOK_SPLICE= +} + +boot_hook_init() { + local hook="${1}_hook" + export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook" + export -n "$hook=" +} + +boot_hook_add() { + local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}" + local func="${2}" + + [ -n "$func" ] && { + local v; eval "v=\$$hook" + export -n "$hook=${v:+$v }$func" + } +} + +boot_hook_shift() { + local hook="${1}_hook" + local rvar="${2}" + + local v; eval "v=\$$hook" + [ -n "$v" ] && { + local first="${v%% *}" + + [ "$v" != "${v#* }" ] && \ + export -n "$hook=${v#* }" || \ + export -n "$hook=" + + export -n "$rvar=$first" + return 0 + } + + return 1 +} + +boot_run_hook() { + local hook="$1" + local func + + while boot_hook_shift "$hook" func; do + local ran; eval "ran=\$PI_RAN_$func" + [ -n "$ran" ] || { + export -n "PI_RAN_$func=1" + $func "$1" "$2" + } + done +} + +jffs2_ready() { + mtdpart="$(find_mtd_part rootfs_data)" + [ -z "$mtdpart" ] && return 1 + magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"') + [ "$magic" != "deadc0de" ] +} + +dupe() { # <new_root> <old_root> + cd $1 + echo -n "creating directories... " + { + cd $2 + find . -xdev -type d + echo "./dev ./overlay ./mnt ./proc ./tmp" + # xdev skips mounted directories + cd $1 + } | xargs mkdir -p + echo "done" + + echo -n "setting up symlinks... " + for file in $(cd $2; find . -xdev -type f;); do + case "$file" in + ./rom/note) ;; #nothing + ./etc/config*|\ + ./usr/lib/opkg/info/*) cp -af $2/$file $file;; + *) ln -sf /rom/${file#./*} $file;; + esac + done + for file in $(cd $2; find . -xdev -type l;); do + cp -af $2/${file#./*} $file + done + echo "done" +} + +pivot() { # <new_root> <old_root> + mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 && { + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/sys /sys 2>&- + mount -o noatime,move $2/overlay /overlay 2>&- + return 0 + } +} + +fopivot() { # <rw_root> <ro_root> <dupe?> + root=$1 + { + if grep -q overlay /proc/filesystems; then + mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt + elif grep -q mini_fo /proc/filesystems; then + mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt + else + mount --bind -o noatime / /mnt + mount --bind -o noatime,union "$1" /mnt && root=/mnt + fi + } || { + [ "$3" = "1" ] && { + mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1 + dupe $1 $rom + } + } + pivot $root $2 +} + +ramoverlay() { + mkdir -p /tmp/root + mount -t tmpfs -o noatime,mode=0755 root /tmp/root + fopivot /tmp/root /rom 1 +} + +[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh diff --git a/package/base-files/files/lib/firstboot/.svn/entries b/package/base-files/files/lib/firstboot/.svn/entries new file mode 100644 index 0000000..4faa8cf --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/entries @@ -0,0 +1,538 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/firstboot +svn://svn.openwrt.org/openwrt + + + +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +30_no_fo_pivot +file + + + + +2013-03-17T12:13:21.000000Z +05dcf8be4db74ee8bf91ec6cc9290a8c +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +212 + +10_determine_parts +file + + + + +2013-03-17T12:13:21.000000Z +7f4e5a91337ee98efcaf044da7a46ea0 +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +932 + +99_10_with_fo_cleanup +file + + + + +2013-03-17T12:13:21.000000Z +933a1c84006796789185495083cfe600 +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +501 + +99_10_no_fo_cleanup +file + + + + +2013-03-17T12:13:21.000000Z +13db248c34fa69a6b000921a1e76da9e +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +224 + +30_reset_copy_rom +file + + + + +2013-03-17T12:13:21.000000Z +c906820b468d1bc036969053ecc84e2a +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +228 + +20_no_fo_mount_jffs +file + + + + +2013-03-17T12:13:21.000000Z +93874189d29461ca4c5538a9c8281f1f +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +332 + +40_no_fo_copy_ramoverlay +file + + + + +2013-03-17T12:13:21.000000Z +ccce2620aa1dafc38d4a3831b32f65f7 +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +365 + +20_reset_clear_jffs +file + + + + +2013-03-17T12:13:21.000000Z +8dfe331ce8ca348071cecfe496c58dfe +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +287 + +30_is_rootfs_mounted +file + + + + +2013-03-17T12:13:21.000000Z +066662c53f60a607cbaba59c235586cf +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +236 + +50_pivot +file + + + + +2013-03-17T12:13:21.000000Z +287023c3965c0a0c060dcb974c56e4f7 +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +383 + +05_firstboot_skip +file + + + + +2013-03-17T12:13:21.000000Z +3e218d08ebd04fa51c73d6a0bbce0361 +2012-04-27T16:49:16.916618Z +31492 +florian + + + + + + + + + + + + + + + + + + + + + +115 + +10_no_fo_clear_overlay +file + + + + +2013-03-17T12:13:21.000000Z +6bf3c0e457e23f335337ea54e566fd4e +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +356 + +20_has_mini_fo +file + + + + +2013-03-17T12:13:21.000000Z +8f0c67354bd0b422d58579d6cb10b25d +2011-03-17T19:09:39.292493Z +26207 +nbd + + + + + + + + + + + + + + + + + + + + + +262 + +10_reset_has_mini_fo +file + + + + +2013-03-17T12:13:21.000000Z +5e47572006d901d63617729a6a35fb5b +2011-03-17T19:09:39.292493Z +26207 +nbd + + + + + + + + + + + + + + + + + + + + + +261 + +40_copy_ramoverlay +file + + + + +2013-03-17T12:13:21.000000Z +8f418a269c3912825daae204264a8f9b +2010-03-21T17:16:50.184472Z +20356 +florian + + + + + + + + + + + + + + + + + + + + + +361 + diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base new file mode 100644 index 0000000..5f44df6 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/05_firstboot_skip.svn-base @@ -0,0 +1,10 @@ +#!/bin/sh + +check_skip() { + if [ "$firstboot_skip_next" = "true" ]; then + return 0 + else + return 1 + fi +} + diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base new file mode 100644 index 0000000..3f56e32 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_determine_parts.svn-base @@ -0,0 +1,46 @@ +#!/bin/sh + +set_mtd_part() { + partname="rootfs_data" + mtdpart="$(find_mtd_part $partname)" +} + +set_rom_part() { + rom=$(awk '/squashfs/ {print $2}' /proc/mounts) +} + +set_jffs_part() { + jffs=$(awk '/jffs2/ {print $2}' /proc/mounts) +} + +determine_mtd_part() { + set_mtd_part + if [ -z "$mtdpart" ]; then + echo "MTD partition not found." + exit 1 + fi +} + +determine_rom_part() { + check_skip || { + set_rom_part + if [ -z "$rom" ]; then + echo "You do not have a squashfs partition; aborting" + echo "(firstboot cannot be run on jffs2 based firmwares)" + exit 1 + fi + } +} + +determine_jffs2_part() { + check_skip || { + set_jffs_part + } +} + +boot_hook_add switch2jffs determine_mtd_part +boot_hook_add jffs2reset determine_mtd_part +boot_hook_add switch2jffs determine_rom_part +boot_hook_add jffs2reset determine_rom_part +boot_hook_add switch2jffs determine_jffs2_part +boot_hook_add jffs2reset determine_jffs2_part diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base new file mode 100644 index 0000000..8a7d9b0 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_no_fo_clear_overlay.svn-base @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_clear_overlay() { + # switch back to squashfs temporarily + pivot /rom /mnt + + # get rid of the old overlay + umount -l /mnt + + # another umount to get rid of the bind from /tmp/root + umount -l /mnt +} + +boot_hook_add no_fo no_fo_clear_overlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base new file mode 100644 index 0000000..4e28584 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/10_reset_has_mini_fo.svn-base @@ -0,0 +1,12 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_check_for_overlay() { + if grep -qE '(mini_fo|overlay)' /proc/filesystems; then + reset_has_fo=true + fi +} + +boot_hook_add jffs2reset reset_check_for_overlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base new file mode 100644 index 0000000..8ca6a4f --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_has_mini_fo.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +check_for_overlay() { + if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then + boot_run_hook no_fo + exit 1 + fi +} + +boot_hook_add switch2jffs check_for_overlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base new file mode 100644 index 0000000..c03714f --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_no_fo_mount_jffs.svn-base @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_mount_jffs() { + # initialize jffs2 + mount -o noatime "$mtdpart" /overlay -t jffs2 || exit + + # workaround to ensure that union can attach properly + sync + ls /overlay >/dev/null +} + +boot_hook_add no_fo no_fo_mount_jffs diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base new file mode 100644 index 0000000..a3cd24f --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/20_reset_clear_jffs.svn-base @@ -0,0 +1,14 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_clear_jffs() { + [ "$reset_has_fo" = "true" ] && { + rm -rf $jffs/* 2>&- + mount -o remount $jffs / 2>&- + exit 0 + } || reset_has_fo=false +} + +boot_hook_add jffs2reset reset_clear_jffs diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base new file mode 100644 index 0000000..7233fd9 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_is_rootfs_mounted.svn-base @@ -0,0 +1,10 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +skip_if_rootfs_mounted() { + mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit +} + +boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base new file mode 100644 index 0000000..b5c2601 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_no_fo_pivot.svn-base @@ -0,0 +1,11 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_pivot() { + # switch to the new (empty) jffs2 + fopivot /overlay /rom 1 +} + +boot_hook_add no_fo no_fo_pivot diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base new file mode 100644 index 0000000..d91c689 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/30_reset_copy_rom.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_copy_rom() { + [ "$reset_has_fo" != "true" ] && { + dupe $jffs $rom + exit 0 + } +} + +boot_hook_add jffs2reset reset_copy_rom diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base new file mode 100644 index 0000000..39c2eda --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/40_copy_ramoverlay.svn-base @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +copy_ramoverlay() { + # try to avoid fs changing while copying + mount -o remount,ro none / 2>&- + # copy ramoverlay to jffs2 + echo -n "copying files ... " + cp -a /tmp/root/* /rom/overlay 2>&- + echo "done" +} + +boot_hook_add switch2jffs copy_ramoverlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base new file mode 100644 index 0000000..ced7c1b --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/40_no_fo_copy_ramoverlay.svn-base @@ -0,0 +1,14 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_copy_ramoverlay() { + # copy ramoverlay to jffs2, must be done after switching + # to the new rootfs to avoid creating opaque directories + echo -n "copying files ... " + cp -a /tmp/root/* / >/dev/null 2>&1 + sync +} + +boot_hook_add no_fo no_fo_ramoverlay diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base new file mode 100644 index 0000000..53801d7 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/50_pivot.svn-base @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +with_fo_pivot() { + # switch back to squashfs (temporarily) + # and park the ramdisk ontop of /tmp/root + pivot /rom /mnt + mount -o move /mnt /tmp/root + + # /overlay is the overlay + # /rom is the readonly + fopivot /overlay /rom +} + +boot_hook_add switch2jffs with_fo_pivot diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base new file mode 100644 index 0000000..6dedcb1 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_no_fo_cleanup.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_cleanup() { + echo "done" + umount -l /overlay + umount -l /tmp/root + exit 0 +} + +boot_hook_add no_fo no_fo_cleanup diff --git a/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base new file mode 100644 index 0000000..5601699 --- /dev/null +++ b/package/base-files/files/lib/firstboot/.svn/text-base/99_10_with_fo_cleanup.svn-base @@ -0,0 +1,25 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +with_fo_cleanup() { + # try to get rid of /tmp/root + # this will almost always fail + umount -l /tmp/root 2>&- + grep -q overlay /proc/filesystems && { + cd / + ( + cd /overlay + find -type l + ) | while read FILE; do + [ -z "$FILE" ] && break + if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then + rm -f "$FILE" + fi + done + } + exit 0 +} + +boot_hook_add switch2jffs with_fo_cleanup diff --git a/package/base-files/files/lib/firstboot/05_firstboot_skip b/package/base-files/files/lib/firstboot/05_firstboot_skip new file mode 100644 index 0000000..5f44df6 --- /dev/null +++ b/package/base-files/files/lib/firstboot/05_firstboot_skip @@ -0,0 +1,10 @@ +#!/bin/sh + +check_skip() { + if [ "$firstboot_skip_next" = "true" ]; then + return 0 + else + return 1 + fi +} + diff --git a/package/base-files/files/lib/firstboot/10_determine_parts b/package/base-files/files/lib/firstboot/10_determine_parts new file mode 100644 index 0000000..3f56e32 --- /dev/null +++ b/package/base-files/files/lib/firstboot/10_determine_parts @@ -0,0 +1,46 @@ +#!/bin/sh + +set_mtd_part() { + partname="rootfs_data" + mtdpart="$(find_mtd_part $partname)" +} + +set_rom_part() { + rom=$(awk '/squashfs/ {print $2}' /proc/mounts) +} + +set_jffs_part() { + jffs=$(awk '/jffs2/ {print $2}' /proc/mounts) +} + +determine_mtd_part() { + set_mtd_part + if [ -z "$mtdpart" ]; then + echo "MTD partition not found." + exit 1 + fi +} + +determine_rom_part() { + check_skip || { + set_rom_part + if [ -z "$rom" ]; then + echo "You do not have a squashfs partition; aborting" + echo "(firstboot cannot be run on jffs2 based firmwares)" + exit 1 + fi + } +} + +determine_jffs2_part() { + check_skip || { + set_jffs_part + } +} + +boot_hook_add switch2jffs determine_mtd_part +boot_hook_add jffs2reset determine_mtd_part +boot_hook_add switch2jffs determine_rom_part +boot_hook_add jffs2reset determine_rom_part +boot_hook_add switch2jffs determine_jffs2_part +boot_hook_add jffs2reset determine_jffs2_part diff --git a/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay new file mode 100644 index 0000000..8a7d9b0 --- /dev/null +++ b/package/base-files/files/lib/firstboot/10_no_fo_clear_overlay @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_clear_overlay() { + # switch back to squashfs temporarily + pivot /rom /mnt + + # get rid of the old overlay + umount -l /mnt + + # another umount to get rid of the bind from /tmp/root + umount -l /mnt +} + +boot_hook_add no_fo no_fo_clear_overlay diff --git a/package/base-files/files/lib/firstboot/10_reset_has_mini_fo b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo new file mode 100644 index 0000000..4e28584 --- /dev/null +++ b/package/base-files/files/lib/firstboot/10_reset_has_mini_fo @@ -0,0 +1,12 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_check_for_overlay() { + if grep -qE '(mini_fo|overlay)' /proc/filesystems; then + reset_has_fo=true + fi +} + +boot_hook_add jffs2reset reset_check_for_overlay diff --git a/package/base-files/files/lib/firstboot/20_has_mini_fo b/package/base-files/files/lib/firstboot/20_has_mini_fo new file mode 100644 index 0000000..8ca6a4f --- /dev/null +++ b/package/base-files/files/lib/firstboot/20_has_mini_fo @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +check_for_overlay() { + if ! grep -qE '(mini_fo|overlay)' /proc/filesystems; then + boot_run_hook no_fo + exit 1 + fi +} + +boot_hook_add switch2jffs check_for_overlay diff --git a/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs new file mode 100644 index 0000000..c03714f --- /dev/null +++ b/package/base-files/files/lib/firstboot/20_no_fo_mount_jffs @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_mount_jffs() { + # initialize jffs2 + mount -o noatime "$mtdpart" /overlay -t jffs2 || exit + + # workaround to ensure that union can attach properly + sync + ls /overlay >/dev/null +} + +boot_hook_add no_fo no_fo_mount_jffs diff --git a/package/base-files/files/lib/firstboot/20_reset_clear_jffs b/package/base-files/files/lib/firstboot/20_reset_clear_jffs new file mode 100644 index 0000000..a3cd24f --- /dev/null +++ b/package/base-files/files/lib/firstboot/20_reset_clear_jffs @@ -0,0 +1,14 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_clear_jffs() { + [ "$reset_has_fo" = "true" ] && { + rm -rf $jffs/* 2>&- + mount -o remount $jffs / 2>&- + exit 0 + } || reset_has_fo=false +} + +boot_hook_add jffs2reset reset_clear_jffs diff --git a/package/base-files/files/lib/firstboot/30_is_rootfs_mounted b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted new file mode 100644 index 0000000..7233fd9 --- /dev/null +++ b/package/base-files/files/lib/firstboot/30_is_rootfs_mounted @@ -0,0 +1,10 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +skip_if_rootfs_mounted() { + mount -o noatime -t jffs2 "$mtdpart" /rom/overlay || exit +} + +boot_hook_add switch2jffs skip_if_rootfs_mounted diff --git a/package/base-files/files/lib/firstboot/30_no_fo_pivot b/package/base-files/files/lib/firstboot/30_no_fo_pivot new file mode 100644 index 0000000..b5c2601 --- /dev/null +++ b/package/base-files/files/lib/firstboot/30_no_fo_pivot @@ -0,0 +1,11 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_pivot() { + # switch to the new (empty) jffs2 + fopivot /overlay /rom 1 +} + +boot_hook_add no_fo no_fo_pivot diff --git a/package/base-files/files/lib/firstboot/30_reset_copy_rom b/package/base-files/files/lib/firstboot/30_reset_copy_rom new file mode 100644 index 0000000..d91c689 --- /dev/null +++ b/package/base-files/files/lib/firstboot/30_reset_copy_rom @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +reset_copy_rom() { + [ "$reset_has_fo" != "true" ] && { + dupe $jffs $rom + exit 0 + } +} + +boot_hook_add jffs2reset reset_copy_rom diff --git a/package/base-files/files/lib/firstboot/40_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_copy_ramoverlay new file mode 100644 index 0000000..39c2eda --- /dev/null +++ b/package/base-files/files/lib/firstboot/40_copy_ramoverlay @@ -0,0 +1,15 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +copy_ramoverlay() { + # try to avoid fs changing while copying + mount -o remount,ro none / 2>&- + # copy ramoverlay to jffs2 + echo -n "copying files ... " + cp -a /tmp/root/* /rom/overlay 2>&- + echo "done" +} + +boot_hook_add switch2jffs copy_ramoverlay diff --git a/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay b/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay new file mode 100644 index 0000000..ced7c1b --- /dev/null +++ b/package/base-files/files/lib/firstboot/40_no_fo_copy_ramoverlay @@ -0,0 +1,14 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_copy_ramoverlay() { + # copy ramoverlay to jffs2, must be done after switching + # to the new rootfs to avoid creating opaque directories + echo -n "copying files ... " + cp -a /tmp/root/* / >/dev/null 2>&1 + sync +} + +boot_hook_add no_fo no_fo_ramoverlay diff --git a/package/base-files/files/lib/firstboot/50_pivot b/package/base-files/files/lib/firstboot/50_pivot new file mode 100644 index 0000000..53801d7 --- /dev/null +++ b/package/base-files/files/lib/firstboot/50_pivot @@ -0,0 +1,17 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +with_fo_pivot() { + # switch back to squashfs (temporarily) + # and park the ramdisk ontop of /tmp/root + pivot /rom /mnt + mount -o move /mnt /tmp/root + + # /overlay is the overlay + # /rom is the readonly + fopivot /overlay /rom +} + +boot_hook_add switch2jffs with_fo_pivot diff --git a/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup new file mode 100644 index 0000000..6dedcb1 --- /dev/null +++ b/package/base-files/files/lib/firstboot/99_10_no_fo_cleanup @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +no_fo_cleanup() { + echo "done" + umount -l /overlay + umount -l /tmp/root + exit 0 +} + +boot_hook_add no_fo no_fo_cleanup diff --git a/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup new file mode 100644 index 0000000..5601699 --- /dev/null +++ b/package/base-files/files/lib/firstboot/99_10_with_fo_cleanup @@ -0,0 +1,25 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +with_fo_cleanup() { + # try to get rid of /tmp/root + # this will almost always fail + umount -l /tmp/root 2>&- + grep -q overlay /proc/filesystems && { + cd / + ( + cd /overlay + find -type l + ) | while read FILE; do + [ -z "$FILE" ] && break + if ls -la "$FILE" 2>&- | grep -q '(overlay-whiteout)'; then + rm -f "$FILE" + fi + done + } + exit 0 +} + +boot_hook_add switch2jffs with_fo_cleanup diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh new file mode 100755 index 0000000..f51bfea --- /dev/null +++ b/package/base-files/files/lib/functions.sh @@ -0,0 +1,543 @@ +#!/bin/sh +# Copyright (C) 2006-2013 OpenWrt.org +# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de> +# Copyright (C) 2010 Vertical Communications + + +debug () { + ${DEBUG:-:} "$@" +} + +# newline +N=" +" + +_C=0 +NO_EXPORT=1 +LOAD_STATE=1 +LIST_SEP=" " + +hotplug_dev() { + env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug-call net +} + +append() { + local var="$1" + local value="$2" + local sep="${3:- }" + + eval "export ${NO_EXPORT:+-n} -- \"$var=\${$var:+\${$var}\${value:+\$sep}}\$value\"" +} + +list_contains() { + local var="$1" + local str="$2" + local val + + eval "val=\" \${$var} \"" + [ "${val%% $str *}" != "$val" ] +} + +list_remove() { + local var="$1" + local remove="$2" + local val + + eval "val=\" \${$var} \"" + val1="${val%% $remove *}" + [ "$val1" = "$val" ] && return + val2="${val##* $remove }" + [ "$val2" = "$val" ] && return + val="${val1## } ${val2%% }" + val="${val%% }" + eval "export ${NO_EXPORT:+-n} -- \"$var=\$val\"" +} + +config_load() { + [ -n "$IPKG_INSTROOT" ] && return 0 + uci_load "$@" +} + +reset_cb() { + config_cb() { return 0; } + option_cb() { return 0; } + list_cb() { return 0; } +} +reset_cb + +package() { + return 0 +} + +config () { + local cfgtype="$1" + local name="$2" + + export ${NO_EXPORT:+-n} CONFIG_NUM_SECTIONS=$(($CONFIG_NUM_SECTIONS + 1)) + name="${name:-cfg$CONFIG_NUM_SECTIONS}" + append CONFIG_SECTIONS "$name" + [ -n "$NO_CALLBACK" ] || config_cb "$cfgtype" "$name" + export ${NO_EXPORT:+-n} CONFIG_SECTION="$name" + export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_TYPE=$cfgtype" +} + +option () { + local varname="$1"; shift + local value="$*" + + export ${NO_EXPORT:+-n} "CONFIG_${CONFIG_SECTION}_${varname}=$value" + [ -n "$NO_CALLBACK" ] || option_cb "$varname" "$*" +} + +list() { + local varname="$1"; shift + local value="$*" + local len + + config_get len "$CONFIG_SECTION" "${varname}_LENGTH" 0 + [ $len = 0 ] && append CONFIG_LIST_STATE "${CONFIG_SECTION}_${varname}" + len=$(($len + 1)) + config_set "$CONFIG_SECTION" "${varname}_ITEM$len" "$value" + config_set "$CONFIG_SECTION" "${varname}_LENGTH" "$len" + append "CONFIG_${CONFIG_SECTION}_${varname}" "$value" "$LIST_SEP" + list_cb "$varname" "$*" +} + +config_rename() { + local OLD="$1" + local NEW="$2" + local oldvar + local newvar + + [ -n "$OLD" -a -n "$NEW" ] || return + for oldvar in `set | grep ^CONFIG_${OLD}_ | \ + sed -e 's/\(.*\)=.*$/\1/'` ; do + newvar="CONFIG_${NEW}_${oldvar##CONFIG_${OLD}_}" + eval "export ${NO_EXPORT:+-n} \"$newvar=\${$oldvar}\"" + unset "$oldvar" + done + export ${NO_EXPORT:+-n} CONFIG_SECTIONS="$(echo " $CONFIG_SECTIONS " | sed -e "s, $OLD , $NEW ,")" + + [ "$CONFIG_SECTION" = "$OLD" ] && export ${NO_EXPORT:+-n} CONFIG_SECTION="$NEW" +} + +config_unset() { + config_set "$1" "$2" "" +} + +config_clear() { + local SECTION="$1" + local oldvar + + list_remove CONFIG_SECTIONS "$SECTION" + export ${NO_EXPORT:+-n} CONFIG_SECTIONS="${SECTION:+$CONFIG_SECTIONS}" + + for oldvar in `set | grep ^CONFIG_${SECTION:+${SECTION}_} | \ + sed -e 's/\(.*\)=.*$/\1/'` ; do + unset $oldvar + done +} + +# config_get <variable> <section> <option> [<default>] +# config_get <section> <option> +config_get() { + case "$3" in + "") eval echo "\${CONFIG_${1}_${2}:-\${4}}";; + *) eval export ${NO_EXPORT:+-n} -- "${1}=\${CONFIG_${2}_${3}:-\${4}}";; + esac +} + +# config_get_bool <variable> <section> <option> [<default>] +config_get_bool() { + local _tmp + config_get _tmp "$2" "$3" "$4" + case "$_tmp" in + 1|on|true|enabled) _tmp=1;; + 0|off|false|disabled) _tmp=0;; + *) _tmp="$4";; + esac + export ${NO_EXPORT:+-n} "$1=$_tmp" +} + +config_set() { + local section="$1" + local option="$2" + local value="$3" + local old_section="$CONFIG_SECTION" + + CONFIG_SECTION="$section" + option "$option" "$value" + CONFIG_SECTION="$old_section" +} + +config_foreach() { + local ___function="$1" + [ "$#" -ge 1 ] && shift + local ___type="$1" + [ "$#" -ge 1 ] && shift + local section cfgtype + + [ -z "$CONFIG_SECTIONS" ] && return 0 + for section in ${CONFIG_SECTIONS}; do + config_get cfgtype "$section" TYPE + [ -n "$___type" -a "x$cfgtype" != "x$___type" ] && continue + eval "$___function \"\$section\" \"\$@\"" + done +} + +config_list_foreach() { + [ "$#" -ge 3 ] || return 0 + local section="$1"; shift + local option="$1"; shift + local function="$1"; shift + local val + local len + local c=1 + + config_get len "${section}" "${option}_LENGTH" + [ -z "$len" ] && return 0 + while [ $c -le "$len" ]; do + config_get val "${section}" "${option}_ITEM$c" + eval "$function \"\$val\" \"\$@\"" + c="$(($c + 1))" + done +} + +load_modules() { + [ -d /etc/modules.d ] && { + cd /etc/modules.d + sed 's/^[^#]/insmod &/' $* | ash 2>&- || : + } +} + +include() { + local file + + for file in $(ls $1/*.sh 2>/dev/null); do + . $file + done +} + +find_mtd_index() { + local PART="$(grep "\"$1\"" /proc/mtd | awk -F: '{print $1}')" + local INDEX="${PART##mtd}" + + echo ${INDEX} +} + +find_mtd_part() { + local INDEX=$(find_mtd_index "$1") + local PREFIX=/dev/mtdblock + + [ -d /dev/mtdblock ] && PREFIX=/dev/mtdblock/ + echo "${INDEX:+$PREFIX$INDEX}" +} + +find_mtd_chardev() { + local INDEX=$(find_mtd_index "$1") + local PREFIX=/dev/mtd + + [ -d /dev/mtd ] && PREFIX=/dev/mtd/ + echo "${INDEX:+$PREFIX$INDEX}" +} + +mtd_get_mac_ascii() +{ + local mtdname="$1" + local key="$2" + local part + local mac_dirty + + . /lib/functions.sh + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_mac_ascii: partition $mtdname not found!" >&2 + return + fi + + mac_dirty=$(strings "$part" | sed -n 's/'"$key"'=//p') + # "canonicalize" mac + printf "%02x:%02x:%02x:%02x:%02x:%02x" 0x${mac_dirty//:/ 0x} +} + +mtd_get_mac_binary() { + local mtdname="$1" + local offset="$2" + local part + + part=$(find_mtd_part "$mtdname") + if [ -z "$part" ]; then + echo "mtd_get_mac_binary: partition $mtdname not found!" >&2 + return + fi + + dd bs=1 skip=$offset count=6 if=$part 2>/dev/null | hexdump -v -n 6 -e '5/1 "%02x:" 1/1 "%02x"' +} + +macaddr_add() { + local mac=$1 + local val=$2 + local oui=${mac%:*:*:*} + local nic=${mac#*:*:*:} + + nic=$(printf "%06x" $((0x${nic//:/} + $val & 0xffffff)) | sed 's/^\(.\{2\}\)\(.\{2\}\)\(.\{2\}\)/\1:\2:\3/') + echo $oui:$nic +} + +macaddr_setbit_la() +{ + local mac=$1 + + printf "%02x:%s" $((0x${mac%%:*} | 0x02)) ${mac#*:} +} + +macaddr_2bin() +{ + local mac=$1 + + echo -ne \\x${mac//:/\\x} +} + +strtok() { # <string> { <variable> [<separator>] ... } + local tmp + local val="$1" + local count=0 + + shift + + while [ $# -gt 1 ]; do + tmp="${val%%$2*}" + + [ "$tmp" = "$val" ] && break + + val="${val#$tmp$2}" + + export ${NO_EXPORT:+-n} "$1=$tmp"; count=$((count+1)) + shift 2 + done + + if [ $# -gt 0 -a -n "$val" ]; then + export ${NO_EXPORT:+-n} "$1=$val"; count=$((count+1)) + fi + + return $count +} + + +jffs2_mark_erase() { + local part="$(find_mtd_part "$1")" + [ -z "$part" ] && { + echo Partition not found. + return 1 + } + echo -e "\xde\xad\xc0\xde" | mtd -qq write - "$1" +} + +uci_apply_defaults() { + cd /etc/uci-defaults || return 0 + files="$(ls)" + [ -z "$files" ] && return 0 + mkdir -p /tmp/.uci + for file in $files; do + ( . "./$(basename $file)" ) && rm -f "$file" + done + uci commit +} + +group_add() { + local name="$1" + local gid="$2" + local rc + [ -f "${IPKG_INSTROOT}/etc/group" ] || return 1 + [ -n "$IPKG_INSTROOT" ] || lock /var/lock/group + echo "${name}:x:${gid}:" >> ${IPKG_INSTROOT}/etc/group + rc=$? + [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/group + return $rc +} + +group_exists() { + grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/group +} + +user_add() { + local name="${1}" + local uid="${2}" + local gid="${3:-$2}" + local desc="${4:-$1}" + local home="${5:-/var/run/$1}" + local shell="${6:-/bin/false}" + local rc + [ -f "${IPKG_INSTROOT}/etc/passwd" ] || return 1 + [ -n "$IPKG_INSTROOT" ] || lock /var/lock/passwd + echo "${name}:x:${uid}:${gid}:${desc}:${home}:${shell}" >> ${IPKG_INSTROOT}/etc/passwd + echo "${name}:x:0:0:99999:7:::" >> ${IPKG_INSTROOT}/etc/shadow + rc=$? + [ -n "$IPKG_INSTROOT" ] || lock -u /var/lock/passwd + return $rc +} + +user_exists() { + grep -qs "^${1}:" ${IPKG_INSTROOT}/etc/passwd +} + + +pi_include() { + if [ -f "/tmp/overlay/$1" ]; then + . "/tmp/overlay/$1" + elif [ -f "$1" ]; then + . "$1" + elif [ -d "/tmp/overlay/$1" ]; then + if [ -n "$(ls /tmp/overlay/$1/*.sh 2>/dev/null)" ]; then + for src_script in /tmp/overlay/$1/*.sh; do + . "$src_script" + done + fi + elif [ -d "$1" ]; then + if [ -n "$(ls $1/*.sh 2>/dev/null)" ]; then + for src_script in $1/*.sh; do + . "$src_script" + done + fi + else + echo "WARNING: $1 not found" + return 1 + fi + return 0 +} + +boot_hook_splice_start() { + export -n PI_HOOK_SPLICE=1 +} + +boot_hook_splice_finish() { + local hook + for hook in $PI_STACK_LIST; do + local v; eval "v=\${${hook}_splice:+\$${hook}_splice }$hook" + export -n "${hook}=${v% }" + export -n "${hook}_splice=" + done + export -n PI_HOOK_SPLICE= +} + +boot_hook_init() { + local hook="${1}_hook" + export -n "PI_STACK_LIST=${PI_STACK_LIST:+$PI_STACK_LIST }$hook" + export -n "$hook=" +} + +boot_hook_add() { + local hook="${1}_hook${PI_HOOK_SPLICE:+_splice}" + local func="${2}" + + [ -n "$func" ] && { + local v; eval "v=\$$hook" + export -n "$hook=${v:+$v }$func" + } +} + +boot_hook_shift() { + local hook="${1}_hook" + local rvar="${2}" + + local v; eval "v=\$$hook" + [ -n "$v" ] && { + local first="${v%% *}" + + [ "$v" != "${v#* }" ] && \ + export -n "$hook=${v#* }" || \ + export -n "$hook=" + + export -n "$rvar=$first" + return 0 + } + + return 1 +} + +boot_run_hook() { + local hook="$1" + local func + + while boot_hook_shift "$hook" func; do + local ran; eval "ran=\$PI_RAN_$func" + [ -n "$ran" ] || { + export -n "PI_RAN_$func=1" + $func "$1" "$2" + } + done +} + +jffs2_ready() { + mtdpart="$(find_mtd_part rootfs_data)" + [ -z "$mtdpart" ] && return 1 + magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"') + [ "$magic" != "deadc0de" ] +} + +dupe() { # <new_root> <old_root> + cd $1 + echo -n "creating directories... " + { + cd $2 + find . -xdev -type d + echo "./dev ./overlay ./mnt ./proc ./tmp" + # xdev skips mounted directories + cd $1 + } | xargs mkdir -p + echo "done" + + echo -n "setting up symlinks... " + for file in $(cd $2; find . -xdev -type f;); do + case "$file" in + ./rom/note) ;; #nothing + ./etc/config*|\ + ./usr/lib/opkg/info/*) cp -af $2/$file $file;; + *) ln -sf /rom/${file#./*} $file;; + esac + done + for file in $(cd $2; find . -xdev -type l;); do + cp -af $2/${file#./*} $file + done + echo "done" +} + +pivot() { # <new_root> <old_root> + mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 && { + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/sys /sys 2>&- + mount -o noatime,move $2/overlay /overlay 2>&- + return 0 + } +} + +fopivot() { # <rw_root> <ro_root> <dupe?> + root=$1 + { + if grep -q overlay /proc/filesystems; then + mount -o noatime,lowerdir=/,upperdir=$1 -t overlayfs "overlayfs:$1" /mnt && root=/mnt + elif grep -q mini_fo /proc/filesystems; then + mount -t mini_fo -o noatime,base=/,sto=$1 "mini_fo:$1" /mnt 2>&- && root=/mnt + else + mount --bind -o noatime / /mnt + mount --bind -o noatime,union "$1" /mnt && root=/mnt + fi + } || { + [ "$3" = "1" ] && { + mount | grep "on $1 type" 2>&- 1>&- || mount -o noatime,bind $1 $1 + dupe $1 $rom + } + } + pivot $root $2 +} + +ramoverlay() { + mkdir -p /tmp/root + mount -t tmpfs -o noatime,mode=0755 root /tmp/root + fopivot /tmp/root /rom 1 +} + +[ -z "$IPKG_INSTROOT" -a -f /lib/config/uci.sh ] && . /lib/config/uci.sh diff --git a/package/base-files/files/lib/functions/.svn/entries b/package/base-files/files/lib/functions/.svn/entries new file mode 100644 index 0000000..be2fb75 --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/entries @@ -0,0 +1,164 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/functions +svn://svn.openwrt.org/openwrt + + + +2013-02-18T09:56:23.456396Z +35648 +juhosg + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +leds.sh +file + + + + +2013-03-17T12:13:21.000000Z +4d196ba7aab9d848e0da8505d8c20ffb +2013-02-18T09:56:23.456396Z +35648 +juhosg +has-props + + + + + + + + + + + + + + + + + + + + +1274 + +network.sh +file + + + + +2013-03-17T12:13:21.000000Z +2eb07029c2d3f87fbb517a87ef1f1a4e +2013-01-22T16:47:16.091518Z +35300 +cyrus + + + + + + + + + + + + + + + + + + + + + +7941 + +service.sh +file + + + + +2013-03-17T12:13:21.000000Z +cffa973cb0e71e1d12967d843ee92179 +2012-03-20T14:29:50.022402Z +31042 +nbd + + + + + + + + + + + + + + + + + + + + + +3488 + +uci-defaults.sh +file + + + + +2013-03-17T12:13:21.000000Z +dd38ca259ffd0916168f7869ebff55e8 +2012-08-13T14:01:37.239528Z +33164 +juhosg +has-props + + + + + + + + + + + + + + + + + + + + +4252 + diff --git a/package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base b/package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/prop-base/leds.sh.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base b/package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/prop-base/uci-defaults.sh.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base new file mode 100644 index 0000000..743c7da --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/text-base/leds.sh.svn-base @@ -0,0 +1,68 @@ +#!/bin/sh +# Copyright (C) 2013 OpenWrt.org + +led_set_attr() { + [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2" +} + +led_timer() { + led_set_attr $1 "trigger" "timer" + led_set_attr $1 "delay_on" "$2" + led_set_attr $1 "delay_off" "$3" +} + +led_on() { + led_set_attr $1 "trigger" "none" + led_set_attr $1 "brightness" 255 +} + +led_off() { + led_set_attr $1 "trigger" "none" + led_set_attr $1 "brightness" 0 +} + +led_morse() { + led_set_attr $1 "trigger" "morse" + led_set_attr $1 "delay" "$2" + led_set_attr $1 "message" "$3" +} + +status_led_set_timer() { + led_timer $status_led "$1" "$2" + [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2" +} + +status_led_set_heartbeat() { + led_set_attr $status_led "trigger" "heartbeat" +} + +status_led_set_morse() { + led_morse $status_led "$1" "$2" + [ -n "$status_led2" ] && led_morse $status_led2 "$1" "$2" +} + +status_led_on() { + led_on $status_led + [ -n "$status_led2" ] && led_on $status_led2 +} + +status_led_off() { + led_off $status_led + [ -n "$status_led2" ] && led_off $status_led2 +} + +status_led_blink_slow() { + led_timer $status_led 1000 1000 +} + +status_led_blink_fast() { + led_timer $status_led 100 100 +} + +status_led_blink_preinit() { + led_timer $status_led 200 200 +} + +status_led_blink_failsafe() { + led_timer $status_led 50 50 +} diff --git a/package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base new file mode 100644 index 0000000..369fa3d --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/text-base/network.sh.svn-base @@ -0,0 +1,350 @@ +. /usr/share/libubox/jshn.sh + +__network_set_cache() +{ + if [ -n "$3" ]; then + eval "export -- __NETWORK_CV_$1='$3'" + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" + elif json_get_var "__NETWORK_CV_$1" "$2"; then + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" + fi +} + +__network_export() +{ + local __v="__NETWORK_CV_$2" + eval "export -- \"$1=\${$__v:+\$$__v$3}\"; [ -n \"\${$__v+x}\" ]" +} + +__network_parse_ifstatus() +{ + local __iface="$1" + local __key="${__iface}" + local __tmp + local __old_ns + + __network_export __tmp "${__key}__parsed" && return 0 + __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" + [ -n "$__tmp" ] || return 1 + + json_set_namespace "network" __old_ns + json_load "$__tmp" + + __network_set_cache "${__key}__parsed" "" "1" + + for __tmp in "" "_inactive"; do + + __key="${__key}${__tmp}" + + # parse addresses + local __family + for __family in 4 6; do + if json_is_a "ipv${__family}_address" array; then + + json_select "ipv${__family}_address" + + if json_is_a 1 object; then + + json_select 1 + __network_set_cache "${__key}_address${__family}" address + __network_set_cache "${__key}_mask${__family}" mask + json_select ".." + + fi + + json_select ".." + + fi + done + + # parse prefixes + if json_is_a "ipv6_prefix" array; then + json_select "ipv6_prefix" + + if json_is_a 1 object; then + json_select 1 + __network_set_cache "${__key}_prefix6_address" address + __network_set_cache "${__key}_prefix6_mask" mask + json_select ".." + fi + + json_select ".." + fi + + # parse routes + if json_is_a route array; then + + json_select "route" + + local __idx=1 + while json_is_a "$__idx" object; do + + json_select "$((__idx++))" + json_get_var __tmp target + + case "${__tmp}" in + 0.0.0.0) + __network_set_cache "${__key}_gateway4" nexthop + ;; + ::) + __network_set_cache "${__key}_gateway6" nexthop + ;; + esac + + json_select ".." + + done + + json_select ".." + + fi + + # parse dns info + local __field + for __field in "dns_server" "dns_search"; do + if json_is_a "$__field" array; then + + json_select "$__field" + + local __idx=1 + local __dns="" + + while json_is_a "$__idx" string; do + + json_get_var __tmp "$((__idx++))" + __dns="${__dns:+$__dns }$__tmp" + + done + + json_select ".." + + if [ -n "$__dns" ]; then + __network_set_cache "${__key}_${__field}" "" "$__dns" + fi + fi + done + + # parse up state, device and physdev + for __field in "up" "l3_device" "device"; do + if json_get_type __tmp "$__field"; then + __network_set_cache "${__key}_${__field}" "$__field" + fi + done + + # descend into inactive table + json_is_a "inactive" object && json_select "inactive" + + done + + json_cleanup + json_set_namespace "$__old_ns" + + return 0 +} + + +__network_ipaddr() +{ + local __var="$1" + local __iface="$2" + local __family="$3" + local __prefix="$4" + local __tmp + + __network_parse_ifstatus "$__iface" || return 1 + + if [ $__prefix -eq 1 ]; then + __network_export __tmp "${__iface}_mask${__family}" && \ + __network_export "$__var" "${__iface}_address${__family}" "/$__tmp" + return $? + fi + + __network_export "$__var" "${__iface}_address${__family}" + return $? + +} + +# determine IPv4 address of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; } + +# determine IPv6 address of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; } + +# determine IPv4 subnet of given logical interface +# 1: destination variable +# 2: interface +network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; } + +# determine IPv6 subnet of given logical interface +# 1: destination variable +# 2: interface +network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } + +# determine IPv6 prefix +network_get_prefix6() { + local __var="$1" + local __iface="$2" + local __address + local __mask + + __network_parse_ifstatus "$__iface" || return 1 + __network_export __mask "${__iface}_prefix6_mask" || return 1 + __network_export "$__var" "${__iface}_prefix6_address" "/$__mask" + return $? +} + + +__network_gateway() +{ + local __var="$1" + local __iface="$2" + local __family="$3" + local __inactive="$4" + + __network_parse_ifstatus "$__iface" || return 1 + + if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then + __network_export "$__var" "${__iface}_inactive_gateway${__family}" && \ + return 0 + fi + + __network_export "$__var" "${__iface}_gateway${__family}" + return $? +} + +# determine IPv4 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; } + +# determine IPv6 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway6() { __network_gateway "$1" "$2" 6 "${3:-0}"; } + + +__network_dns() { + local __var="$1" + local __iface="$2" + local __field="$3" + local __inactive="$4" + + __network_parse_ifstatus "$__iface" || return 1 + + if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then + __network_export "$__var" "${__iface}_inactive_${__field}" && \ + return 0 + fi + + __network_export "$__var" "${__iface}_${__field}" + return $? +} + +# determine the DNS servers of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive servers if "true" (optional) +network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; } + +# determine the domains of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive domains if "true" (optional) +network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; } + + +__network_wan() +{ + local __var="$1" + local __family="$2" + local __inactive="$3" + local __iface + + for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do + if [ "$__iface" != loopback ]; then + if __network_gateway "$__var" "$__iface" "$__family" "$__inactive"; then + eval "export -- \"$__var=$__iface\"" + return 0 + fi + fi + done + + eval "export -- \"$__var=\"" + return 1 +} + +# find the logical interface which holds the current IPv4 default route +# 1: destination variable +# 2: consider inactive default routes if "true" (optional) +network_find_wan() { __network_wan "$1" 4 "${2:-0}"; } + +# find the logical interface which holds the current IPv6 default route +# 1: destination variable +# 2: consider inactive dafault routes if "true" (optional) +network_find_wan6() { __network_wan "$1" 6 "${2:-0}"; } + + +__network_device() +{ + local __var="$1" + local __iface="$2" + local __field="$3" + + __network_parse_ifstatus "$__iface" || return 1 + __network_export "$__var" "${__iface}_${__field}" + return $? +} + +# test whether the given logical interface is running +# 1: interface +network_is_up() +{ + local __up + __network_device __up "$1" up && [ $__up -eq 1 ] +} + +# determine the layer 3 linux network device of the given logical interface +# 1: destination variable +# 2: interface +network_get_device() { __network_device "$1" "$2" l3_device; } + +# determine the layer 2 linux network device of the given logical interface +# 1: destination variable +# 2: interface +network_get_physdev() { __network_device "$1" "$2" device; } + + +__network_defer() +{ + local __device="$1" + local __defer="$2" + + json_init + json_add_string name "$__device" + json_add_boolean defer "$__defer" + + ubus call network.device set_state "$(json_dump)" 2>/dev/null +} + +# defer netifd actions on the given linux network device +# 1: device name +network_defer_device() { __network_defer "$1" 1; } + +# continue netifd actions on the given linux network device +# 1: device name +network_ready_device() { __network_defer "$1" 0; } + +# flush the internal value cache to force re-reading values from ubus +network_flush_cache() +{ + local __tmp + for __tmp in $__NETWORK_CACHE __NETWORK_CACHE; do + unset "$__tmp" + done +} diff --git a/package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base new file mode 100644 index 0000000..cbb717d --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/text-base/service.sh.svn-base @@ -0,0 +1,129 @@ +# +# service: simple wrapper around start-stop-daemon +# +# Usage: service ACTION EXEC ARGS... +# +# Action: +# -C check if EXEC is alive +# -S start EXEC, passing it ARGS as its arguments +# -K kill EXEC, sending it a TERM signal if not specified otherwise +# +# Environment variables exposed: +# SERVICE_DAEMONIZE run EXEC in background +# SERVICE_WRITE_PID create a pid-file and use it for matching +# SERVICE_MATCH_EXEC use EXEC command-line for matching (default) +# SERVICE_MATCH_NAME use EXEC process name for matching +# SERVICE_USE_PID assume EXEC create its own pid-file and use it for matching +# SERVICE_NAME process name to use (default to EXEC file part) +# SERVICE_PID_FILE pid file to use (default to /var/run/$SERVICE_NAME.pid) +# SERVICE_SIG signal to send when using -K +# SERVICE_SIG_RELOAD default signal used when reloading +# SERVICE_SIG_STOP default signal used when stopping +# SERVICE_STOP_TIME time to wait for a process to stop gracefully before killing it +# SERVICE_UID user EXEC should be run as +# SERVICE_GID group EXEC should be run as +# +# SERVICE_DEBUG don't do anything, but show what would be done +# SERVICE_QUIET don't print anything +# + +SERVICE_QUIET=1 +SERVICE_SIG_RELOAD="HUP" +SERVICE_SIG_STOP="TERM" +SERVICE_STOP_TIME=5 +SERVICE_MATCH_EXEC=1 + +service() { + local ssd + local exec + local name + local start + ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}" + case "$1" in + -C) + ssd="$ssd -K -t" + ;; + -S) + ssd="$ssd -S${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}" + start=1 + ;; + -K) + ssd="$ssd -K${SERVICE_SIG:+ -s $SERVICE_SIG}" + ;; + *) + echo "service: unknown ACTION '$1'" 1>&2 + return 1 + esac + shift + exec="$1" + [ -n "$exec" ] || { + echo "service: missing argument" 1>&2 + return 1 + } + [ -x "$exec" ] || { + echo "service: file '$exec' is not executable" 1>&2 + return 1 + } + name="${SERVICE_NAME:-${exec##*/}}" + [ -z "$SERVICE_USE_PID$SERVICE_WRITE_PID$SERVICE_PID_FILE" ] \ + || ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/$name.pid}" + [ -z "$SERVICE_MATCH_NAME" ] || ssd="$ssd -n $name" + ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}" + [ -z "$SERVICE_MATCH_EXEC$start" ] || ssd="$ssd -x $exec" + shift + $ssd${1:+ -- "$@"} +} + +service_check() { + service -C "$@" +} + +service_signal() { + SERVICE_SIG="${SERVICE_SIG:-USR1}" service -K "$@" +} + +service_start() { + service -S "$@" +} + +service_stop() { + local try + SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_STOP}" service -K "$@" || return 1 + while [ $((try++)) -lt $SERVICE_STOP_TIME ]; do + service -C "$@" || return 0 + sleep 1 + done + SERVICE_SIG="KILL" service -K "$@" + sleep 1 + ! service -C "$@" +} + +service_reload() { + SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_RELOAD}" service -K "$@" +} + +service_kill() { + cat 1>&2 << __END_OF_WARNING__ +# +# WARNING: the 'service_kill' function is now deprecated and might be +# removed soon. Consider using the other new service_* wrappers instead. +# +__END_OF_WARNING__ + local name="${1}" + local pid="${2:-$(pidof "$name")}" + local grace="${3:-5}" + + [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)" + + for pid in $pid; do + [ -d "/proc/$pid" ] || continue + local try=0 + kill -TERM $pid 2>/dev/null && \ + while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done + kill -KILL $pid 2>/dev/null && \ + while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done + done +} + + + diff --git a/package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base b/package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base new file mode 100644 index 0000000..477c00c --- /dev/null +++ b/package/base-files/files/lib/functions/.svn/text-base/uci-defaults.sh.svn-base @@ -0,0 +1,230 @@ +#!/bin/sh +# Copyright (C) 2011 OpenWrt.org + +UCIDEF_LEDS_CHANGED=0 + +ucidef_set_led_netdev() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local dev=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='netdev' +set system.$cfg.dev='$dev' +set system.$cfg.mode='link tx rx' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_usbdev() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local dev=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='usbdev' +set system.$cfg.dev='$dev' +set system.$cfg.interval='50' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_wlan() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local trigger=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='$trigger' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_switch() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local trigger=$4 + local port_mask=$5 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='$trigger' +set system.$cfg.port_mask='$port_mask' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_default() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local default=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.default='$default' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_rssi() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local iface=$4 + local minq=$5 + local maxq=$6 + local offset=$7 + local factor=$8 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='rssi' +set system.$cfg.iface='rssid_$iface' +set system.$cfg.minq='$minq' +set system.$cfg.maxq='$maxq' +set system.$cfg.offset='$offset' +set system.$cfg.factor='$factor' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_rssimon() { + local dev="$1" + local refresh="$2" + local threshold="$3" + + local cfg="rssid_$dev" + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='rssid' +set system.$cfg.dev='$dev' +set system.$cfg.refresh='$refresh' +set system.$cfg.threshold='$threshold' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_commit_leds() +{ + [ "$UCIDEF_LEDS_CHANGED" == "1" ] && uci commit system +} + +ucidef_set_interface_loopback() { + uci batch <<EOF +set network.loopback='interface' +set network.loopback.ifname='lo' +set network.loopback.proto='static' +set network.loopback.ipaddr='127.0.0.1' +set network.loopback.netmask='255.0.0.0' +EOF +} + +ucidef_set_interface_raw() { + local cfg=$1 + local ifname=$2 + + uci batch <<EOF +set network.$cfg='interface' +set network.$cfg.ifname='$ifname' +set network.$cfg.proto='none' +EOF +} + +ucidef_set_interface_lan() { + local ifname=$1 + + uci batch <<EOF +set network.lan='interface' +set network.lan.ifname='$ifname' +set network.lan.type='bridge' +set network.lan.proto='static' +set network.lan.ipaddr='192.168.1.1' +set network.lan.netmask='255.255.255.0' +EOF +} + +ucidef_set_interface_wan() { + local ifname=$1 + + uci batch <<EOF +set network.wan='interface' +set network.wan.ifname='$ifname' +set network.wan.proto='dhcp' +EOF +} + +ucidef_set_interfaces_lan_wan() { + local lan_ifname=$1 + local wan_ifname=$2 + + ucidef_set_interface_lan "$lan_ifname" + ucidef_set_interface_wan "$wan_ifname" +} + +ucidef_set_interface_macaddr() { + local ifname=$1 + local mac=$2 + + uci batch <<EOF +set network.$ifname.macaddr='$mac' +EOF +} + +ucidef_add_switch() { + local name=$1 + local reset=$2 + local enable=$3 + uci batch <<EOF +add network switch +set network.@switch[-1].name='$name' +set network.@switch[-1].reset='$reset' +set network.@switch[-1].enable_vlan='$enable' +EOF +} + +ucidef_add_switch_vlan() { + local device=$1 + local vlan=$2 + local ports=$3 + uci batch <<EOF +add network switch_vlan +set network.@switch_vlan[-1].device='$device' +set network.@switch_vlan[-1].vlan='$vlan' +set network.@switch_vlan[-1].ports='$ports' +EOF +} + diff --git a/package/base-files/files/lib/functions/leds.sh b/package/base-files/files/lib/functions/leds.sh new file mode 100644 index 0000000..743c7da --- /dev/null +++ b/package/base-files/files/lib/functions/leds.sh @@ -0,0 +1,68 @@ +#!/bin/sh +# Copyright (C) 2013 OpenWrt.org + +led_set_attr() { + [ -f "/sys/class/leds/$1/$2" ] && echo "$3" > "/sys/class/leds/$1/$2" +} + +led_timer() { + led_set_attr $1 "trigger" "timer" + led_set_attr $1 "delay_on" "$2" + led_set_attr $1 "delay_off" "$3" +} + +led_on() { + led_set_attr $1 "trigger" "none" + led_set_attr $1 "brightness" 255 +} + +led_off() { + led_set_attr $1 "trigger" "none" + led_set_attr $1 "brightness" 0 +} + +led_morse() { + led_set_attr $1 "trigger" "morse" + led_set_attr $1 "delay" "$2" + led_set_attr $1 "message" "$3" +} + +status_led_set_timer() { + led_timer $status_led "$1" "$2" + [ -n "$status_led2" ] && led_timer $status_led2 "$1" "$2" +} + +status_led_set_heartbeat() { + led_set_attr $status_led "trigger" "heartbeat" +} + +status_led_set_morse() { + led_morse $status_led "$1" "$2" + [ -n "$status_led2" ] && led_morse $status_led2 "$1" "$2" +} + +status_led_on() { + led_on $status_led + [ -n "$status_led2" ] && led_on $status_led2 +} + +status_led_off() { + led_off $status_led + [ -n "$status_led2" ] && led_off $status_led2 +} + +status_led_blink_slow() { + led_timer $status_led 1000 1000 +} + +status_led_blink_fast() { + led_timer $status_led 100 100 +} + +status_led_blink_preinit() { + led_timer $status_led 200 200 +} + +status_led_blink_failsafe() { + led_timer $status_led 50 50 +} diff --git a/package/base-files/files/lib/functions/network.sh b/package/base-files/files/lib/functions/network.sh new file mode 100644 index 0000000..369fa3d --- /dev/null +++ b/package/base-files/files/lib/functions/network.sh @@ -0,0 +1,350 @@ +. /usr/share/libubox/jshn.sh + +__network_set_cache() +{ + if [ -n "$3" ]; then + eval "export -- __NETWORK_CV_$1='$3'" + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" + elif json_get_var "__NETWORK_CV_$1" "$2"; then + __NETWORK_CACHE="${__NETWORK_CACHE:+$__NETWORK_CACHE }__NETWORK_CV_$1" + fi +} + +__network_export() +{ + local __v="__NETWORK_CV_$2" + eval "export -- \"$1=\${$__v:+\$$__v$3}\"; [ -n \"\${$__v+x}\" ]" +} + +__network_parse_ifstatus() +{ + local __iface="$1" + local __key="${__iface}" + local __tmp + local __old_ns + + __network_export __tmp "${__key}__parsed" && return 0 + __tmp="$(ubus call network.interface."$__iface" status 2>/dev/null)" + [ -n "$__tmp" ] || return 1 + + json_set_namespace "network" __old_ns + json_load "$__tmp" + + __network_set_cache "${__key}__parsed" "" "1" + + for __tmp in "" "_inactive"; do + + __key="${__key}${__tmp}" + + # parse addresses + local __family + for __family in 4 6; do + if json_is_a "ipv${__family}_address" array; then + + json_select "ipv${__family}_address" + + if json_is_a 1 object; then + + json_select 1 + __network_set_cache "${__key}_address${__family}" address + __network_set_cache "${__key}_mask${__family}" mask + json_select ".." + + fi + + json_select ".." + + fi + done + + # parse prefixes + if json_is_a "ipv6_prefix" array; then + json_select "ipv6_prefix" + + if json_is_a 1 object; then + json_select 1 + __network_set_cache "${__key}_prefix6_address" address + __network_set_cache "${__key}_prefix6_mask" mask + json_select ".." + fi + + json_select ".." + fi + + # parse routes + if json_is_a route array; then + + json_select "route" + + local __idx=1 + while json_is_a "$__idx" object; do + + json_select "$((__idx++))" + json_get_var __tmp target + + case "${__tmp}" in + 0.0.0.0) + __network_set_cache "${__key}_gateway4" nexthop + ;; + ::) + __network_set_cache "${__key}_gateway6" nexthop + ;; + esac + + json_select ".." + + done + + json_select ".." + + fi + + # parse dns info + local __field + for __field in "dns_server" "dns_search"; do + if json_is_a "$__field" array; then + + json_select "$__field" + + local __idx=1 + local __dns="" + + while json_is_a "$__idx" string; do + + json_get_var __tmp "$((__idx++))" + __dns="${__dns:+$__dns }$__tmp" + + done + + json_select ".." + + if [ -n "$__dns" ]; then + __network_set_cache "${__key}_${__field}" "" "$__dns" + fi + fi + done + + # parse up state, device and physdev + for __field in "up" "l3_device" "device"; do + if json_get_type __tmp "$__field"; then + __network_set_cache "${__key}_${__field}" "$__field" + fi + done + + # descend into inactive table + json_is_a "inactive" object && json_select "inactive" + + done + + json_cleanup + json_set_namespace "$__old_ns" + + return 0 +} + + +__network_ipaddr() +{ + local __var="$1" + local __iface="$2" + local __family="$3" + local __prefix="$4" + local __tmp + + __network_parse_ifstatus "$__iface" || return 1 + + if [ $__prefix -eq 1 ]; then + __network_export __tmp "${__iface}_mask${__family}" && \ + __network_export "$__var" "${__iface}_address${__family}" "/$__tmp" + return $? + fi + + __network_export "$__var" "${__iface}_address${__family}" + return $? + +} + +# determine IPv4 address of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddr() { __network_ipaddr "$1" "$2" 4 0; } + +# determine IPv6 address of given logical interface +# 1: destination variable +# 2: interface +network_get_ipaddr6() { __network_ipaddr "$1" "$2" 6 0; } + +# determine IPv4 subnet of given logical interface +# 1: destination variable +# 2: interface +network_get_subnet() { __network_ipaddr "$1" "$2" 4 1; } + +# determine IPv6 subnet of given logical interface +# 1: destination variable +# 2: interface +network_get_subnet6() { __network_ipaddr "$1" "$2" 6 1; } + +# determine IPv6 prefix +network_get_prefix6() { + local __var="$1" + local __iface="$2" + local __address + local __mask + + __network_parse_ifstatus "$__iface" || return 1 + __network_export __mask "${__iface}_prefix6_mask" || return 1 + __network_export "$__var" "${__iface}_prefix6_address" "/$__mask" + return $? +} + + +__network_gateway() +{ + local __var="$1" + local __iface="$2" + local __family="$3" + local __inactive="$4" + + __network_parse_ifstatus "$__iface" || return 1 + + if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then + __network_export "$__var" "${__iface}_inactive_gateway${__family}" && \ + return 0 + fi + + __network_export "$__var" "${__iface}_gateway${__family}" + return $? +} + +# determine IPv4 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway() { __network_gateway "$1" "$2" 4 "${3:-0}"; } + +# determine IPv6 gateway of given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive gateway if "true" (optional) +network_get_gateway6() { __network_gateway "$1" "$2" 6 "${3:-0}"; } + + +__network_dns() { + local __var="$1" + local __iface="$2" + local __field="$3" + local __inactive="$4" + + __network_parse_ifstatus "$__iface" || return 1 + + if [ "$__inactive" = 1 -o "$__inactive" = "true" ]; then + __network_export "$__var" "${__iface}_inactive_${__field}" && \ + return 0 + fi + + __network_export "$__var" "${__iface}_${__field}" + return $? +} + +# determine the DNS servers of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive servers if "true" (optional) +network_get_dnsserver() { __network_dns "$1" "$2" dns_server "${3:-0}"; } + +# determine the domains of the given logical interface +# 1: destination variable +# 2: interface +# 3: consider inactive domains if "true" (optional) +network_get_dnssearch() { __network_dns "$1" "$2" dns_search "${3:-0}"; } + + +__network_wan() +{ + local __var="$1" + local __family="$2" + local __inactive="$3" + local __iface + + for __iface in $(ubus list | sed -ne 's/^network\.interface\.//p'); do + if [ "$__iface" != loopback ]; then + if __network_gateway "$__var" "$__iface" "$__family" "$__inactive"; then + eval "export -- \"$__var=$__iface\"" + return 0 + fi + fi + done + + eval "export -- \"$__var=\"" + return 1 +} + +# find the logical interface which holds the current IPv4 default route +# 1: destination variable +# 2: consider inactive default routes if "true" (optional) +network_find_wan() { __network_wan "$1" 4 "${2:-0}"; } + +# find the logical interface which holds the current IPv6 default route +# 1: destination variable +# 2: consider inactive dafault routes if "true" (optional) +network_find_wan6() { __network_wan "$1" 6 "${2:-0}"; } + + +__network_device() +{ + local __var="$1" + local __iface="$2" + local __field="$3" + + __network_parse_ifstatus "$__iface" || return 1 + __network_export "$__var" "${__iface}_${__field}" + return $? +} + +# test whether the given logical interface is running +# 1: interface +network_is_up() +{ + local __up + __network_device __up "$1" up && [ $__up -eq 1 ] +} + +# determine the layer 3 linux network device of the given logical interface +# 1: destination variable +# 2: interface +network_get_device() { __network_device "$1" "$2" l3_device; } + +# determine the layer 2 linux network device of the given logical interface +# 1: destination variable +# 2: interface +network_get_physdev() { __network_device "$1" "$2" device; } + + +__network_defer() +{ + local __device="$1" + local __defer="$2" + + json_init + json_add_string name "$__device" + json_add_boolean defer "$__defer" + + ubus call network.device set_state "$(json_dump)" 2>/dev/null +} + +# defer netifd actions on the given linux network device +# 1: device name +network_defer_device() { __network_defer "$1" 1; } + +# continue netifd actions on the given linux network device +# 1: device name +network_ready_device() { __network_defer "$1" 0; } + +# flush the internal value cache to force re-reading values from ubus +network_flush_cache() +{ + local __tmp + for __tmp in $__NETWORK_CACHE __NETWORK_CACHE; do + unset "$__tmp" + done +} diff --git a/package/base-files/files/lib/functions/service.sh b/package/base-files/files/lib/functions/service.sh new file mode 100644 index 0000000..cbb717d --- /dev/null +++ b/package/base-files/files/lib/functions/service.sh @@ -0,0 +1,129 @@ +# +# service: simple wrapper around start-stop-daemon +# +# Usage: service ACTION EXEC ARGS... +# +# Action: +# -C check if EXEC is alive +# -S start EXEC, passing it ARGS as its arguments +# -K kill EXEC, sending it a TERM signal if not specified otherwise +# +# Environment variables exposed: +# SERVICE_DAEMONIZE run EXEC in background +# SERVICE_WRITE_PID create a pid-file and use it for matching +# SERVICE_MATCH_EXEC use EXEC command-line for matching (default) +# SERVICE_MATCH_NAME use EXEC process name for matching +# SERVICE_USE_PID assume EXEC create its own pid-file and use it for matching +# SERVICE_NAME process name to use (default to EXEC file part) +# SERVICE_PID_FILE pid file to use (default to /var/run/$SERVICE_NAME.pid) +# SERVICE_SIG signal to send when using -K +# SERVICE_SIG_RELOAD default signal used when reloading +# SERVICE_SIG_STOP default signal used when stopping +# SERVICE_STOP_TIME time to wait for a process to stop gracefully before killing it +# SERVICE_UID user EXEC should be run as +# SERVICE_GID group EXEC should be run as +# +# SERVICE_DEBUG don't do anything, but show what would be done +# SERVICE_QUIET don't print anything +# + +SERVICE_QUIET=1 +SERVICE_SIG_RELOAD="HUP" +SERVICE_SIG_STOP="TERM" +SERVICE_STOP_TIME=5 +SERVICE_MATCH_EXEC=1 + +service() { + local ssd + local exec + local name + local start + ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}" + case "$1" in + -C) + ssd="$ssd -K -t" + ;; + -S) + ssd="$ssd -S${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}" + start=1 + ;; + -K) + ssd="$ssd -K${SERVICE_SIG:+ -s $SERVICE_SIG}" + ;; + *) + echo "service: unknown ACTION '$1'" 1>&2 + return 1 + esac + shift + exec="$1" + [ -n "$exec" ] || { + echo "service: missing argument" 1>&2 + return 1 + } + [ -x "$exec" ] || { + echo "service: file '$exec' is not executable" 1>&2 + return 1 + } + name="${SERVICE_NAME:-${exec##*/}}" + [ -z "$SERVICE_USE_PID$SERVICE_WRITE_PID$SERVICE_PID_FILE" ] \ + || ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/$name.pid}" + [ -z "$SERVICE_MATCH_NAME" ] || ssd="$ssd -n $name" + ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}" + [ -z "$SERVICE_MATCH_EXEC$start" ] || ssd="$ssd -x $exec" + shift + $ssd${1:+ -- "$@"} +} + +service_check() { + service -C "$@" +} + +service_signal() { + SERVICE_SIG="${SERVICE_SIG:-USR1}" service -K "$@" +} + +service_start() { + service -S "$@" +} + +service_stop() { + local try + SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_STOP}" service -K "$@" || return 1 + while [ $((try++)) -lt $SERVICE_STOP_TIME ]; do + service -C "$@" || return 0 + sleep 1 + done + SERVICE_SIG="KILL" service -K "$@" + sleep 1 + ! service -C "$@" +} + +service_reload() { + SERVICE_SIG="${SERVICE_SIG:-$SERVICE_SIG_RELOAD}" service -K "$@" +} + +service_kill() { + cat 1>&2 << __END_OF_WARNING__ +# +# WARNING: the 'service_kill' function is now deprecated and might be +# removed soon. Consider using the other new service_* wrappers instead. +# +__END_OF_WARNING__ + local name="${1}" + local pid="${2:-$(pidof "$name")}" + local grace="${3:-5}" + + [ -f "$pid" ] && pid="$(head -n1 "$pid" 2>/dev/null)" + + for pid in $pid; do + [ -d "/proc/$pid" ] || continue + local try=0 + kill -TERM $pid 2>/dev/null && \ + while grep -qs "$name" "/proc/$pid/cmdline" && [ $((try++)) -lt $grace ]; do sleep 1; done + kill -KILL $pid 2>/dev/null && \ + while grep -qs "$name" "/proc/$pid/cmdline"; do sleep 1; done + done +} + + + diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh new file mode 100644 index 0000000..477c00c --- /dev/null +++ b/package/base-files/files/lib/functions/uci-defaults.sh @@ -0,0 +1,230 @@ +#!/bin/sh +# Copyright (C) 2011 OpenWrt.org + +UCIDEF_LEDS_CHANGED=0 + +ucidef_set_led_netdev() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local dev=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='netdev' +set system.$cfg.dev='$dev' +set system.$cfg.mode='link tx rx' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_usbdev() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local dev=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='usbdev' +set system.$cfg.dev='$dev' +set system.$cfg.interval='50' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_wlan() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local trigger=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='$trigger' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_switch() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local trigger=$4 + local port_mask=$5 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='$trigger' +set system.$cfg.port_mask='$port_mask' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_default() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local default=$4 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.default='$default' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_led_rssi() { + local cfg="led_$1" + local name=$2 + local sysfs=$3 + local iface=$4 + local minq=$5 + local maxq=$6 + local offset=$7 + local factor=$8 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.name='$name' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='rssi' +set system.$cfg.iface='rssid_$iface' +set system.$cfg.minq='$minq' +set system.$cfg.maxq='$maxq' +set system.$cfg.offset='$offset' +set system.$cfg.factor='$factor' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_set_rssimon() { + local dev="$1" + local refresh="$2" + local threshold="$3" + + local cfg="rssid_$dev" + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='rssid' +set system.$cfg.dev='$dev' +set system.$cfg.refresh='$refresh' +set system.$cfg.threshold='$threshold' +EOF + UCIDEF_LEDS_CHANGED=1 +} + +ucidef_commit_leds() +{ + [ "$UCIDEF_LEDS_CHANGED" == "1" ] && uci commit system +} + +ucidef_set_interface_loopback() { + uci batch <<EOF +set network.loopback='interface' +set network.loopback.ifname='lo' +set network.loopback.proto='static' +set network.loopback.ipaddr='127.0.0.1' +set network.loopback.netmask='255.0.0.0' +EOF +} + +ucidef_set_interface_raw() { + local cfg=$1 + local ifname=$2 + + uci batch <<EOF +set network.$cfg='interface' +set network.$cfg.ifname='$ifname' +set network.$cfg.proto='none' +EOF +} + +ucidef_set_interface_lan() { + local ifname=$1 + + uci batch <<EOF +set network.lan='interface' +set network.lan.ifname='$ifname' +set network.lan.type='bridge' +set network.lan.proto='static' +set network.lan.ipaddr='192.168.1.1' +set network.lan.netmask='255.255.255.0' +EOF +} + +ucidef_set_interface_wan() { + local ifname=$1 + + uci batch <<EOF +set network.wan='interface' +set network.wan.ifname='$ifname' +set network.wan.proto='dhcp' +EOF +} + +ucidef_set_interfaces_lan_wan() { + local lan_ifname=$1 + local wan_ifname=$2 + + ucidef_set_interface_lan "$lan_ifname" + ucidef_set_interface_wan "$wan_ifname" +} + +ucidef_set_interface_macaddr() { + local ifname=$1 + local mac=$2 + + uci batch <<EOF +set network.$ifname.macaddr='$mac' +EOF +} + +ucidef_add_switch() { + local name=$1 + local reset=$2 + local enable=$3 + uci batch <<EOF +add network switch +set network.@switch[-1].name='$name' +set network.@switch[-1].reset='$reset' +set network.@switch[-1].enable_vlan='$enable' +EOF +} + +ucidef_add_switch_vlan() { + local device=$1 + local vlan=$2 + local ports=$3 + uci batch <<EOF +add network switch_vlan +set network.@switch_vlan[-1].device='$device' +set network.@switch_vlan[-1].vlan='$vlan' +set network.@switch_vlan[-1].ports='$ports' +EOF +} + diff --git a/package/base-files/files/lib/preinit/.svn/entries b/package/base-files/files/lib/preinit/.svn/entries new file mode 100644 index 0000000..8270063 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/entries @@ -0,0 +1,674 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/preinit +svn://svn.openwrt.org/openwrt + + + +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +90_restore_config +file + + + + +2013-03-17T12:13:21.000000Z +04e69cc1da4d81832d27a2cb7ab5358a +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +311 + +40_run_failsafe_hook +file + + + + +2013-03-17T12:13:21.000000Z +17269a4ab7d6cf87d0cfaa9c66dd45c6 +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +258 + +99_10_failsafe_login +file + + + + +2013-03-17T12:13:21.000000Z +70069fee1421e423b4b1b32fe8d41275 +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +380 + +99_10_mount_no_mtd +file + + + + +2013-03-17T12:13:21.000000Z +6609d58567732864df67793fbd87673f +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +207 + +10_check_for_mtd +file + + + + +2013-03-17T12:13:21.000000Z +d3b129644d4e887c14362fd50cc3a0b2 +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +361 + +05_mount_skip +file + + + + +2013-03-17T12:13:21.000000Z +1653d3e10ce2fa0bb19b9a2bc3512a1b +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +193 + +20_check_jffs2_ready +file + + + + +2013-03-17T12:13:21.000000Z +64b8f9758cf25e80af122a3e458ba2ce +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +344 + +40_mount_jffs2 +file + + + + +2013-03-17T12:13:21.000000Z +b52a12f4e1f86507ced5a17c68721415 +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +509 + +50_indicate_regular_preinit +file + + + + +2013-03-17T12:13:21.000000Z +2b9a9ccda822a0f7b9d57458ca31efe2 +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +251 + +02_default_set_state +file + + + + +2013-03-17T12:13:21.000000Z +193b1e9516b1755f8bd6e23f580e9314 +2011-07-07T02:52:02.172369Z +27501 +cshore + + + + + + + + + + + + + + + + + + + + + +111 + +30_failsafe_wait +file + + + + +2013-03-17T12:13:21.000000Z +fbfc634f57e24a2b818a68731e7d06bb +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +2107 + +90_mount_no_jffs2 +file + + + + +2013-03-17T12:13:21.000000Z +c18d18f6906e46760fa4a7bc641f5e3a +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +240 + +70_initramfs_test +file + + + + +2013-03-17T12:13:21.000000Z +e18ec6f31f263f2d83ba91d1968ee4ad +2010-03-12T14:37:19.807154Z +20159 +juhosg + + + + + + + + + + + + + + + + + + + + + +247 + +70_pivot_jffs2_root +file + + + + +2013-03-17T12:13:21.000000Z +45c359724eec192a210abb1faa4d5c2f +2012-12-19T16:07:46.450520Z +34792 +mirko + + + + + + + + + + + + + + + + + + + + + +335 + +41_merge_overlay_hooks +file + + + + +2013-03-17T12:13:21.000000Z +db40ab6d5b24c82854843cb41f41f80e +2010-09-23T17:32:58.124136Z +23114 +jow + + + + + + + + + + + + + + + + + + + + + +518 + +99_10_run_init +file + + + + +2013-03-17T12:13:21.000000Z +98ebebf030a69b8c25a7e47a0464755c +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +166 + +10_indicate_preinit +file + + + + +2013-03-17T12:13:21.000000Z +4c0cb2401ca1ddfb08398be732832f04 +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +1159 + +10_indicate_failsafe +file + + + + +2013-03-17T12:13:21.000000Z +da886213883c1e3827b041891063609a +2010-01-25T17:11:17.955488Z +19331 +nbd + + + + + + + + + + + + + + + + + + + + + +365 + +80_mount_root +file + + + + +2013-03-17T12:13:21.000000Z +d40c6fa4ce55e2fc41ab815263b95f16 +2013-03-13T18:11:19.892934Z +36003 +blogic + + + + + + + + + + + + + + + + + + + + + +214 + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base new file mode 100644 index 0000000..df43395 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/02_default_set_state.svn-base @@ -0,0 +1,7 @@ +#!/bin/sh + +define_default_set_state() { + . /etc/diag.sh +} + +boot_hook_add preinit_main define_default_set_state diff --git a/package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base new file mode 100644 index 0000000..c2b7ee7 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/05_mount_skip.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +check_skip() { + if [ "$pi_mount_skip_next" = "true" ]; then + return 0 + else + return 1 + fi +} + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base new file mode 100644 index 0000000..6a7bd30 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/10_check_for_mtd.svn-base @@ -0,0 +1,20 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +mount_no_mtd() { + mtd unlock rootfs + mount -o noatime,remount,rw /dev/root / +} + +check_for_mtd() { + check_skip || { + grep -qs rootfs_data /proc/mtd || { + mount_no_mtd && pi_mount_skip_next=true + } + } +} + +boot_hook_add preinit_mount_root check_for_mtd + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base new file mode 100644 index 0000000..7761fd3 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_failsafe.svn-base @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +# commands for emitting messages to network in failsafe mode + +indicate_failsafe_led () { + set_state failsafe +} + +indicate_failsafe() { + echo "- failsafe -" + preinit_net_echo "Entering Failsafe!\n" + indicate_failsafe_led +} + +boot_hook_add failsafe indicate_failsafe + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base new file mode 100644 index 0000000..da70b97 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/10_indicate_preinit.svn-base @@ -0,0 +1,50 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +preinit_ip() { + # if the preinit interface isn't specified and ifname is set in + # preinit.arch use that interface + if [ -z "$pi_ifname" ]; then + pi_ifname=$ifname + fi + + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up + } +} + +preinit_ip_deconfig() { + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + ifconfig $pi_ifname 0.0.0.0 down + } +} + +preinit_net_echo() { + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + { + [ "$pi_preinit_net_messages" = "y" ] || { + [ "$pi_failsafe_net_message" = "true" ] && + [ "$pi_preinit_no_failsafe_netmsg" != "y" ] + } + } && netmsg $pi_broadcast "$1" + } +} + +preinit_echo() { + preinit_net_echo $1 + echo $1 +} + +pi_indicate_led() { + set_state preinit +} + +pi_indicate_preinit() { + preinit_net_echo "Doing OpenWRT Preinit\n" + pi_indicate_led +} + +boot_hook_add preinit_main preinit_ip +boot_hook_add preinit_main pi_indicate_preinit + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base new file mode 100644 index 0000000..3c5cf67 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/20_check_jffs2_ready.svn-base @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +mount_no_jffs2() { + echo "jffs2 not ready yet; using ramdisk" + ramoverlay +} + +check_for_jffs2() { + check_skip || { + jffs2_ready || { + mount_no_jffs2 && pi_mount_skip_next=true + } + } +} + +boot_hook_add preinit_mount_root check_for_jffs2 + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base new file mode 100644 index 0000000..808d973 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/30_failsafe_wait.svn-base @@ -0,0 +1,84 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +fs_wait_for_key () { + local timeout=$3 + local timer + local do_failsafe + local keypress_true="$(mktemp)" + local keypress_wait="$(mktemp)" + local keypress_sec="$(mktemp)" + if [ -z "$keypress_wait" ]; then + keypress_wait=/tmp/.keypress_wait + touch $keypress_wait + fi + if [ -z "$keypress_true" ]; then + keypress_true=/tmp/.keypress_true + touch $keypress_true + fi + if [ -z "$keypress_sec" ]; then + keypress_sec=/tmp/.keypress_sec + touch $keypress_sec + fi + + trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT + trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1 + + [ -n "$timeout" ] || timeout=1 + [ $timeout -ge 1 ] || timeout=1 + timer=$timeout + lock $keypress_wait + { + while [ $timer -gt 0 ]; do + echo "$timer" >$keypress_sec + timer=$(($timer - 1)) + sleep 1 + done + lock -u $keypress_wait + rm -f $keypress_wait + } & + + echo "Press the [$1] key and hit [enter] $2" + # if we're on the console we wait for input + { + while [ -r $keypress_wait ]; do + timer="$(cat $keypress_sec)" + + [ -n "$timer" ] || timer=1 + timer="${timer%%\ *}" + [ $timer -ge 1 ] || timer=1 + do_failsafe="" + { + read -t "$timer" do_failsafe + if [ "$do_failsafe" = "$1" ]; then + echo "true" >$keypress_true + lock -u $keypress_wait + rm -f $keypress_wait + fi + } + done + } + lock -w $keypress_wait + + keypressed=1 + [ "$(cat $keypress_true)" = "true" ] && keypressed=0 + [ -f "/tmp/failsafe_button" ] && keypressed=1 + + rm -f $keypress_true + rm -f $keypress_wait + rm -f $keypress_sec + + return $keypressed +} + +failsafe_wait() { + FAILSAFE= + pi_failsafe_net_message=true + preinit_net_echo "Please press button now to enter failsafe" + pi_failsafe_net_message=false + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE +} + +boot_hook_add preinit_main failsafe_wait + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base new file mode 100644 index 0000000..ded785e --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/40_mount_jffs2.svn-base @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +find_mount_jffs2() { + mkdir -p /tmp/overlay + mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay + mtd -qq unlock rootfs_data +} + +jffs2_not_mounted() { + if [ "$pi_jffs2_mount_success" != "true" ]; then + return 0 + else + return 1 + fi +} + +do_mount_jffs2() { + check_skip || { + find_mount_jffs2 && pi_jffs2_mount_success=true + } +} + +boot_hook_add preinit_mount_root do_mount_jffs2 + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base new file mode 100644 index 0000000..faa043c --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/40_run_failsafe_hook.svn-base @@ -0,0 +1,13 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +run_failsafe_hook() { + if [ "$FAILSAFE" = "true" ]; then + boot_run_hook failsafe + lock -w /tmp/.failsafe + fi +} + +boot_hook_add preinit_main run_failsafe_hook + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base new file mode 100644 index 0000000..4ca6877 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/41_merge_overlay_hooks.svn-base @@ -0,0 +1,24 @@ +#!/bin/sh +# Copyright (C) 2010 OpenWrt.org + +merge_overlay_hooks() { + jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || { + echo "- merge overlay components -" + + mkdir -p /tmp/preinit-hook-merge + ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/ + + boot_hook_splice_start + + local pipart + for pipart in /tmp/preinit-hook-merge/*; do + . $pipart + done + + boot_hook_splice_finish + + rm -rf /tmp/preinit-hook-merge + } +} + +boot_hook_add preinit_mount_root merge_overlay_hooks diff --git a/package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base new file mode 100644 index 0000000..c200dad --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/50_indicate_regular_preinit.svn-base @@ -0,0 +1,11 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +indicate_regular_preinit() { + preinit_net_echo "Continuing with Regular Preinit\n" + pi_indicate_led +} + +boot_hook_add preinit_main indicate_regular_preinit + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base new file mode 100644 index 0000000..15c0dcd --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/70_initramfs_test.svn-base @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +initramfs_test() { + if [ -n "$INITRAMFS" ]; then + boot_run_hook initramfs + preinit_ip_deconfig + break + fi +} + +boot_hook_add preinit_main initramfs_test + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base new file mode 100644 index 0000000..b76f111 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/70_pivot_jffs2_root.svn-base @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +rootfs_pivot() { + check_skip || jffs2_not_mounted || { + echo "switching to jffs2" + mount -o noatime,move /tmp/overlay /overlay 2>&- + fopivot /overlay /rom && pi_mount_skip_next=true + } +} + +boot_hook_add preinit_mount_root rootfs_pivot + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base new file mode 100644 index 0000000..9a99ee9 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/80_mount_root.svn-base @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_root() { + boot_run_hook preinit_mount_root +} + +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root diff --git a/package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base new file mode 100644 index 0000000..d8ad4ae --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/90_mount_no_jffs2.svn-base @@ -0,0 +1,12 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_no_jffs2() { + check_skip || { + mount_no_jffs2 && pi_mount_skip_next=true + } +} + +boot_hook_add preinit_mount_root do_mount_no_jffs2 + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base new file mode 100644 index 0000000..210bf61 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/90_restore_config.svn-base @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +restore_config() { + [ -f /sysupgrade.tgz ] && { + echo "- config restore -" + cd / + mv sysupgrade.tgz /tmp + tar xzf /tmp/sysupgrade.tgz + rm -f /tmp/sysupgrade.tgz + sync + } +} + +boot_hook_add preinit_main restore_config + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base new file mode 100644 index 0000000..05d6b77 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/99_10_failsafe_login.svn-base @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +failsafe_netlogin () { + telnetd -l /bin/login.sh <> /dev/null 2>&1 +} + +failsafe_shell() { + lock /tmp/.failsafe + ash --login + echo "Please reboot system when done with failsafe network logins" +} + + +boot_hook_add failsafe failsafe_netlogin +boot_hook_add failsafe failsafe_shell + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base new file mode 100644 index 0000000..c4f38e4 --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/99_10_mount_no_mtd.svn-base @@ -0,0 +1,12 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_no_mtd() { + check_skip || { + mount_no_mtd + } +} + +boot_hook_add preinit_mount_root do_mount_no_mtd + diff --git a/package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base b/package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base new file mode 100644 index 0000000..a8f330f --- /dev/null +++ b/package/base-files/files/lib/preinit/.svn/text-base/99_10_run_init.svn-base @@ -0,0 +1,10 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +run_init() { + preinit_ip_deconfig +} + +boot_hook_add preinit_main run_init + diff --git a/package/base-files/files/lib/preinit/02_default_set_state b/package/base-files/files/lib/preinit/02_default_set_state new file mode 100644 index 0000000..df43395 --- /dev/null +++ b/package/base-files/files/lib/preinit/02_default_set_state @@ -0,0 +1,7 @@ +#!/bin/sh + +define_default_set_state() { + . /etc/diag.sh +} + +boot_hook_add preinit_main define_default_set_state diff --git a/package/base-files/files/lib/preinit/05_mount_skip b/package/base-files/files/lib/preinit/05_mount_skip new file mode 100644 index 0000000..c2b7ee7 --- /dev/null +++ b/package/base-files/files/lib/preinit/05_mount_skip @@ -0,0 +1,13 @@ +#!/bin/sh + +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +check_skip() { + if [ "$pi_mount_skip_next" = "true" ]; then + return 0 + else + return 1 + fi +} + diff --git a/package/base-files/files/lib/preinit/10_check_for_mtd b/package/base-files/files/lib/preinit/10_check_for_mtd new file mode 100644 index 0000000..6a7bd30 --- /dev/null +++ b/package/base-files/files/lib/preinit/10_check_for_mtd @@ -0,0 +1,20 @@ +#!/bin/sh + +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +mount_no_mtd() { + mtd unlock rootfs + mount -o noatime,remount,rw /dev/root / +} + +check_for_mtd() { + check_skip || { + grep -qs rootfs_data /proc/mtd || { + mount_no_mtd && pi_mount_skip_next=true + } + } +} + +boot_hook_add preinit_mount_root check_for_mtd + diff --git a/package/base-files/files/lib/preinit/10_indicate_failsafe b/package/base-files/files/lib/preinit/10_indicate_failsafe new file mode 100644 index 0000000..7761fd3 --- /dev/null +++ b/package/base-files/files/lib/preinit/10_indicate_failsafe @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +# commands for emitting messages to network in failsafe mode + +indicate_failsafe_led () { + set_state failsafe +} + +indicate_failsafe() { + echo "- failsafe -" + preinit_net_echo "Entering Failsafe!\n" + indicate_failsafe_led +} + +boot_hook_add failsafe indicate_failsafe + diff --git a/package/base-files/files/lib/preinit/10_indicate_preinit b/package/base-files/files/lib/preinit/10_indicate_preinit new file mode 100644 index 0000000..da70b97 --- /dev/null +++ b/package/base-files/files/lib/preinit/10_indicate_preinit @@ -0,0 +1,50 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +preinit_ip() { + # if the preinit interface isn't specified and ifname is set in + # preinit.arch use that interface + if [ -z "$pi_ifname" ]; then + pi_ifname=$ifname + fi + + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + ifconfig $pi_ifname $pi_ip netmask $pi_netmask broadcast $pi_broadcast up + } +} + +preinit_ip_deconfig() { + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + ifconfig $pi_ifname 0.0.0.0 down + } +} + +preinit_net_echo() { + [ -n "$pi_ifname" ] && grep -q "$pi_ifname" /proc/net/dev && { + { + [ "$pi_preinit_net_messages" = "y" ] || { + [ "$pi_failsafe_net_message" = "true" ] && + [ "$pi_preinit_no_failsafe_netmsg" != "y" ] + } + } && netmsg $pi_broadcast "$1" + } +} + +preinit_echo() { + preinit_net_echo $1 + echo $1 +} + +pi_indicate_led() { + set_state preinit +} + +pi_indicate_preinit() { + preinit_net_echo "Doing OpenWRT Preinit\n" + pi_indicate_led +} + +boot_hook_add preinit_main preinit_ip +boot_hook_add preinit_main pi_indicate_preinit + diff --git a/package/base-files/files/lib/preinit/20_check_jffs2_ready b/package/base-files/files/lib/preinit/20_check_jffs2_ready new file mode 100644 index 0000000..3c5cf67 --- /dev/null +++ b/package/base-files/files/lib/preinit/20_check_jffs2_ready @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +mount_no_jffs2() { + echo "jffs2 not ready yet; using ramdisk" + ramoverlay +} + +check_for_jffs2() { + check_skip || { + jffs2_ready || { + mount_no_jffs2 && pi_mount_skip_next=true + } + } +} + +boot_hook_add preinit_mount_root check_for_jffs2 + diff --git a/package/base-files/files/lib/preinit/30_failsafe_wait b/package/base-files/files/lib/preinit/30_failsafe_wait new file mode 100644 index 0000000..808d973 --- /dev/null +++ b/package/base-files/files/lib/preinit/30_failsafe_wait @@ -0,0 +1,84 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +fs_wait_for_key () { + local timeout=$3 + local timer + local do_failsafe + local keypress_true="$(mktemp)" + local keypress_wait="$(mktemp)" + local keypress_sec="$(mktemp)" + if [ -z "$keypress_wait" ]; then + keypress_wait=/tmp/.keypress_wait + touch $keypress_wait + fi + if [ -z "$keypress_true" ]; then + keypress_true=/tmp/.keypress_true + touch $keypress_true + fi + if [ -z "$keypress_sec" ]; then + keypress_sec=/tmp/.keypress_sec + touch $keypress_sec + fi + + trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" INT + trap "echo 'true' >$keypress_true; lock -u $keypress_wait ; rm -f $keypress_wait" USR1 + + [ -n "$timeout" ] || timeout=1 + [ $timeout -ge 1 ] || timeout=1 + timer=$timeout + lock $keypress_wait + { + while [ $timer -gt 0 ]; do + echo "$timer" >$keypress_sec + timer=$(($timer - 1)) + sleep 1 + done + lock -u $keypress_wait + rm -f $keypress_wait + } & + + echo "Press the [$1] key and hit [enter] $2" + # if we're on the console we wait for input + { + while [ -r $keypress_wait ]; do + timer="$(cat $keypress_sec)" + + [ -n "$timer" ] || timer=1 + timer="${timer%%\ *}" + [ $timer -ge 1 ] || timer=1 + do_failsafe="" + { + read -t "$timer" do_failsafe + if [ "$do_failsafe" = "$1" ]; then + echo "true" >$keypress_true + lock -u $keypress_wait + rm -f $keypress_wait + fi + } + done + } + lock -w $keypress_wait + + keypressed=1 + [ "$(cat $keypress_true)" = "true" ] && keypressed=0 + [ -f "/tmp/failsafe_button" ] && keypressed=1 + + rm -f $keypress_true + rm -f $keypress_wait + rm -f $keypress_sec + + return $keypressed +} + +failsafe_wait() { + FAILSAFE= + pi_failsafe_net_message=true + preinit_net_echo "Please press button now to enter failsafe" + pi_failsafe_net_message=false + fs_wait_for_key f 'to enter failsafe mode' $fs_failsafe_wait_timeout && FAILSAFE=true && export FAILSAFE +} + +boot_hook_add preinit_main failsafe_wait + diff --git a/package/base-files/files/lib/preinit/40_mount_jffs2 b/package/base-files/files/lib/preinit/40_mount_jffs2 new file mode 100644 index 0000000..ded785e --- /dev/null +++ b/package/base-files/files/lib/preinit/40_mount_jffs2 @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +find_mount_jffs2() { + mkdir -p /tmp/overlay + mount -o noatime -t jffs2 "$(find_mtd_part rootfs_data)" /tmp/overlay + mtd -qq unlock rootfs_data +} + +jffs2_not_mounted() { + if [ "$pi_jffs2_mount_success" != "true" ]; then + return 0 + else + return 1 + fi +} + +do_mount_jffs2() { + check_skip || { + find_mount_jffs2 && pi_jffs2_mount_success=true + } +} + +boot_hook_add preinit_mount_root do_mount_jffs2 + diff --git a/package/base-files/files/lib/preinit/40_run_failsafe_hook b/package/base-files/files/lib/preinit/40_run_failsafe_hook new file mode 100644 index 0000000..faa043c --- /dev/null +++ b/package/base-files/files/lib/preinit/40_run_failsafe_hook @@ -0,0 +1,13 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +run_failsafe_hook() { + if [ "$FAILSAFE" = "true" ]; then + boot_run_hook failsafe + lock -w /tmp/.failsafe + fi +} + +boot_hook_add preinit_main run_failsafe_hook + diff --git a/package/base-files/files/lib/preinit/41_merge_overlay_hooks b/package/base-files/files/lib/preinit/41_merge_overlay_hooks new file mode 100644 index 0000000..4ca6877 --- /dev/null +++ b/package/base-files/files/lib/preinit/41_merge_overlay_hooks @@ -0,0 +1,24 @@ +#!/bin/sh +# Copyright (C) 2010 OpenWrt.org + +merge_overlay_hooks() { + jffs2_not_mounted || [ ! -d /tmp/overlay/lib/preinit ] || { + echo "- merge overlay components -" + + mkdir -p /tmp/preinit-hook-merge + ln -sf /lib/preinit/* /tmp/overlay/lib/preinit/[0-9][0-9]_* /tmp/preinit-hook-merge/ + + boot_hook_splice_start + + local pipart + for pipart in /tmp/preinit-hook-merge/*; do + . $pipart + done + + boot_hook_splice_finish + + rm -rf /tmp/preinit-hook-merge + } +} + +boot_hook_add preinit_mount_root merge_overlay_hooks diff --git a/package/base-files/files/lib/preinit/50_indicate_regular_preinit b/package/base-files/files/lib/preinit/50_indicate_regular_preinit new file mode 100644 index 0000000..c200dad --- /dev/null +++ b/package/base-files/files/lib/preinit/50_indicate_regular_preinit @@ -0,0 +1,11 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +indicate_regular_preinit() { + preinit_net_echo "Continuing with Regular Preinit\n" + pi_indicate_led +} + +boot_hook_add preinit_main indicate_regular_preinit + diff --git a/package/base-files/files/lib/preinit/70_initramfs_test b/package/base-files/files/lib/preinit/70_initramfs_test new file mode 100644 index 0000000..15c0dcd --- /dev/null +++ b/package/base-files/files/lib/preinit/70_initramfs_test @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +initramfs_test() { + if [ -n "$INITRAMFS" ]; then + boot_run_hook initramfs + preinit_ip_deconfig + break + fi +} + +boot_hook_add preinit_main initramfs_test + diff --git a/package/base-files/files/lib/preinit/70_pivot_jffs2_root b/package/base-files/files/lib/preinit/70_pivot_jffs2_root new file mode 100644 index 0000000..b76f111 --- /dev/null +++ b/package/base-files/files/lib/preinit/70_pivot_jffs2_root @@ -0,0 +1,14 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +rootfs_pivot() { + check_skip || jffs2_not_mounted || { + echo "switching to jffs2" + mount -o noatime,move /tmp/overlay /overlay 2>&- + fopivot /overlay /rom && pi_mount_skip_next=true + } +} + +boot_hook_add preinit_mount_root rootfs_pivot + diff --git a/package/base-files/files/lib/preinit/80_mount_root b/package/base-files/files/lib/preinit/80_mount_root new file mode 100644 index 0000000..9a99ee9 --- /dev/null +++ b/package/base-files/files/lib/preinit/80_mount_root @@ -0,0 +1,9 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_root() { + boot_run_hook preinit_mount_root +} + +[ "$INITRAMFS" = "1" ] || boot_hook_add preinit_main do_mount_root diff --git a/package/base-files/files/lib/preinit/90_mount_no_jffs2 b/package/base-files/files/lib/preinit/90_mount_no_jffs2 new file mode 100644 index 0000000..d8ad4ae --- /dev/null +++ b/package/base-files/files/lib/preinit/90_mount_no_jffs2 @@ -0,0 +1,12 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_no_jffs2() { + check_skip || { + mount_no_jffs2 && pi_mount_skip_next=true + } +} + +boot_hook_add preinit_mount_root do_mount_no_jffs2 + diff --git a/package/base-files/files/lib/preinit/90_restore_config b/package/base-files/files/lib/preinit/90_restore_config new file mode 100644 index 0000000..210bf61 --- /dev/null +++ b/package/base-files/files/lib/preinit/90_restore_config @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +restore_config() { + [ -f /sysupgrade.tgz ] && { + echo "- config restore -" + cd / + mv sysupgrade.tgz /tmp + tar xzf /tmp/sysupgrade.tgz + rm -f /tmp/sysupgrade.tgz + sync + } +} + +boot_hook_add preinit_main restore_config + diff --git a/package/base-files/files/lib/preinit/99_10_failsafe_login b/package/base-files/files/lib/preinit/99_10_failsafe_login new file mode 100644 index 0000000..05d6b77 --- /dev/null +++ b/package/base-files/files/lib/preinit/99_10_failsafe_login @@ -0,0 +1,18 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +failsafe_netlogin () { + telnetd -l /bin/login.sh <> /dev/null 2>&1 +} + +failsafe_shell() { + lock /tmp/.failsafe + ash --login + echo "Please reboot system when done with failsafe network logins" +} + + +boot_hook_add failsafe failsafe_netlogin +boot_hook_add failsafe failsafe_shell + diff --git a/package/base-files/files/lib/preinit/99_10_mount_no_mtd b/package/base-files/files/lib/preinit/99_10_mount_no_mtd new file mode 100644 index 0000000..c4f38e4 --- /dev/null +++ b/package/base-files/files/lib/preinit/99_10_mount_no_mtd @@ -0,0 +1,12 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +do_mount_no_mtd() { + check_skip || { + mount_no_mtd + } +} + +boot_hook_add preinit_mount_root do_mount_no_mtd + diff --git a/package/base-files/files/lib/preinit/99_10_run_init b/package/base-files/files/lib/preinit/99_10_run_init new file mode 100644 index 0000000..a8f330f --- /dev/null +++ b/package/base-files/files/lib/preinit/99_10_run_init @@ -0,0 +1,10 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +run_init() { + preinit_ip_deconfig +} + +boot_hook_add preinit_main run_init + diff --git a/package/base-files/files/lib/upgrade/.svn/entries b/package/base-files/files/lib/upgrade/.svn/entries new file mode 100644 index 0000000..9d0891d --- /dev/null +++ b/package/base-files/files/lib/upgrade/.svn/entries @@ -0,0 +1,65 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/upgrade +svn://svn.openwrt.org/openwrt + + + +2013-03-14T18:43:58.957223Z +36031 +blogic + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +common.sh +file + + + + +2013-03-17T12:13:21.000000Z +5671955731b7ddeb547f916ec53d4129 +2013-03-14T18:43:58.957223Z +36031 +blogic + + + + + + + + + + + + + + + + + + + + + +5037 + +keep.d +dir + diff --git a/package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base b/package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base new file mode 100644 index 0000000..df842bf --- /dev/null +++ b/package/base-files/files/lib/upgrade/.svn/text-base/common.sh.svn-base @@ -0,0 +1,230 @@ +#!/bin/sh + +RAM_ROOT=/tmp/root + +ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } +libs() { ldd $* | awk '{print $3}'; } + +install_file() { # <file> [ <file> ... ] + for file in "$@"; do + dest="$RAM_ROOT/$file" + [ -f $file -a ! -f $dest ] && { + dir="$(dirname $dest)" + mkdir -p "$dir" + cp $file $dest + } + done +} + +install_bin() { # <file> [ <symlink> ... ] + src=$1 + files=$1 + [ -x "$src" ] && files="$src $(libs $src)" + install_file $files + [ -e /lib/ld-linux.so.3 ] && { + install_file /lib/ld-linux.so.3 + } + shift + for link in "$@"; do { + dest="$RAM_ROOT/$link" + dir="$(dirname $dest)" + mkdir -p "$dir" + [ -f "$dest" ] || ln -s $src $dest + }; done +} + +supivot() { # <new_root> <old_root> + mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1 + mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ + mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 || { + umount -l $1 $1 + return 1 + } + + mount -o noatime,move $2/sys /sys + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/overlay /overlay 2>&- + return 0 +} + +run_ramfs() { # <command> [...] + install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \ + /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \ + /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \ + /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \ + /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc + + install_bin /sbin/mtd + for file in $RAMFS_COPY_BIN; do + install_bin $file + done + install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA + + supivot $RAM_ROOT /mnt || { + echo "Failed to switch over to ramfs. Please reboot." + exit 1 + } + + mount -o remount,ro /mnt + umount -l /mnt + + grep /overlay /proc/mounts > /dev/null && { + mount -o noatime,remount,ro /overlay + umount -l /overlay + } + + # spawn a new shell from ramdisk to reduce the probability of cache issues + exec /bin/busybox ash -c "$*" +} + +kill_remaining() { # [ <signal> ] + local sig="${1:-TERM}" + echo -n "Sending $sig to remaining processes ... " + + local stat + for stat in /proc/[0-9]*/stat; do + [ -f "$stat" ] || continue + + local pid name state ppid rest + read pid name state ppid rest < $stat + name="${name#(}"; name="${name%)}" + + local cmdline + read cmdline < /proc/$pid/cmdline + + # Skip kernel threads + [ -n "$cmdline" ] || continue + + case "$name" in + # Skip essential services + *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;; + + # Killable process + *) + if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then + echo -n "$name " + kill -$sig $pid 2>/dev/null + fi + ;; + esac + done + echo "" +} + +run_hooks() { + local arg="$1"; shift + for func in "$@"; do + eval "$func $arg" + done +} + +ask_bool() { + local default="$1"; shift; + local answer="$default" + + [ "$INTERACTIVE" -eq 1 ] && { + case "$default" in + 0) echo -n "$* (y/N): ";; + *) echo -n "$* (Y/n): ";; + esac + read answer + case "$answer" in + y*) answer=1;; + n*) answer=0;; + *) answer="$default";; + esac + } + [ "$answer" -gt 0 ] +} + +v() { + [ "$VERBOSE" -ge 1 ] && echo "$@" +} + +rootfs_type() { + mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }' +} + +get_image() { # <source> [ <command> ] + local from="$1" + local conc="$2" + local cmd + + case "$from" in + http://*|ftp://*) cmd="wget -O- -q";; + *) cmd="cat";; + esac + if [ -z "$conc" ]; then + local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" + case "$magic" in + 1f8b) conc="zcat";; + 425a) conc="bzcat";; + esac + fi + + eval "$cmd $from ${conc:+| $conc}" +} + +get_magic_word() { + get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"' +} + +get_magic_long() { + get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' +} + +refresh_mtd_partitions() { + mtd refresh rootfs +} + +jffs2_copy_config() { + if grep rootfs_data /proc/mtd >/dev/null; then + # squashfs+jffs2 + mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data + else + # jffs2 + mtd jffs2write "$CONF_TAR" rootfs + fi +} + +default_do_upgrade() { + sync + if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then + get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}" + else + get_image "$1" | mtd write - "${PART_NAME:-image}" + fi +} + +do_upgrade() { + v "Performing system upgrade..." + if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then + platform_do_upgrade "$ARGV" + else + default_do_upgrade "$ARGV" + fi + + [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && { + v "Refreshing partitions" + if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then + platform_refresh_partitions + else + refresh_mtd_partitions + fi + if type 'platform_copy_config' >/dev/null 2>/dev/null; then + platform_copy_config + else + jffs2_copy_config + fi + } + v "Upgrade completed" + [ -n "$DELAY" ] && sleep "$DELAY" + ask_bool 1 "Reboot" && { + v "Rebooting system..." + reboot -f + sleep 5 + echo b 2>/dev/null >/proc/sysrq-trigger + } +} diff --git a/package/base-files/files/lib/upgrade/common.sh b/package/base-files/files/lib/upgrade/common.sh new file mode 100644 index 0000000..df842bf --- /dev/null +++ b/package/base-files/files/lib/upgrade/common.sh @@ -0,0 +1,230 @@ +#!/bin/sh + +RAM_ROOT=/tmp/root + +ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; } +libs() { ldd $* | awk '{print $3}'; } + +install_file() { # <file> [ <file> ... ] + for file in "$@"; do + dest="$RAM_ROOT/$file" + [ -f $file -a ! -f $dest ] && { + dir="$(dirname $dest)" + mkdir -p "$dir" + cp $file $dest + } + done +} + +install_bin() { # <file> [ <symlink> ... ] + src=$1 + files=$1 + [ -x "$src" ] && files="$src $(libs $src)" + install_file $files + [ -e /lib/ld-linux.so.3 ] && { + install_file /lib/ld-linux.so.3 + } + shift + for link in "$@"; do { + dest="$RAM_ROOT/$link" + dir="$(dirname $dest)" + mkdir -p "$dir" + [ -f "$dest" ] || ln -s $src $dest + }; done +} + +supivot() { # <new_root> <old_root> + mount | grep "on $1 type" 2>&- 1>&- || mount -o bind $1 $1 + mkdir -p $1$2 $1/proc $1/sys $1/dev $1/tmp $1/overlay && \ + mount -o noatime,move /proc $1/proc && \ + pivot_root $1 $1$2 || { + umount -l $1 $1 + return 1 + } + + mount -o noatime,move $2/sys /sys + mount -o noatime,move $2/dev /dev + mount -o noatime,move $2/tmp /tmp + mount -o noatime,move $2/overlay /overlay 2>&- + return 0 +} + +run_ramfs() { # <command> [...] + install_bin /bin/busybox /bin/ash /bin/sh /bin/mount /bin/umount \ + /sbin/pivot_root /usr/bin/wget /sbin/reboot /bin/sync /bin/dd \ + /bin/grep /bin/cp /bin/mv /bin/tar /usr/bin/md5sum "/usr/bin/[" \ + /bin/vi /bin/ls /bin/cat /usr/bin/awk /usr/bin/hexdump \ + /bin/sleep /bin/zcat /usr/bin/bzcat /usr/bin/printf /usr/bin/wc + + install_bin /sbin/mtd + for file in $RAMFS_COPY_BIN; do + install_bin $file + done + install_file /etc/resolv.conf /lib/functions.sh /lib/functions.sh /lib/upgrade/*.sh $RAMFS_COPY_DATA + + supivot $RAM_ROOT /mnt || { + echo "Failed to switch over to ramfs. Please reboot." + exit 1 + } + + mount -o remount,ro /mnt + umount -l /mnt + + grep /overlay /proc/mounts > /dev/null && { + mount -o noatime,remount,ro /overlay + umount -l /overlay + } + + # spawn a new shell from ramdisk to reduce the probability of cache issues + exec /bin/busybox ash -c "$*" +} + +kill_remaining() { # [ <signal> ] + local sig="${1:-TERM}" + echo -n "Sending $sig to remaining processes ... " + + local stat + for stat in /proc/[0-9]*/stat; do + [ -f "$stat" ] || continue + + local pid name state ppid rest + read pid name state ppid rest < $stat + name="${name#(}"; name="${name%)}" + + local cmdline + read cmdline < /proc/$pid/cmdline + + # Skip kernel threads + [ -n "$cmdline" ] || continue + + case "$name" in + # Skip essential services + *procd*|*ash*|*init*|*watchdog*|*ssh*|*dropbear*|*telnet*|*login*|*hostapd*|*wpa_supplicant*) : ;; + + # Killable process + *) + if [ $pid -ne $$ ] && [ $ppid -ne $$ ]; then + echo -n "$name " + kill -$sig $pid 2>/dev/null + fi + ;; + esac + done + echo "" +} + +run_hooks() { + local arg="$1"; shift + for func in "$@"; do + eval "$func $arg" + done +} + +ask_bool() { + local default="$1"; shift; + local answer="$default" + + [ "$INTERACTIVE" -eq 1 ] && { + case "$default" in + 0) echo -n "$* (y/N): ";; + *) echo -n "$* (Y/n): ";; + esac + read answer + case "$answer" in + y*) answer=1;; + n*) answer=0;; + *) answer="$default";; + esac + } + [ "$answer" -gt 0 ] +} + +v() { + [ "$VERBOSE" -ge 1 ] && echo "$@" +} + +rootfs_type() { + mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }' +} + +get_image() { # <source> [ <command> ] + local from="$1" + local conc="$2" + local cmd + + case "$from" in + http://*|ftp://*) cmd="wget -O- -q";; + *) cmd="cat";; + esac + if [ -z "$conc" ]; then + local magic="$(eval $cmd $from | dd bs=2 count=1 2>/dev/null | hexdump -n 2 -e '1/1 "%02x"')" + case "$magic" in + 1f8b) conc="zcat";; + 425a) conc="bzcat";; + esac + fi + + eval "$cmd $from ${conc:+| $conc}" +} + +get_magic_word() { + get_image "$@" | dd bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"' +} + +get_magic_long() { + get_image "$@" | dd bs=4 count=1 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' +} + +refresh_mtd_partitions() { + mtd refresh rootfs +} + +jffs2_copy_config() { + if grep rootfs_data /proc/mtd >/dev/null; then + # squashfs+jffs2 + mtd -e rootfs_data jffs2write "$CONF_TAR" rootfs_data + else + # jffs2 + mtd jffs2write "$CONF_TAR" rootfs + fi +} + +default_do_upgrade() { + sync + if [ "$SAVE_CONFIG" -eq 1 -a -z "$USE_REFRESH" ]; then + get_image "$1" | mtd -j "$CONF_TAR" write - "${PART_NAME:-image}" + else + get_image "$1" | mtd write - "${PART_NAME:-image}" + fi +} + +do_upgrade() { + v "Performing system upgrade..." + if type 'platform_do_upgrade' >/dev/null 2>/dev/null; then + platform_do_upgrade "$ARGV" + else + default_do_upgrade "$ARGV" + fi + + [ "$SAVE_CONFIG" -eq 1 -a -n "$USE_REFRESH" ] && { + v "Refreshing partitions" + if type 'platform_refresh_partitions' >/dev/null 2>/dev/null; then + platform_refresh_partitions + else + refresh_mtd_partitions + fi + if type 'platform_copy_config' >/dev/null 2>/dev/null; then + platform_copy_config + else + jffs2_copy_config + fi + } + v "Upgrade completed" + [ -n "$DELAY" ] && sleep "$DELAY" + ask_bool 1 "Reboot" && { + v "Rebooting system..." + reboot -f + sleep 5 + echo b 2>/dev/null >/proc/sysrq-trigger + } +} diff --git a/package/base-files/files/lib/upgrade/keep.d/.svn/entries b/package/base-files/files/lib/upgrade/keep.d/.svn/entries new file mode 100644 index 0000000..4e66190 --- /dev/null +++ b/package/base-files/files/lib/upgrade/keep.d/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/lib/upgrade/keep.d +svn://svn.openwrt.org/openwrt + + + +2010-12-20T19:51:05.233718Z +24742 +jow + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +base-files-essential +file + + + + +2013-03-17T12:13:21.000000Z +9290cfe4776fdf4e40a00d21ca852014 +2010-12-20T19:51:05.233718Z +24742 +jow + + + + + + + + + + + + + + + + + + + + + +146 + diff --git a/package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base b/package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base new file mode 100644 index 0000000..2c611d2 --- /dev/null +++ b/package/base-files/files/lib/upgrade/keep.d/.svn/text-base/base-files-essential.svn-base @@ -0,0 +1,9 @@ +# Essential files that will be always kept +/etc/hosts +/etc/inittab +/etc/group +/etc/passwd +/etc/profile +/etc/shells +/etc/sysctl.conf +/etc/rc.local diff --git a/package/base-files/files/lib/upgrade/keep.d/base-files-essential b/package/base-files/files/lib/upgrade/keep.d/base-files-essential new file mode 100644 index 0000000..2c611d2 --- /dev/null +++ b/package/base-files/files/lib/upgrade/keep.d/base-files-essential @@ -0,0 +1,9 @@ +# Essential files that will be always kept +/etc/hosts +/etc/inittab +/etc/group +/etc/passwd +/etc/profile +/etc/shells +/etc/sysctl.conf +/etc/rc.local diff --git a/package/base-files/files/rom/.svn/entries b/package/base-files/files/rom/.svn/entries new file mode 100644 index 0000000..891d42d --- /dev/null +++ b/package/base-files/files/rom/.svn/entries @@ -0,0 +1,62 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/rom +svn://svn.openwrt.org/openwrt + + + +2009-04-17T14:32:29.989894Z +15245 +nico + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +note +file + + + + +2013-03-17T12:13:22.000000Z +6e5a89f15dded527d05ebae365b50041 +2009-04-17T14:32:29.989894Z +15245 +nico +has-props + + + + + + + + + + + + + + + + + + + + +116 + diff --git a/package/base-files/files/rom/.svn/prop-base/note.svn-base b/package/base-files/files/rom/.svn/prop-base/note.svn-base new file mode 100644 index 0000000..bdbd305 --- /dev/null +++ b/package/base-files/files/rom/.svn/prop-base/note.svn-base @@ -0,0 +1,5 @@ +K 13 +svn:eol-style +V 6 +native +END diff --git a/package/base-files/files/rom/.svn/text-base/note.svn-base b/package/base-files/files/rom/.svn/text-base/note.svn-base new file mode 100644 index 0000000..1746eb0 --- /dev/null +++ b/package/base-files/files/rom/.svn/text-base/note.svn-base @@ -0,0 +1,3 @@ +SQUASHFS USERS: +After firstboot has been run, / will be jffs2 and /rom will be squashfs +(* except when in failsafe) diff --git a/package/base-files/files/rom/note b/package/base-files/files/rom/note new file mode 100644 index 0000000..1746eb0 --- /dev/null +++ b/package/base-files/files/rom/note @@ -0,0 +1,3 @@ +SQUASHFS USERS: +After firstboot has been run, / will be jffs2 and /rom will be squashfs +(* except when in failsafe) diff --git a/package/base-files/files/sbin/.svn/entries b/package/base-files/files/sbin/.svn/entries new file mode 100644 index 0000000..977ed47 --- /dev/null +++ b/package/base-files/files/sbin/.svn/entries @@ -0,0 +1,232 @@ +10 + +dir +36060 +svn://svn.openwrt.org/openwrt/trunk/package/base-files/files/sbin +svn://svn.openwrt.org/openwrt + + + +2013-02-21T11:45:14.787839Z +35712 +jogo + + + + + + + + + + + + + + +3c298f89-4303-0410-b956-a3cf2f4a3e73 + +mount_root +file + + + + +2013-03-17T12:13:22.000000Z +ef6b97908416845d1ebb9d697c3e8594 +2012-12-19T16:07:53.948034Z +34794 +mirko +has-props + + + + + + + + + + + + + + + + + + + + +512 + +sysupgrade +file + + + + +2013-03-17T12:13:22.000000Z +80dd8b00b37af0da40d9b0ca20534dfe +2013-01-02T16:21:30.448164Z +34975 +jow +has-props + + + + + + + + + + + + + + + + + + + + +4780 + +firstboot +file + + + + +2013-03-17T12:13:22.000000Z +e758da5c290339b002ad110ebefb67e5 +2013-02-21T11:45:14.787839Z +35712 +jogo +has-props + + + + + + + + + + + + + + + + + + + + +850 + +hotplug-call +file + + + + +2013-03-17T12:13:22.000000Z +391bb18bb651ae8339f16d8314216ea2 +2012-06-05T16:04:23.055438Z +32062 +jow +has-props + + + + + + + + + + + + + + + + + + + + +317 + +led.sh +file + + + + +2013-03-17T12:13:22.000000Z +9ce20c80054eec2b3f1dd983a397f979 +2012-06-05T16:04:23.055438Z +32062 +jow +has-props + + + + + + + + + + + + + + + + + + + + +500 + +wifi +file + + + + +2013-03-17T12:13:22.000000Z +833e83b54896be7375af57286730b587 +2012-06-26T15:25:33.271356Z +32503 +jow +has-props + + + + + + + + + + + + + + + + + + + + +3944 + diff --git a/package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base b/package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/sbin/.svn/prop-base/firstboot.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base b/package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/sbin/.svn/prop-base/hotplug-call.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base b/package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/sbin/.svn/prop-base/led.sh.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base b/package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/sbin/.svn/prop-base/mount_root.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base b/package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base new file mode 100644 index 0000000..869ac71 --- /dev/null +++ b/package/base-files/files/sbin/.svn/prop-base/sysupgrade.svn-base @@ -0,0 +1,5 @@ +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/sbin/.svn/prop-base/wifi.svn-base b/package/base-files/files/sbin/.svn/prop-base/wifi.svn-base new file mode 100644 index 0000000..03b5bfa --- /dev/null +++ b/package/base-files/files/sbin/.svn/prop-base/wifi.svn-base @@ -0,0 +1,9 @@ +K 13 +svn:eol-style +V 6 +native +K 14 +svn:executable +V 1 +* +END diff --git a/package/base-files/files/sbin/.svn/text-base/firstboot.svn-base b/package/base-files/files/sbin/.svn/text-base/firstboot.svn-base new file mode 100644 index 0000000..e7c0851 --- /dev/null +++ b/package/base-files/files/sbin/.svn/text-base/firstboot.svn-base @@ -0,0 +1,42 @@ +#!/bin/sh + +switch2jffs_hook= +jffs2reset_hook= +no_fo_hook= + +. /lib/functions.sh + +firstboot_skip_next=false + +for fb_source_file in /lib/firstboot/*; do + . $fb_source_file +done + +set_mtd_part +set_rom_part +set_jffs_part + +# invoked as an executable +if [ "${0##*/}" = "firstboot" ]; then + if [ "$1" = "switch2jffs" ]; then + boot_run_hook switch2jffs + else + local input + + echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]" + read input + [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0 + + if [ -n "$jffs" ]; then + reset_has_fo=true + echo "firstboot has already been run" + echo "jffs2 partition is mounted, only resetting files" + boot_run_hook jffs2reset + else + mtd erase "$partname" + mount -o noatime "$mtdpart" /overlay -t jffs2 + fopivot /overlay /rom 1 + fi + fi +fi + diff --git a/package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base b/package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base new file mode 100644 index 0000000..d627bec --- /dev/null +++ b/package/base-files/files/sbin/.svn/text-base/hotplug-call.svn-base @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org + +export HOTPLUG_TYPE="$1" + +. /lib/functions.sh + +PATH=/bin:/sbin:/usr/bin:/usr/sbin +LOGNAME=root +USER=root +export PATH LOGNAME USER + +[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && { + for script in $(ls /etc/hotplug.d/$1/* 2>&-); do ( + [ -f $script ] && . $script + ); done +} diff --git a/package/base-files/files/sbin/.svn/text-base/led.sh.svn-base b/package/base-files/files/sbin/.svn/text-base/led.sh.svn-base new file mode 100644 index 0000000..d67a0f5 --- /dev/null +++ b/package/base-files/files/sbin/.svn/text-base/led.sh.svn-base @@ -0,0 +1,25 @@ +#!/bin/sh +# (C) 2008 openwrt.org + +. /lib/functions.sh +ACTION=$1 +NAME=$2 +do_led() { + local name + local sysfs + config_get name $1 name + config_get sysfs $1 sysfs + [ "$name" == "$NAME" -o "$sysfs" = "$NAME" -a -e "/sys/class/leds/${sysfs}" ] && { + [ "$ACTION" == "set" ] && + echo 1 >/sys/class/leds/${sysfs}/brightness \ + || echo 0 >/sys/class/leds/${sysfs}/brightness + exit 0 + } +} + +[ "$1" == "clear" -o "$1" == "set" ] && + [ -n "$2" ] &&{ + config_load system + config_foreach do_led + exit 1 + } diff --git a/package/base-files/files/sbin/.svn/text-base/mount_root.svn-base b/package/base-files/files/sbin/.svn/text-base/mount_root.svn-base new file mode 100644 index 0000000..1c48eba --- /dev/null +++ b/package/base-files/files/sbin/.svn/text-base/mount_root.svn-base @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +# Initialize hook variables et by pulling in from preinit + +preinit_essential_hook= +preinit_main_hook= +failsafe_hook= +initramfs_hook= +preinit_mount_root= + +. /lib/functions.sh + +for pi_source_file in /lib/preinit/*; do + . $pi_source_file +done + +# Override function that doesn't apply to use of mount_root as a command rather +# than as part of preinit + +preinit_echo() { + echo "$@" +} + +boot_run_hook preinit_mount_root diff --git a/package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base b/package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base new file mode 100644 index 0000000..6701930 --- /dev/null +++ b/package/base-files/files/sbin/.svn/text-base/sysupgrade.svn-base @@ -0,0 +1,191 @@ +#!/bin/sh +. /lib/functions.sh + +# initialize defaults +RAMFS_COPY_BIN="" # extra programs for temporary ramfs root +RAMFS_COPY_DATA="" # extra data files +export INTERACTIVE=0 +export VERBOSE=1 +export SAVE_CONFIG=1 +export SAVE_OVERLAY=0 +export DELAY= +export CONF_IMAGE= +export CONF_BACKUP= +export CONF_RESTORE= +export NEED_IMAGE= +export HELP=0 +export FORCE=0 + +# parse options +while [ -n "$1" ]; do + case "$1" in + -i) export INTERACTIVE=1;; + -d) export DELAY="$2"; shift;; + -v) export VERBOSE="$(($VERBOSE + 1))";; + -q) export VERBOSE="$(($VERBOSE - 1))";; + -n) export SAVE_CONFIG=0;; + -c) export SAVE_OVERLAY=1;; + -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;; + -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;; + -f) export CONF_IMAGE="$2"; shift;; + -F|--force) export FORCE=1;; + -h|--help) export HELP=1; break;; + -*) + echo "Invalid option: $1" + exit 1 + ;; + *) break;; + esac + shift; +done + +export CONFFILES=/tmp/sysupgrade.conffiles +export CONF_TAR=/tmp/sysupgrade.tgz + +export ARGV="$*" +export ARGC="$#" + +[ -z "$ARGV" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && { + cat <<EOF +Usage: $0 [<upgrade-option>...] <image file or URL> + $0 [-q] [-i] <backup-command> <file> + +upgrade-option: + -d <delay> add a delay before rebooting + -f <config> restore configuration from .tar.gz (file or url) + -i interactive mode + -c attempt to preserve all changed files in /etc/ + -n do not save configuration over reflash + -F | --force + Flash image even if image checks fail, this is dangerous! + -q less verbose + -v more verbose + -h | --help display this help + +backup-command: + -b | --create-backup <file> + create .tar.gz of files specified in sysupgrade.conf + then exit. Does not flash an image. If file is '-', + i.e. stdout, verbosity is set to 0 (i.e. quiet). + -r | --restore-backup <file> + restore a .tar.gz created with sysupgrade -b + then exit. Does not flash an image. If file is '-', + the archive is read from stdin. + +EOF + exit 1 +} + +[ -n "$ARGV" -a -n "$NEED_IMAGE" ] && { + cat <<-EOF + -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade. + Do not specify both -b|-r and a firmware image. + EOF + exit 1 +} + +# prevent messages from clobbering the tarball when using stdout +[ "$CONF_BACKUP" = "-" ] && export VERBOSE=0 + +add_uci_conffiles() { + local file="$1" + ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \ + /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \ + -type f 2>/dev/null; + opkg list-changed-conffiles ) | sort -u > "$file" + return 0 +} + +add_overlayfiles() { + local file="$1" + find /overlay/etc/ -type f | sed \ + -e 's,^/overlay/,/,' \ + -e '\,/META_[a-zA-Z0-9]*$,d' \ + -e '\,/functions.sh$,d' \ + -e '\,/[^/]*-opkg$,d' \ + > "$file" + return 0 +} + +# hooks +sysupgrade_image_check="platform_check_image" +[ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \ + sysupgrade_init_conffiles="add_uci_conffiles" || \ + sysupgrade_init_conffiles="add_overlayfiles" + +include /lib/upgrade + +do_save_conffiles() { + local conf_tar="${1:-$CONF_TAR}" + + [ -z "$(rootfs_type)" ] && { + echo "Cannot save config while running from ramdisk." + ask_bool 0 "Abort" && exit + return 0 + } + run_hooks "$CONFFILES" $sysupgrade_init_conffiles + ask_bool 0 "Edit config file list" && vi "$CONFFILES" + + v "Saving config files..." + [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" + tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null +} + +if [ -n "$CONF_BACKUP" ]; then + do_save_conffiles "$CONF_BACKUP" + exit $? +fi + +if [ -f "$CONF_RESTORE" ] || [ "$CONF_RESTORE" = "-" ]; then + [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" + tar -C / -x${TAR_V}zf "$CONF_RESTORE" + exit $? +fi + +type platform_check_image >/dev/null 2>/dev/null || { + echo "Firmware upgrade is not implemented for this platform." + exit 1 +} + +for check in $sysupgrade_image_check; do + ( eval "$check \"\$ARGV\"" ) || { + if [ $FORCE -eq 1 ]; then + echo "Image check '$check' failed but --force given - will update anyway!" + break + else + echo "Image check '$check' failed." + exit 1 + fi + } +done + +if [ -n "$CONF_IMAGE" ]; then + case "$(get_magic_word $CONF_IMAGE cat)" in + # .gz files + 1f8b) ;; + *) + echo "Invalid config file. Please use only .tar.gz files" + exit 1 + ;; + esac + get_image "$CONF_IMAGE" "cat" > "$CONF_TAR" + export SAVE_CONFIG=1 +elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then + do_save_conffiles + export SAVE_CONFIG=1 +else + export SAVE_CONFIG=0 +fi + +run_hooks "" $sysupgrade_pre_upgrade + +kill_remaining TERM +sleep 3 +kill_remaining KILL + +if [ -n "$(rootfs_type)" ]; then + v "Switching to ramdisk..." + run_ramfs '. /lib/functions.sh; include /lib/upgrade; do_upgrade' +else + do_upgrade +fi diff --git a/package/base-files/files/sbin/.svn/text-base/wifi.svn-base b/package/base-files/files/sbin/.svn/text-base/wifi.svn-base new file mode 100644 index 0000000..ef20787 --- /dev/null +++ b/package/base-files/files/sbin/.svn/text-base/wifi.svn-base @@ -0,0 +1,204 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +. /lib/functions.sh + +usage() { + cat <<EOF +Usage: $0 [down|detect] +enables (default), disables or detects a wifi configuration. +EOF + exit 1 +} + +find_net_config() {( + local vif="$1" + local cfg + local ifname + + config_get cfg "$vif" network + + [ -z "$cfg" ] && { + include /lib/network + scan_interfaces + + config_get ifname "$vif" ifname + + cfg="$(find_config "$ifname")" + } + [ -z "$cfg" ] && return 0 + echo "$cfg" +)} + + +bridge_interface() {( + local cfg="$1" + [ -z "$cfg" ] && return 0 + + include /lib/network + scan_interfaces + + for cfg in $cfg; do + config_get iftype "$cfg" type + [ "$iftype" = bridge ] && config_get "$cfg" ifname + prepare_interface_bridge "$cfg" + return $? + done +)} + +prepare_key_wep() { + local key="$1" + local hex=1 + + echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0 + [ "${#key}" -eq 10 -a $hex -eq 1 ] || \ + [ "${#key}" -eq 26 -a $hex -eq 1 ] || { + [ "${key:0:2}" = "s:" ] && key="${key#s:}" + key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')" + } + echo "$key" +} + +wifi_fixup_hwmode() { + local device="$1" + local default="$2" + local hwmode hwmode_11n + + config_get channel "$device" channel + config_get hwmode "$device" hwmode + case "$hwmode" in + 11bg) hwmode=bg;; + 11a) hwmode=a;; + 11b) hwmode=b;; + 11g) hwmode=g;; + 11n*) + hwmode_11n="${hwmode##11n}" + case "$hwmode_11n" in + a|g) ;; + default) hwmode_11n="$default" + esac + config_set "$device" hwmode_11n "$hwmode_11n" + ;; + *) + hwmode= + if [ "${channel:-0}" -gt 0 ]; then + if [ "${channel:-0}" -gt 14 ]; then + hwmode=a + else + hwmode=g + fi + else + hwmode="$default" + fi + ;; + esac + config_set "$device" hwmode "$hwmode" +} + +wifi_updown() { + [ enable = "$1" ] && { + wifi_updown disable "$2" + scan_wifi + } + for device in ${2:-$DEVICES}; do ( + config_get disabled "$device" disabled + [ 1 == "$disabled" ] && { + echo "'$device' is disabled" + set disable + } + config_get iftype "$device" type + if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then + eval "scan_$iftype '$device'" + eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed" + else + echo "$device($iftype): Interface type not supported" + fi + ); done +} + +wifi_detect() { + for driver in ${2:-$DRIVERS}; do ( + if eval "type detect_$driver" 2>/dev/null >/dev/null; then + eval "detect_$driver" || echo "$driver: Detect failed" >&2 + else + echo "$driver: Hardware detection not supported" >&2 + fi + ); done +} + +start_net() {( + local iface="$1" + local config="$2" + local vifmac="$3" + + [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev/null + [ -z "$config" ] || { + include /lib/network + scan_interfaces + for config in $config; do + setup_interface "$iface" "$config" "" "$vifmac" + done + } +)} + +set_wifi_up() { + local cfg="$1" + local ifname="$2" + uci_set_state wireless "$cfg" up 1 + uci_set_state wireless "$cfg" ifname "$ifname" +} + +set_wifi_down() { + local cfg="$1" + local vifs vif vifstr + + [ -f "/var/run/wifi-${cfg}.pid" ] && + kill "$(cat "/var/run/wifi-${cfg}.pid")" 2>/dev/null + uci_revert_state wireless "$cfg" + config_get vifs "$cfg" vifs + for vif in $vifs; do + uci_revert_state wireless "$vif" + done +} + +scan_wifi() { + local cfgfile="$1" + DEVICES= + config_cb() { + local type="$1" + local section="$2" + + # section start + case "$type" in + wifi-device) + append DEVICES "$section" + config_set "$section" vifs "" + config_set "$section" ht_capab "" + ;; + esac + + # section end + config_get TYPE "$CONFIG_SECTION" TYPE + case "$TYPE" in + wifi-iface) + config_get device "$CONFIG_SECTION" device + config_get vifs "$device" vifs + append vifs "$CONFIG_SECTION" + config_set "$device" vifs "$vifs" + ;; + esac + } + config_load "${cfgfile:-wireless}" +} + +DEVICES= +DRIVERS= +include /lib/wifi +scan_wifi + +case "$1" in + down) wifi_updown "disable" "$2";; + detect) wifi_detect "$2";; + --help|help) usage;; + *) wifi_updown "enable" "$2";; +esac diff --git a/package/base-files/files/sbin/firstboot b/package/base-files/files/sbin/firstboot new file mode 100755 index 0000000..e7c0851 --- /dev/null +++ b/package/base-files/files/sbin/firstboot @@ -0,0 +1,42 @@ +#!/bin/sh + +switch2jffs_hook= +jffs2reset_hook= +no_fo_hook= + +. /lib/functions.sh + +firstboot_skip_next=false + +for fb_source_file in /lib/firstboot/*; do + . $fb_source_file +done + +set_mtd_part +set_rom_part +set_jffs_part + +# invoked as an executable +if [ "${0##*/}" = "firstboot" ]; then + if [ "$1" = "switch2jffs" ]; then + boot_run_hook switch2jffs + else + local input + + echo -n "firstboot will erase all settings and remove any installed packages. Are you sure? [N/y]" + read input + [ "$input" = "y" ] || [ "$input" = "Y" ] || return 0 + + if [ -n "$jffs" ]; then + reset_has_fo=true + echo "firstboot has already been run" + echo "jffs2 partition is mounted, only resetting files" + boot_run_hook jffs2reset + else + mtd erase "$partname" + mount -o noatime "$mtdpart" /overlay -t jffs2 + fopivot /overlay /rom 1 + fi + fi +fi + diff --git a/package/base-files/files/sbin/hotplug-call b/package/base-files/files/sbin/hotplug-call new file mode 100755 index 0000000..d627bec --- /dev/null +++ b/package/base-files/files/sbin/hotplug-call @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org + +export HOTPLUG_TYPE="$1" + +. /lib/functions.sh + +PATH=/bin:/sbin:/usr/bin:/usr/sbin +LOGNAME=root +USER=root +export PATH LOGNAME USER + +[ \! -z "$1" -a -d /etc/hotplug.d/$1 ] && { + for script in $(ls /etc/hotplug.d/$1/* 2>&-); do ( + [ -f $script ] && . $script + ); done +} diff --git a/package/base-files/files/sbin/led.sh b/package/base-files/files/sbin/led.sh new file mode 100755 index 0000000..d67a0f5 --- /dev/null +++ b/package/base-files/files/sbin/led.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# (C) 2008 openwrt.org + +. /lib/functions.sh +ACTION=$1 +NAME=$2 +do_led() { + local name + local sysfs + config_get name $1 name + config_get sysfs $1 sysfs + [ "$name" == "$NAME" -o "$sysfs" = "$NAME" -a -e "/sys/class/leds/${sysfs}" ] && { + [ "$ACTION" == "set" ] && + echo 1 >/sys/class/leds/${sysfs}/brightness \ + || echo 0 >/sys/class/leds/${sysfs}/brightness + exit 0 + } +} + +[ "$1" == "clear" -o "$1" == "set" ] && + [ -n "$2" ] &&{ + config_load system + config_foreach do_led + exit 1 + } diff --git a/package/base-files/files/sbin/mount_root b/package/base-files/files/sbin/mount_root new file mode 100755 index 0000000..1c48eba --- /dev/null +++ b/package/base-files/files/sbin/mount_root @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2010 Vertical Communications + +# Initialize hook variables et by pulling in from preinit + +preinit_essential_hook= +preinit_main_hook= +failsafe_hook= +initramfs_hook= +preinit_mount_root= + +. /lib/functions.sh + +for pi_source_file in /lib/preinit/*; do + . $pi_source_file +done + +# Override function that doesn't apply to use of mount_root as a command rather +# than as part of preinit + +preinit_echo() { + echo "$@" +} + +boot_run_hook preinit_mount_root diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade new file mode 100755 index 0000000..6701930 --- /dev/null +++ b/package/base-files/files/sbin/sysupgrade @@ -0,0 +1,191 @@ +#!/bin/sh +. /lib/functions.sh + +# initialize defaults +RAMFS_COPY_BIN="" # extra programs for temporary ramfs root +RAMFS_COPY_DATA="" # extra data files +export INTERACTIVE=0 +export VERBOSE=1 +export SAVE_CONFIG=1 +export SAVE_OVERLAY=0 +export DELAY= +export CONF_IMAGE= +export CONF_BACKUP= +export CONF_RESTORE= +export NEED_IMAGE= +export HELP=0 +export FORCE=0 + +# parse options +while [ -n "$1" ]; do + case "$1" in + -i) export INTERACTIVE=1;; + -d) export DELAY="$2"; shift;; + -v) export VERBOSE="$(($VERBOSE + 1))";; + -q) export VERBOSE="$(($VERBOSE - 1))";; + -n) export SAVE_CONFIG=0;; + -c) export SAVE_OVERLAY=1;; + -b|--create-backup) export CONF_BACKUP="$2" NEED_IMAGE=1; shift;; + -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; shift;; + -f) export CONF_IMAGE="$2"; shift;; + -F|--force) export FORCE=1;; + -h|--help) export HELP=1; break;; + -*) + echo "Invalid option: $1" + exit 1 + ;; + *) break;; + esac + shift; +done + +export CONFFILES=/tmp/sysupgrade.conffiles +export CONF_TAR=/tmp/sysupgrade.tgz + +export ARGV="$*" +export ARGC="$#" + +[ -z "$ARGV" -a -z "$NEED_IMAGE" -o $HELP -gt 0 ] && { + cat <<EOF +Usage: $0 [<upgrade-option>...] <image file or URL> + $0 [-q] [-i] <backup-command> <file> + +upgrade-option: + -d <delay> add a delay before rebooting + -f <config> restore configuration from .tar.gz (file or url) + -i interactive mode + -c attempt to preserve all changed files in /etc/ + -n do not save configuration over reflash + -F | --force + Flash image even if image checks fail, this is dangerous! + -q less verbose + -v more verbose + -h | --help display this help + +backup-command: + -b | --create-backup <file> + create .tar.gz of files specified in sysupgrade.conf + then exit. Does not flash an image. If file is '-', + i.e. stdout, verbosity is set to 0 (i.e. quiet). + -r | --restore-backup <file> + restore a .tar.gz created with sysupgrade -b + then exit. Does not flash an image. If file is '-', + the archive is read from stdin. + +EOF + exit 1 +} + +[ -n "$ARGV" -a -n "$NEED_IMAGE" ] && { + cat <<-EOF + -b|--create-backup and -r|--restore-backup do not perform a firmware upgrade. + Do not specify both -b|-r and a firmware image. + EOF + exit 1 +} + +# prevent messages from clobbering the tarball when using stdout +[ "$CONF_BACKUP" = "-" ] && export VERBOSE=0 + +add_uci_conffiles() { + local file="$1" + ( find $(sed -ne '/^[[:space:]]*$/d; /^#/d; p' \ + /etc/sysupgrade.conf /lib/upgrade/keep.d/* 2>/dev/null) \ + -type f 2>/dev/null; + opkg list-changed-conffiles ) | sort -u > "$file" + return 0 +} + +add_overlayfiles() { + local file="$1" + find /overlay/etc/ -type f | sed \ + -e 's,^/overlay/,/,' \ + -e '\,/META_[a-zA-Z0-9]*$,d' \ + -e '\,/functions.sh$,d' \ + -e '\,/[^/]*-opkg$,d' \ + > "$file" + return 0 +} + +# hooks +sysupgrade_image_check="platform_check_image" +[ $SAVE_OVERLAY = 0 -o ! -d /overlay/etc ] && \ + sysupgrade_init_conffiles="add_uci_conffiles" || \ + sysupgrade_init_conffiles="add_overlayfiles" + +include /lib/upgrade + +do_save_conffiles() { + local conf_tar="${1:-$CONF_TAR}" + + [ -z "$(rootfs_type)" ] && { + echo "Cannot save config while running from ramdisk." + ask_bool 0 "Abort" && exit + return 0 + } + run_hooks "$CONFFILES" $sysupgrade_init_conffiles + ask_bool 0 "Edit config file list" && vi "$CONFFILES" + + v "Saving config files..." + [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" + tar c${TAR_V}zf "$conf_tar" -T "$CONFFILES" 2>/dev/null +} + +if [ -n "$CONF_BACKUP" ]; then + do_save_conffiles "$CONF_BACKUP" + exit $? +fi + +if [ -f "$CONF_RESTORE" ] || [ "$CONF_RESTORE" = "-" ]; then + [ "$VERBOSE" -gt 1 ] && TAR_V="v" || TAR_V="" + tar -C / -x${TAR_V}zf "$CONF_RESTORE" + exit $? +fi + +type platform_check_image >/dev/null 2>/dev/null || { + echo "Firmware upgrade is not implemented for this platform." + exit 1 +} + +for check in $sysupgrade_image_check; do + ( eval "$check \"\$ARGV\"" ) || { + if [ $FORCE -eq 1 ]; then + echo "Image check '$check' failed but --force given - will update anyway!" + break + else + echo "Image check '$check' failed." + exit 1 + fi + } +done + +if [ -n "$CONF_IMAGE" ]; then + case "$(get_magic_word $CONF_IMAGE cat)" in + # .gz files + 1f8b) ;; + *) + echo "Invalid config file. Please use only .tar.gz files" + exit 1 + ;; + esac + get_image "$CONF_IMAGE" "cat" > "$CONF_TAR" + export SAVE_CONFIG=1 +elif ask_bool $SAVE_CONFIG "Keep config files over reflash"; then + do_save_conffiles + export SAVE_CONFIG=1 +else + export SAVE_CONFIG=0 +fi + +run_hooks "" $sysupgrade_pre_upgrade + +kill_remaining TERM +sleep 3 +kill_remaining KILL + +if [ -n "$(rootfs_type)" ]; then + v "Switching to ramdisk..." + run_ramfs '. /lib/functions.sh; include /lib/upgrade; do_upgrade' +else + do_upgrade +fi diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi new file mode 100755 index 0000000..ef20787 --- /dev/null +++ b/package/base-files/files/sbin/wifi @@ -0,0 +1,204 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +. /lib/functions.sh + +usage() { + cat <<EOF +Usage: $0 [down|detect] +enables (default), disables or detects a wifi configuration. +EOF + exit 1 +} + +find_net_config() {( + local vif="$1" + local cfg + local ifname + + config_get cfg "$vif" network + + [ -z "$cfg" ] && { + include /lib/network + scan_interfaces + + config_get ifname "$vif" ifname + + cfg="$(find_config "$ifname")" + } + [ -z "$cfg" ] && return 0 + echo "$cfg" +)} + + +bridge_interface() {( + local cfg="$1" + [ -z "$cfg" ] && return 0 + + include /lib/network + scan_interfaces + + for cfg in $cfg; do + config_get iftype "$cfg" type + [ "$iftype" = bridge ] && config_get "$cfg" ifname + prepare_interface_bridge "$cfg" + return $? + done +)} + +prepare_key_wep() { + local key="$1" + local hex=1 + + echo -n "$key" | grep -qE "[^a-fA-F0-9]" && hex=0 + [ "${#key}" -eq 10 -a $hex -eq 1 ] || \ + [ "${#key}" -eq 26 -a $hex -eq 1 ] || { + [ "${key:0:2}" = "s:" ] && key="${key#s:}" + key="$(echo -n "$key" | hexdump -ve '1/1 "%02x" ""')" + } + echo "$key" +} + +wifi_fixup_hwmode() { + local device="$1" + local default="$2" + local hwmode hwmode_11n + + config_get channel "$device" channel + config_get hwmode "$device" hwmode + case "$hwmode" in + 11bg) hwmode=bg;; + 11a) hwmode=a;; + 11b) hwmode=b;; + 11g) hwmode=g;; + 11n*) + hwmode_11n="${hwmode##11n}" + case "$hwmode_11n" in + a|g) ;; + default) hwmode_11n="$default" + esac + config_set "$device" hwmode_11n "$hwmode_11n" + ;; + *) + hwmode= + if [ "${channel:-0}" -gt 0 ]; then + if [ "${channel:-0}" -gt 14 ]; then + hwmode=a + else + hwmode=g + fi + else + hwmode="$default" + fi + ;; + esac + config_set "$device" hwmode "$hwmode" +} + +wifi_updown() { + [ enable = "$1" ] && { + wifi_updown disable "$2" + scan_wifi + } + for device in ${2:-$DEVICES}; do ( + config_get disabled "$device" disabled + [ 1 == "$disabled" ] && { + echo "'$device' is disabled" + set disable + } + config_get iftype "$device" type + if eval "type ${1}_$iftype" 2>/dev/null >/dev/null; then + eval "scan_$iftype '$device'" + eval "${1}_$iftype '$device'" || echo "$device($iftype): ${1} failed" + else + echo "$device($iftype): Interface type not supported" + fi + ); done +} + +wifi_detect() { + for driver in ${2:-$DRIVERS}; do ( + if eval "type detect_$driver" 2>/dev/null >/dev/null; then + eval "detect_$driver" || echo "$driver: Detect failed" >&2 + else + echo "$driver: Hardware detection not supported" >&2 + fi + ); done +} + +start_net() {( + local iface="$1" + local config="$2" + local vifmac="$3" + + [ -f "/var/run/$iface.pid" ] && kill "$(cat /var/run/${iface}.pid)" 2>/dev/null + [ -z "$config" ] || { + include /lib/network + scan_interfaces + for config in $config; do + setup_interface "$iface" "$config" "" "$vifmac" + done + } +)} + +set_wifi_up() { + local cfg="$1" + local ifname="$2" + uci_set_state wireless "$cfg" up 1 + uci_set_state wireless "$cfg" ifname "$ifname" +} + +set_wifi_down() { + local cfg="$1" + local vifs vif vifstr + + [ -f "/var/run/wifi-${cfg}.pid" ] && + kill "$(cat "/var/run/wifi-${cfg}.pid")" 2>/dev/null + uci_revert_state wireless "$cfg" + config_get vifs "$cfg" vifs + for vif in $vifs; do + uci_revert_state wireless "$vif" + done +} + +scan_wifi() { + local cfgfile="$1" + DEVICES= + config_cb() { + local type="$1" + local section="$2" + + # section start + case "$type" in + wifi-device) + append DEVICES "$section" + config_set "$section" vifs "" + config_set "$section" ht_capab "" + ;; + esac + + # section end + config_get TYPE "$CONFIG_SECTION" TYPE + case "$TYPE" in + wifi-iface) + config_get device "$CONFIG_SECTION" device + config_get vifs "$device" vifs + append vifs "$CONFIG_SECTION" + config_set "$device" vifs "$vifs" + ;; + esac + } + config_load "${cfgfile:-wireless}" +} + +DEVICES= +DRIVERS= +include /lib/wifi +scan_wifi + +case "$1" in + down) wifi_updown "disable" "$2";; + detect) wifi_detect "$2";; + --help|help) usage;; + *) wifi_updown "enable" "$2";; +esac |