aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/default
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-10-13 22:51:49 +0200
committerFelix Fietkau <nbd@openwrt.org>2016-03-20 17:29:15 +0100
commit60c1f0f64d23003a19a07d6b9638542130f6641d (patch)
tree8fb2787f4c49baded97cd55e0c371fe1cffce2b6 /package/base-files/default
parentd58a09110ccfa95f06c983fe796806f2e035c9d2 (diff)
parentb3ce218b51746d3a576221ea542facf3a1703ab2 (diff)
downloadupstream-60c1f0f64d23003a19a07d6b9638542130f6641d.tar.gz
upstream-60c1f0f64d23003a19a07d6b9638542130f6641d.tar.bz2
upstream-60c1f0f64d23003a19a07d6b9638542130f6641d.zip
finally move buildroot-ng to trunk
Diffstat (limited to 'package/base-files/default')
-rwxr-xr-xpackage/base-files/default/bin/ipcalc32
-rwxr-xr-xpackage/base-files/default/bin/login18
-rwxr-xr-xpackage/base-files/default/bin/uci159
-rw-r--r--package/base-files/default/etc/banner10
-rw-r--r--package/base-files/default/etc/config/network13
-rwxr-xr-xpackage/base-files/default/etc/functions.sh119
-rw-r--r--package/base-files/default/etc/group2
-rw-r--r--package/base-files/default/etc/hosts1
-rwxr-xr-xpackage/base-files/default/etc/hotplug.d/block/01-mount26
-rw-r--r--package/base-files/default/etc/hotplug.d/net/10-net28
-rwxr-xr-xpackage/base-files/default/etc/hotplug.d/usb/01-ln33
-rwxr-xr-xpackage/base-files/default/etc/init.d/S10boot25
-rwxr-xr-xpackage/base-files/default/etc/init.d/S40network11
-rwxr-xr-xpackage/base-files/default/etc/init.d/S50httpd10
-rwxr-xr-xpackage/base-files/default/etc/init.d/S50telnet10
-rwxr-xr-xpackage/base-files/default/etc/init.d/S60cron12
-rwxr-xr-xpackage/base-files/default/etc/init.d/rcS26
-rw-r--r--package/base-files/default/etc/inittab3
-rw-r--r--package/base-files/default/etc/ipkg.conf3
-rw-r--r--package/base-files/default/etc/nvram.sh19
-rw-r--r--package/base-files/default/etc/passwd2
-rw-r--r--package/base-files/default/etc/profile12
-rw-r--r--package/base-files/default/etc/protocols56
-rwxr-xr-xpackage/base-files/default/etc/rc.common73
-rw-r--r--package/base-files/default/etc/resolv.conf2
-rw-r--r--package/base-files/default/etc/shells1
-rw-r--r--package/base-files/default/etc/sysctl.conf12
-rw-r--r--package/base-files/default/lib/config/uci-update.awk160
-rwxr-xr-xpackage/base-files/default/lib/config/uci.sh138
-rwxr-xr-xpackage/base-files/default/lib/network/config.sh143
-rw-r--r--package/base-files/default/rom/note3
-rwxr-xr-xpackage/base-files/default/sbin/hotplug26
-rwxr-xr-xpackage/base-files/default/sbin/ifdown34
-rwxr-xr-xpackage/base-files/default/sbin/ifup14
-rwxr-xr-xpackage/base-files/default/sbin/mount_root10
-rwxr-xr-xpackage/base-files/default/sbin/wifi44
-rw-r--r--package/base-files/default/usr/lib/common.awk68
-rw-r--r--package/base-files/default/usr/lib/parse-config.awk42
-rwxr-xr-xpackage/base-files/default/usr/share/udhcpc/default.script57
39 files changed, 1457 insertions, 0 deletions
diff --git a/package/base-files/default/bin/ipcalc b/package/base-files/default/bin/ipcalc
new file mode 100755
index 0000000000..e8efa6b96c
--- /dev/null
+++ b/package/base-files/default/bin/ipcalc
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+awk -f /usr/lib/common.awk -f - $* <<EOF
+BEGIN {
+ ipaddr=ip2int(ARGV[1])
+ netmask=ip2int(ARGV[2])
+ network=and(ipaddr,netmask)
+ broadcast=or(network,compl(netmask))
+
+ start=or(network,and(ip2int(ARGV[3]),compl(netmask)))
+ limit=network+1
+ if (start<limit) start=limit
+
+ end=start+ARGV[4]
+ limit=or(network,compl(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(compl(netmask))
+
+ # range calculations:
+ # ipcalc <ip> <netmask> <start> <num>
+
+ if (ARGC > 3) {
+ print "START="int2ip(start)
+ print "END="int2ip(end-1)
+ }
+}
+EOF
diff --git a/package/base-files/default/bin/login b/package/base-files/default/bin/login
new file mode 100755
index 0000000000..ff5d3660e4
--- /dev/null
+++ b/package/base-files/default/bin/login
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+grep '^root:[^!]' /etc/passwd >&- 2>&-
+[ "$?" = "0" -a -z "$FAILSAFE" ] &&
+{
+ echo "Login failed."
+ exit 0
+} || {
+cat << EOF
+ === IMPORTANT ============================
+ Use 'passwd' to set your login password
+ this will disable telnet and enable SSH
+ ------------------------------------------
+EOF
+}
+
+exec /bin/ash --login
diff --git a/package/base-files/default/bin/uci b/package/base-files/default/bin/uci
new file mode 100755
index 0000000000..7f43549471
--- /dev/null
+++ b/package/base-files/default/bin/uci
@@ -0,0 +1,159 @@
+#!/bin/sh
+# Shell script for interacting with config files
+#
+# Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraumhofer.de>
+# Copyright (C) 2006 by Felix Fietkau <nbd@openwrt.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+. /etc/functions.sh
+include /lib/config
+
+do_get() {
+ [ $# -ne 3 ] && {
+ uci_usage get
+ exit 1
+ }
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ uci_load "$PACAKGE"
+ config_get "$CONFIG" "$OPTION"
+}
+
+do_set() {
+ [ $# -ne 4 ] && {
+ uci_usage set
+ exit 1
+ }
+ uci_set "$@"
+}
+
+do_add() {
+ [ $# -ne 3 ] && {
+ uci_usage add
+ exit 1
+ }
+ uci_add "$@"
+}
+
+do_rename() {
+ [ $# -ne 3 ] && {
+ uci_usage rename
+ exit 1
+ }
+ uci_rename "$@"
+}
+
+do_remove() {
+ [ $# -ne 3 -a $# -ne 2 ] && {
+ uci_usage rename
+ exit 1
+ }
+ uci_remove "$@"
+}
+
+do_commit() {
+ [ $# -ne 1 ] && {
+ uci_usage commit
+ exit 1
+ }
+ uci_commit "$1"
+}
+
+do_show() {
+ [ $# -gt 2 -o $# -lt 1 ] && {
+ uci_usage show
+ exit 1
+ }
+
+ PACKAGE="$1"
+ CONFIG="$2"
+ SECTION=""
+
+ config_cb() {
+ if [ -z "$CONFIG" -o "$CONFIG" = "$2" ]; then
+ append SECTION "$2"
+ option_cb() {
+ append "${CONFIG_SECTION}_VARS" "$1"
+ }
+ else
+ option_cb() {
+ return 0
+ }
+ fi
+ }
+
+ uci_load "$PACKAGE"
+
+ for section in $SECTION; do
+ config_get type "$section" TYPE
+ [ -z "$type" ] && continue
+ echo "@$section=$type"
+ eval "VARS=\"\${${section}_VARS}\""
+ for var in $VARS; do
+ config_get val "$section" "$var"
+ [ -n "$val" ] && {
+ echo "${section}.${var}=${val}"
+ config_set "$section" "$var" ""
+ }
+ done
+ config_set "$section" TYPE ""
+ done
+}
+
+uci_usage() {
+ case "$1" in
+ show) echo "$0 show <package> [<config>]";;
+ get) echo "$0 get <package> <config> <option>";;
+ set) echo "$0 set <package> <config> <option> <value>";;
+ add) echo "$0 add <package> <type> <config>";;
+ del) echo "$0 del <package> <config> [<option>]";;
+ rename) echo "$0 rename <package> <config> <name>";;
+ commit) echo "$0 commit <package>";;
+ *)
+ echo "Syntax: $0 <command> <arguments...>"
+ echo
+ uci_usage show
+ uci_usage get
+ uci_usage set
+ uci_usage add
+ uci_usage del
+ uci_usage rename
+ uci_usage commit
+ echo
+ exit 1
+ ;;
+ esac
+}
+
+if [ $# -eq 0 ] ; then
+ uci_usage
+ exit 0
+fi
+CMD="$1"
+shift
+case "$CMD" in
+ set) do_set "$@";;
+ add) do_add "$@";;
+ del) do_remove "$@";;
+ rename) do_rename "$@";;
+ get) do_get "$@";;
+ show) do_show "$@";;
+ commit) do_commit "$@";;
+ *) uci_usage;;
+esac
+exit 0
diff --git a/package/base-files/default/etc/banner b/package/base-files/default/etc/banner
new file mode 100644
index 0000000000..c2fbc12680
--- /dev/null
+++ b/package/base-files/default/etc/banner
@@ -0,0 +1,10 @@
+ _______ ________ __
+ | |.-----.-----.-----.| | | |.----.| |_
+ | - || _ | -__| || | | || _|| _|
+ |_______|| __|_____|__|__||________||__| |____|
+ |__| W I R E L E S S F R E E D O M
+ KAMIKAZE (bleeding edge, $R) -------------------
+ * 10 oz Vodka Shake well with ice and strain
+ * 10 oz Triple sec mixture into 10 shot glasses.
+ * 10 oz lime juice Salute!
+ ---------------------------------------------------
diff --git a/package/base-files/default/etc/config/network b/package/base-files/default/etc/config/network
new file mode 100644
index 0000000000..1d5ded3728
--- /dev/null
+++ b/package/base-files/default/etc/config/network
@@ -0,0 +1,13 @@
+# 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 proto static
+ option ipaddr 192.168.1.1
+ option netmask 255.255.255.0
diff --git a/package/base-files/default/etc/functions.sh b/package/base-files/default/etc/functions.sh
new file mode 100755
index 0000000000..9c3057ed00
--- /dev/null
+++ b/package/base-files/default/etc/functions.sh
@@ -0,0 +1,119 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006 Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
+
+alias debug=${DEBUG:-:}
+
+# newline
+N="
+"
+
+_C=0
+
+# valid interface?
+if_valid () (
+ ifconfig "$1" >&- 2>&- ||
+ [ "${1%%[0-9]}" = "br" ] ||
+ { debug "# missing interface '$1' ignored"; false; }
+)
+
+hotplug_dev() {
+ env -i ACTION=$1 INTERFACE=$2 /sbin/hotplug net
+}
+
+append() {
+ local var="$1"
+ local value="$2"
+ local sep="${3:- }"
+ eval "export ${var}=\"\${${var}:+\${${var}}${value:+$sep}}\$value\""
+}
+
+reset_cb() {
+ config_cb() {
+ return 0
+ }
+ option_cb() {
+ return 0
+ }
+}
+reset_cb
+
+config () {
+ local cfgtype="$1"
+ local name="$2"
+ _C=$(($_C + 1))
+ name="${name:-cfg${_C}}"
+ config_cb "$cfgtype" "$name"
+ export CONFIG_SECTION="$name"
+ export CONFIG_${CONFIG_SECTION}_TYPE="$cfgtype"
+}
+
+option () {
+ local varname="$1"; shift
+ export CONFIG_${CONFIG_SECTION}_${varname}="$*"
+ option_cb "$varname" "$*"
+}
+
+config_rename() {
+ local OLD="$1"
+ local NEW="$2"
+ local oldsetting
+ local newvar
+
+ [ -z "$OLD" -o -z "$NEW" ] && return
+ for oldsetting in `set | grep ^CONFIG_${OLD}_ | \
+ sed -e 's/\(.*\)=.*$/\1/'` ; do
+ newvar="CONFIG_${NEW}_${oldsetting##CONFIG_${OLD}_}"
+ eval "${newvar}=\${$oldsetting}"
+ unset "$oldsetting"
+ done
+ [ "$CONFIG_SECTION" = "$OLD" ] && CONFIG_SECTION="$NEW"
+}
+
+config_unset() {
+ config_set "$1" "$2" ""
+}
+
+config_clear() {
+ [ -z "$CONFIG_SECTION" ] && return
+ for oldsetting in `set | grep ^CONFIG_${CONFIG_SECTION}_ | \
+ sed -e 's/\(.*\)=.*$/\1/'` ; do
+ unset $oldsetting
+ done
+ unset CONFIG_SECTION
+}
+
+config_load() {
+ local DIR="./"
+ _C=0
+ [ \! -e "$1" -a -e "/etc/config/$1" ] && {
+ DIR="/etc/config/"
+ }
+ [ -e "$DIR$1" ] && {
+ CONFIG_FILENAME="$DIR$1"
+ . ${CONFIG_FILENAME}
+ } || return 1
+ ${CD:+cd -} >/dev/null
+ ${CONFIG_SECTION:+config_cb}
+}
+
+config_get() {
+ case "$3" in
+ "") eval "echo \"\${CONFIG_${1}_${2}}\"";;
+ *) eval "$1=\"\${CONFIG_${2}_${3}}\"";;
+ esac
+}
+
+config_set() {
+ export CONFIG_${1}_${2}="${3}"
+}
+
+load_modules() {
+ sed 's/^[^#]/insmod &/' $* | ash 2>&- || :
+}
+
+include() {
+ for file in $(ls $1/*.sh 2>/dev/null); do
+ . $file
+ done
+}
diff --git a/package/base-files/default/etc/group b/package/base-files/default/etc/group
new file mode 100644
index 0000000000..c4e77f316a
--- /dev/null
+++ b/package/base-files/default/etc/group
@@ -0,0 +1,2 @@
+root:x:0:
+nogroup:x:65534:
diff --git a/package/base-files/default/etc/hosts b/package/base-files/default/etc/hosts
new file mode 100644
index 0000000000..ce138ec1e6
--- /dev/null
+++ b/package/base-files/default/etc/hosts
@@ -0,0 +1 @@
+127.0.0.1 localhost OpenWrt
diff --git a/package/base-files/default/etc/hotplug.d/block/01-mount b/package/base-files/default/etc/hotplug.d/block/01-mount
new file mode 100755
index 0000000000..b6275e5a28
--- /dev/null
+++ b/package/base-files/default/etc/hotplug.d/block/01-mount
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+DEV=${DEVPATH##*/}
+{
+echo "ACTION=$ACTION DEVPATH=$DEVPATH $0 $*"
+case "$ACTION" in
+add)
+ echo -ne "waiting for $DEV"
+ while [ ! -b /dev/$DEV ]; do {
+ echo -ne "."
+ sleep 1
+ time=$((time+1)); [ $time -gt 10 ] && break
+ }; done
+
+ [ ${DEV%%[0-9]} != ${DEV} ] && {
+ mkdir -p /tmp/$DEV
+ mount /dev/$DEV /tmp/$DEV -t auto -o sync
+ }
+ ;;
+remove)
+ umount /tmp/$DEV
+ rm -rf /dev/$DEV /tmp/$DEV
+ ;;
+esac
+} 2>&1 | logger
diff --git a/package/base-files/default/etc/hotplug.d/net/10-net b/package/base-files/default/etc/hotplug.d/net/10-net
new file mode 100644
index 0000000000..4e5c3041b5
--- /dev/null
+++ b/package/base-files/default/etc/hotplug.d/net/10-net
@@ -0,0 +1,28 @@
+# Copyright (C) 2006 OpenWrt.org
+
+include /lib/network
+
+addif() {
+ scan_interfaces
+ setup_interface "$INTERFACE"
+
+ # find all vlan configurations for this interface and set them up as well
+ for ifc in $interfaces; do
+ config_get iftype "$ifc" type
+ config_get ifs "$ifc" device
+ for dev in $ifs; do
+ [ "${dev%%\.*}" = "$INTERFACE" -a "$dev" != "$INTERFACE" ] && {
+ add_vlan "$dev"
+ }
+ done
+ done
+}
+
+case "$ACTION" in
+ add|register)
+ case "$PHYSDEVDRIVER" in
+ natsemi) sleep 1;;
+ esac
+ addif
+ ;;
+esac
diff --git a/package/base-files/default/etc/hotplug.d/usb/01-ln b/package/base-files/default/etc/hotplug.d/usb/01-ln
new file mode 100755
index 0000000000..f9eda02988
--- /dev/null
+++ b/package/base-files/default/etc/hotplug.d/usb/01-ln
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+case "$ACTION" in
+add)
+ [ -f /sys/${DEVPATH}/idVendor -a "$(cat /sys/${DEVPATH}/idVendor)" -ne "0000" ] && {
+ cd /sys/${DEVPATH}
+
+ NUM=${DEVPATH##*/}
+ HOST=$(find ${NUM}:*/host* -type d)
+ HOST=${HOST##*/host}
+
+ echo -ne "waiting for disk"
+
+ while [ ! -d "/dev/scsi/host${HOST}/bus0/target0/lun0" ]; do {
+ echo -ne "."
+ sleep 1;
+ time=$((time+1)); [ $time -gt 10 ] && break
+ }; done
+ echo
+
+ cd /sys/bus/scsi/devices/${HOST}\:0\:0\:0
+ for BLOCK in block:* ; do {
+ cd ${BLOCK}
+ BLOCK=${BLOCK##block\:}
+ ln -sf /dev/scsi/host${HOST}/bus0/target0/lun0/disc /dev/${BLOCK}
+ for DEV in ${BLOCK}*; do {
+ ln -sf /dev/scsi/host${HOST}/bus0/target0/lun0/part${DEV##$BLOCK} /dev/$DEV
+ }; done
+ }; done
+ } 2>&1 | logger
+ ;;
+esac
diff --git a/package/base-files/default/etc/init.d/S10boot b/package/base-files/default/etc/init.d/S10boot
new file mode 100755
index 0000000000..77b5ca72d5
--- /dev/null
+++ b/package/base-files/default/etc/init.d/S10boot
@@ -0,0 +1,25 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start() {
+ [ -f /proc/mounts ] || /sbin/mount_root
+ [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+ vconfig set_name_type DEV_PLUS_VID_NO_PAD
+
+ HOSTNAME=${wan_hostname%%.*}
+ echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
+
+ mkdir -p /var/run
+ mkdir -p /var/log
+ mkdir -p /var/lock
+ touch /var/log/wtmp
+ touch /var/log/lastlog
+ [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+
+ # manually trigger hotplug before loading modules
+ for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
+ /usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug net
+ done
+
+ load_modules /etc/modules /etc/modules.d/*
+}
diff --git a/package/base-files/default/etc/init.d/S40network b/package/base-files/default/etc/init.d/S40network
new file mode 100755
index 0000000000..be045045e7
--- /dev/null
+++ b/package/base-files/default/etc/init.d/S40network
@@ -0,0 +1,11 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start() {
+ setup_switch() { return 0; }
+
+ include /lib/network
+ setup_switch
+ /sbin/wifi
+}
+
diff --git a/package/base-files/default/etc/init.d/S50httpd b/package/base-files/default/etc/init.d/S50httpd
new file mode 100755
index 0000000000..a05b10c094
--- /dev/null
+++ b/package/base-files/default/etc/init.d/S50httpd
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start() {
+ [ -d /www ] && httpd -p 80 -h /www -r OpenWrt
+}
+
+stop() {
+ killall httpd
+}
diff --git a/package/base-files/default/etc/init.d/S50telnet b/package/base-files/default/etc/init.d/S50telnet
new file mode 100755
index 0000000000..228eac2b62
--- /dev/null
+++ b/package/base-files/default/etc/init.d/S50telnet
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start() {
+ if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
+}
+
+stop() {
+ killall telnetd
+}
diff --git a/package/base-files/default/etc/init.d/S60cron b/package/base-files/default/etc/init.d/S60cron
new file mode 100755
index 0000000000..a450c36dd2
--- /dev/null
+++ b/package/base-files/default/etc/init.d/S60cron
@@ -0,0 +1,12 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start () {
+ mkdir -p /var/spool/cron
+ ln -s /etc/crontabs /var/spool/cron/crontabs
+ crond -c /etc/crontabs
+}
+
+stop() {
+ killall crond
+}
diff --git a/package/base-files/default/etc/init.d/rcS b/package/base-files/default/etc/init.d/rcS
new file mode 100755
index 0000000000..7fae7f5b05
--- /dev/null
+++ b/package/base-files/default/etc/init.d/rcS
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+${FAILSAFE:+exit}
+
+# FIXME: add logging configuration
+#[ -f /etc/config/network ] && . /etc/config/network
+#eval $(ipcalc "$log_ipaddr")
+#[ "$log_ipaddr" = "$IP" ] || log_ipaddr=""
+syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr}
+klogd
+
+(
+ for i in /etc/init.d/S*; do
+ $i start 2>&1
+ done
+
+ sysctl -p >&-
+
+ # automagically run firstboot
+ { mount|grep "on / type tmpfs" 1>&-; } && {
+ lock /tmp/.switch2jffs
+ firstboot switch2jffs
+ lock -u /tmp/.switch2jffs
+ }
+) | logger -s -p 6 -t '' &
diff --git a/package/base-files/default/etc/inittab b/package/base-files/default/etc/inittab
new file mode 100644
index 0000000000..39e134cb16
--- /dev/null
+++ b/package/base-files/default/etc/inittab
@@ -0,0 +1,3 @@
+::sysinit:/etc/init.d/rcS
+tts/0::askfirst:/bin/ash --login
+#tts/1::askfirst:/bin/ash --login
diff --git a/package/base-files/default/etc/ipkg.conf b/package/base-files/default/etc/ipkg.conf
new file mode 100644
index 0000000000..2931d2cf80
--- /dev/null
+++ b/package/base-files/default/etc/ipkg.conf
@@ -0,0 +1,3 @@
+src snapshots http://openwrt.org/downloads/snapshots/$S/packages
+dest root /
+dest ram /tmp
diff --git a/package/base-files/default/etc/nvram.sh b/package/base-files/default/etc/nvram.sh
new file mode 100644
index 0000000000..ddbd88b52f
--- /dev/null
+++ b/package/base-files/default/etc/nvram.sh
@@ -0,0 +1,19 @@
+#!/bin/ash
+# Copyright (C) 2006 OpenWrt.org
+
+
+# allow env to override nvram
+nvram () {
+ if [ -x /usr/sbin/nvram ]; then
+ case $1 in
+ get) eval "echo \${$2:-\$(/usr/sbin/nvram get $2)}";;
+ *) /usr/sbin/nvram $*;;
+ esac
+ else
+ case $1 in
+ get) eval "echo \${$2:-\${DEFAULT_$2}}";;
+ *);;
+ esac
+ fi
+}
+
diff --git a/package/base-files/default/etc/passwd b/package/base-files/default/etc/passwd
new file mode 100644
index 0000000000..3b660a0d4e
--- /dev/null
+++ b/package/base-files/default/etc/passwd
@@ -0,0 +1,2 @@
+root:!:0:0:root:/tmp:/bin/ash
+nobody:*:65534:65534:nobody:/var:/bin/false
diff --git a/package/base-files/default/etc/profile b/package/base-files/default/etc/profile
new file mode 100644
index 0000000000..ae514b0924
--- /dev/null
+++ b/package/base-files/default/etc/profile
@@ -0,0 +1,12 @@
+#!/bin/sh
+[ -f /etc/banner ] && cat /etc/banner
+
+export PATH=/bin:/sbin:/usr/bin:/usr/sbin
+export PS1='\u@\h:\w\$ '
+
+alias more=less
+[ -x /usr/bin/vim ] || alias vim=vi
+
+arp() { cat /proc/net/arp; }
+ldd() { LD_TRACE_LOADED_OBJECTS=1 $*; }
+reboot() { ifdown wan 2>&1 >/dev/null ; /sbin/reboot; }
diff --git a/package/base-files/default/etc/protocols b/package/base-files/default/etc/protocols
new file mode 100644
index 0000000000..53fecb6d3c
--- /dev/null
+++ b/package/base-files/default/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/default/etc/rc.common b/package/base-files/default/etc/rc.common
new file mode 100755
index 0000000000..20d1efa402
--- /dev/null
+++ b/package/base-files/default/etc/rc.common
@@ -0,0 +1,73 @@
+#!/bin/sh
+. /etc/functions.sh
+
+start() {
+ return 0
+}
+
+stop() {
+ return 0
+}
+
+reload() {
+ return 1
+}
+
+restart() {
+ stop
+ start
+}
+
+boot() {
+ start
+}
+
+shutdown() {
+ return 0
+}
+
+disable() {
+ rm -f /etc/rc.d/${initscript##*/}
+}
+
+enable() {
+ disable
+ ln -s /etc/init.d/${initscript##*/} /etc/rc.d/${initscript##*/}
+}
+
+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)
+$EXTRA_HELP
+EOF
+}
+
+initscript="$1"
+action="$2"
+
+. "$initscript"
+
+cmds=
+for cmd in $EXTRA_COMMANDS; do
+ cmds="$cmd) $cmd;;"
+done
+eval "case \"\$action\" in
+ start) start;;
+ stop) stop;;
+ reload) reload || restart;;
+ restart) restart;;
+ boot) boot;;
+ shutdown) shutdown;;
+ $cmds
+ *) help;;
+esac"
diff --git a/package/base-files/default/etc/resolv.conf b/package/base-files/default/etc/resolv.conf
new file mode 100644
index 0000000000..9617eacda7
--- /dev/null
+++ b/package/base-files/default/etc/resolv.conf
@@ -0,0 +1,2 @@
+nameserver 127.0.0.1
+search lan
diff --git a/package/base-files/default/etc/shells b/package/base-files/default/etc/shells
new file mode 100644
index 0000000000..006aa38ced
--- /dev/null
+++ b/package/base-files/default/etc/shells
@@ -0,0 +1 @@
+/bin/ash
diff --git a/package/base-files/default/etc/sysctl.conf b/package/base-files/default/etc/sysctl.conf
new file mode 100644
index 0000000000..e60038cf35
--- /dev/null
+++ b/package/base-files/default/etc/sysctl.conf
@@ -0,0 +1,12 @@
+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_fin_timeout=30
+net.ipv4.tcp_keepalive_time=120
+net.ipv4.tcp_syncookies=1
+net.ipv4.tcp_timestamps=0
+net.ipv4.ip_conntrack_tcp_timeouts="300 43200 120 60 120 120 10 60 30 120"
+net.ipv4.ip_conntrack_udp_timeouts="60 180"
diff --git a/package/base-files/default/lib/config/uci-update.awk b/package/base-files/default/lib/config/uci-update.awk
new file mode 100644
index 0000000000..efa8758507
--- /dev/null
+++ b/package/base-files/default/lib/config/uci-update.awk
@@ -0,0 +1,160 @@
+# Configuration update functions
+#
+# Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraunhofer.de>
+# Copyright (C) 2006 by Felix Fietkau <nbd@openwrt.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+function read_file(filename, result) {
+ while ((getline <filename) == 1) {
+ result = result $0 "\n"
+ }
+ gsub(/\n*$/, "", result)
+ return result
+}
+
+function cmd2option(str, tmp) {
+ if (match(str,"=")!=0) {
+ res = "\toption " substr(str,1,RSTART-1) "\t'" substr(str,RSTART+1) "'"
+ } else {
+ res= ""
+ }
+ return res
+}
+
+function cmd2config(atype, aname) {
+ return "config \"" atype "\" \"" aname "\""
+}
+
+function update_config(cfg, update, \
+ lines, line, l, n, i, i2, section, scnt, remove, tmp, aidx, rest) {
+ scnt = 1
+ linecnt=split(cfg "\n", lines, "\n")
+
+ cfg = ""
+ for (n = 1; n < linecnt; n++) {
+ # stupid parser for quoted arguments (e.g. for the type string).
+ # not to be used to gather variable values (backslash escaping doesn't work)
+ line = lines[n]
+ gsub(/^[ \t]*/, "", line)
+ gsub(/#.*$/, "", line)
+ i2 = 1
+ delete l
+ rest = line
+ while (length(rest)) {
+ if (match(rest, /[ \t\"]+/)) {
+ if (RSTART>1) {
+ l[i2] = substr(rest,1,RSTART-1)
+ i2++
+ }
+ aidx=index(rest,"\"")
+ if (aidx>=RSTART && aidx<=RSTART+RLENGTH) {
+ rest=substr(rest,aidx+1)
+ # find the end of the string
+ match(rest,/\"/)
+ l[i2]=substr(rest,1,RSTART-1)
+ i2++
+ }
+ rest=substr(rest,RSTART+RLENGTH)
+ } else {
+ l[i2] = rest
+ i2++
+ rest = ""
+ }
+ }
+ line = lines[n]
+
+ # when a command wants to set a config value for the current
+ # section and a blank line is encountered before an option with
+ # the same name, insert it here to maintain some coherency between
+ # manually and automatically created option lines
+ # if an option with the same name appears after this point, simply
+ # ignore it, because it is already set.
+ if ((section != "") && (l[1] != "option")) {
+ if (line ~ /^[ \t]*$/) {
+ if (update ~ "^" section "\\.") {
+ gsub("^" section ".", "", update)
+ cfg = cfg cmd2option(update) "\n"
+ gsub(/=.*$/, "", update)
+ update = "-" section "." update
+ }
+ }
+ }
+
+ if (l[1] == "config") {
+ # look for all unset values
+ if (section != "") {
+ flag=0
+ if (update ~ "^" section "\\.") {
+ flag=1
+ gsub("^" section ".", "", update)
+ cfg = cfg cmd2option(update) "\n"
+
+ update = "-" section "." update
+ }
+ if (flag!=0) cfg = cfg "\n"
+ }
+
+ remove = ""
+ section = l[3]
+ if (!length(section)) {
+ section = "cfg" scnt
+ }
+ scnt++
+ if (update == "-" section) {
+ remove = "section"
+ update = ""
+ } else if (update ~ "^@" section "=") {
+ update = ""
+ } else if (update ~ "^&" section "=") {
+ gsub("^&" section "=", "", update)
+ line = cmd2config(l[2],update)
+ update = ""
+ }
+ }
+ if (remove == "option") remove = ""
+ if (l[1] == "option") {
+ if (update ~ "^-" section "\\." l[2] "$") remove = "option"
+ # if a supplied config value already exists, replace the whole line
+ if (match(update, "^" section "." l[2] "=")) {
+ gsub("^" section ".", "", update)
+ line = cmd2option(update)
+ update = ""
+ }
+ }
+ if (remove == "") cfg = cfg line "\n"
+ }
+
+ # any new options for the last section??
+ if (section != "") {
+ if (update ~ "^" section "\\.") {
+ gsub("^" section ".", "", update)
+ cfg = cfg cmd2option(update) "\n"
+
+ update = "-" section "." update
+ }
+ }
+
+ if (update ~ "^@") {
+ # new section
+ section = stype = substr(update,2)
+ gsub(/=.*$/,"",section)
+ gsub(/^.*=/,"",stype)
+ cfg = cfg "\nconfig \"" stype "\" \"" section "\"\n"
+ }
+
+ return cfg
+}
diff --git a/package/base-files/default/lib/config/uci.sh b/package/base-files/default/lib/config/uci.sh
new file mode 100755
index 0000000000..ccd6ee57ba
--- /dev/null
+++ b/package/base-files/default/lib/config/uci.sh
@@ -0,0 +1,138 @@
+#!/bin/sh
+# Shell script defining macros for manipulating config files
+#
+# Copyright (C) 2006 by Fokus Fraunhofer <carsten.tittel@fokus.fraumhofer.de>
+# Copyright (C) 2006 by Felix Fietkau <nbd@openwrt.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+uci_load() {
+ config_load "$PACKAGE"
+ local PACKAGE_BASE="$(basename "$PACKAGE")"
+ [ -f "/tmp/.uci/${PACKAGE_BASE}" ] && {
+ . "/tmp/.uci/${PACKAGE_BASE}"
+ config_cb
+ }
+}
+
+uci_do_update() {
+ local FILENAME="$1"
+ local UPDATE="$2"
+ awk -f /lib/config/uci-update.awk -f - <<EOF
+BEGIN {
+ config = read_file("$FILENAME")
+ $UPDATE
+ print config
+}
+EOF
+}
+
+uci_add_update() {
+ local PACKAGE="$1"
+ local UPDATE="$2"
+ local PACKAGE_BASE="$(basename "$PACKAGE")"
+
+ # FIXME: add locking?
+ mkdir -p "/tmp/.uci"
+ echo "$UPDATE" >> "/tmp/.uci/${PACKAGE_BASE}"
+}
+
+uci_set() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+ local VALUE="$4"
+
+ ( # spawn a subshell so you don't mess up the current environment
+ uci_load "$PACKAGE"
+ config_get type "$CONFIG" TYPE
+ [ -z "$type" ]
+ ) || uci_add_update "$PACKAGE" "CONFIG_SECTION='$CONFIG'${N}option '$OPTION' '$VALUE'"
+}
+
+uci_add() {
+ local PACKAGE="$1"
+ local TYPE="$2"
+ local CONFIG="$3"
+
+ uci_add_update "$PACKAGE" "config '$TYPE' '$CONFIG'"
+}
+
+uci_rename() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local VALUE="$3"
+
+ uci_add_update "$PACKAGE" "config_rename '$CONFIG' '$VALUE'"
+}
+
+uci_remove() {
+ local PACKAGE="$1"
+ local CONFIG="$2"
+ local OPTION="$3"
+
+ if [ -z "$OPTION" ]; then
+ uci_add_update "$PACKAGE" "config_clear '$CONFIG'"
+ else
+ uci_add_update "$PACKAGE" "config_unset '$CONFIG' '$OPTION'"
+ fi
+}
+
+uci_commit() {
+ local PACKAGE="$1"
+ local PACKAGE_BASE="$(basename "$PACKAGE")"
+
+ mkdir -p /tmp/.uci
+ lock "/tmp/.uci/$PACKAGE_BASE.lock"
+ [ -f "/tmp/.uci/$PACKAGE_BASE" ] && (
+ updatestr=""
+
+ # replace handlers
+ config() {
+ append updatestr "config = update_config(config, \"@$2=$1\")" "$N"
+ }
+ option() {
+ append updatestr "config = update_config(config, \"$CONFIG_SECTION.$1=$2\")" "$N"
+ }
+ config_rename() {
+ append updatestr "config = update_config(config, \"&$1=$2\")" "$N"
+ }
+ config_unset() {
+ append updatestr "config = update_config(config, \"-$1.$2\")" "$N"
+ }
+ config_clear() {
+ append updatestr "config = update_config(config, \"-$1\")" "$N"
+ }
+
+ . "/tmp/.uci/$PACKAGE_BASE"
+
+ # completely disable handlers so that they don't get in the way
+ config() {
+ return 0
+ }
+ option() {
+ return 0
+ }
+
+ config_load "$PACKAGE" || CONFIG_FILENAME="$ROOT/etc/config/$PACKAGE_BASE"
+ uci_do_update "$CONFIG_FILENAME" "$updatestr" > "/tmp/.uci/$PACKAGE_BASE.new" && {
+ mv -f "/tmp/.uci/$PACKAGE_BASE.new" "$CONFIG_FILENAME" && \
+ rm -f "/tmp/.uci/$PACKAGE_BASE"
+ }
+ )
+ lock -u "/tmp/.uci/$PACKAGE_BASE.lock"
+}
+
+
diff --git a/package/base-files/default/lib/network/config.sh b/package/base-files/default/lib/network/config.sh
new file mode 100755
index 0000000000..18f794a31b
--- /dev/null
+++ b/package/base-files/default/lib/network/config.sh
@@ -0,0 +1,143 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+# DEBUG="echo"
+
+find_config() {
+ local iftype device iface ifaces ifn
+ for ifn in $interfaces; do
+ config_get iftype "$ifn" type
+ config_get iface "$ifn" ifname
+ case "$iftype" in
+ bridge) config_get ifaces "$ifn" ifnames;;
+ esac
+ config_get device "$ifn" device
+ for ifc in $device $iface $ifaces; do
+ [ "$ifc" = "$1" ] && {
+ echo "$ifn"
+ return 0
+ }
+ done
+ done
+
+ return 1;
+}
+
+scan_interfaces() {
+ local mode iftype iface ifname device
+ interfaces=
+ config_cb() {
+ config_get iftype "$CONFIG_SECTION" TYPE
+ case "$iftype" in
+ interface)
+ config_get proto "$CONFIG_SECTION" proto
+ append interfaces "$CONFIG_SECTION"
+ config_get iftype "$CONFIG_SECTION" type
+ config_get ifname "$CONFIG_SECTION" ifname
+ config_set "$CONFIG_SECTION" device "$ifname"
+ case "$iftype" in
+ bridge)
+ config_set "$CONFIG_SECTION" ifnames "$ifname"
+ config_set "$CONFIG_SECTION" ifname br-"$CONFIG_SECTION"
+ ;;
+ esac
+ ( type "scan_$proto" ) >/dev/null 2>/dev/null && eval "scan_$proto '$CONFIG_SECTION'"
+ ;;
+ esac
+ }
+ config_load network
+}
+
+add_vlan() {
+ local vif="${1%\.*}"
+
+ [ "$1" = "$vif" ] || ifconfig "$1" >/dev/null 2>/dev/null || {
+ ifconfig "$vif" up 2>/dev/null >/dev/null || add_vlan "$vif"
+ $DEBUG vconfig add "$vif" "${1##*\.}"
+ }
+}
+
+setup_interface() {
+ local iface="$1"
+ local config="$2"
+ local proto
+
+ [ -n "$config" ] || {
+ config=$(find_config "$iface")
+ [ "$?" = 0 ] || return 1
+ }
+
+ proto="${3:-$(config_get "$config" proto)}"
+ config_get iftype "$config" type
+
+ # Setup VLAN interfaces
+ add_vlan "$iface"
+
+ # Setup bridging
+ case "$iftype" in
+ bridge)
+ ifconfig "$iface" up 2>/dev/null >/dev/null
+ ifconfig "br-$config" 2>/dev/null >/dev/null && {
+ $DEBUG brctl addif "br-$config" "$iface"
+ return 0
+ } || {
+ $DEBUG brctl addbr "br-$config"
+ $DEBUG brctl setfd "br-$config" 0
+ $DEBUG brctl addif "br-$config" "$iface"
+ iface="br-$config"
+ }
+ ;;
+ esac
+
+ # Interface settings
+ config_get mtu "$config" mtu
+ $DEBUG ifconfig "$iface" ${mtu:+mtu $mtu} up
+
+ pidfile="/var/run/$iface.pid"
+ case "$proto" in
+ static)
+ config_get ipaddr "$config" ipaddr
+ config_get netmask "$config" netmask
+ [ -z "$ipaddr" -o -z "$netmask" ] && return 1
+
+ config_get ip6addr "$config" ip6addr
+ config_get gateway "$config" gateway
+ config_get dns "$config" dns
+
+ $DEBUG ifconfig "$iface" "$ipaddr" netmask "$netmask"
+ [ -z "$gateway" ] || route add default gw "$gateway"
+ [ -z "$dns" -o -f /tmp/resolv.conf ] || {
+ for ns in $dns; do
+ echo "nameserver $ns" >> /tmp/resolv.conf
+ done
+ }
+
+ env -i ACTION="ifup" INTERFACE="config" DEVICE="$iface" PROTO=static /sbin/hotplug "iface" &
+ ;;
+ dhcp)
+ pid="$(cat "$pidfile" 2>/dev/null)"
+ [ -n "$pid" -a -d "/proc/$pid" ] && kill -9 "$pid"
+
+ config_get ipaddr "$config" ipaddr
+ config_get netmask "$config" netmask
+ config_get hostname "$config" hostname
+ config_get proto1 "$config" proto
+
+ [ -z "$ipaddr" ] || \
+ $DEBUG ifconfig "$iface" "$ipaddr" ${netmask:+netmask "$netmask"}
+
+ # don't stay running in background if dhcp is not the main proto on the interface (e.g. when using pptp)
+ [ "$proto1" != "$proto" ] && dhcpopts="-n -q"
+ $DEBUG udhcpc -i "$iface" ${ipaddr:+-r $ipaddr} ${hostname:+-H $hostname} -b -p "$pidfile" ${dhcpopts:- -R &}
+ ;;
+ *)
+ if ( eval "type setup_interface_$proto" ) >/dev/null 2>/dev/null; then
+ eval "setup_interface_$proto '$iface' '$config' '$proto'"
+ else
+ echo "Interface type $proto not supported."
+ return 1
+ fi
+ ;;
+ esac
+}
+
diff --git a/package/base-files/default/rom/note b/package/base-files/default/rom/note
new file mode 100644
index 0000000000..1746eb0509
--- /dev/null
+++ b/package/base-files/default/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/default/sbin/hotplug b/package/base-files/default/sbin/hotplug
new file mode 100755
index 0000000000..b1b6f97b23
--- /dev/null
+++ b/package/base-files/default/sbin/hotplug
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+# bypass the normal hotplug path for firmware loading
+# would otherwise cause problems with drivers like bcm43xx
+[ "$1" = "firmware" -a "$ACTION" = "add" ] && {
+ [ -f "/lib/firmware/$FIRMWARE" ] && {
+ echo 1 > "/sys$DEVPATH/loading"
+ cp "/lib/firmware/$FIRMWARE" "/sys$DEVPATH/data"
+ echo 0 > "/sys$DEVPATH/loading"
+ }
+ exit 0
+}
+
+. /etc/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/default/sbin/ifdown b/package/base-files/default/sbin/ifdown
new file mode 100755
index 0000000000..073e80d2da
--- /dev/null
+++ b/package/base-files/default/sbin/ifdown
@@ -0,0 +1,34 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+[ $# = 0 ] && { echo " $0 <group>"; exit; }
+. /etc/functions.sh
+include /lib/network
+scan_interfaces
+
+cfg=$1
+debug "### ifdown $cfg ###"
+
+config_get proto "$cfg" proto
+[ -z "$proto" ] && { echo "interface not found."; exit; }
+
+# kill active ppp daemon
+pid="$(cat /var/run/ppp-${cfg}.pid 2>/dev/null)"
+[ -n "$pid" -a -d "/proc/$pid" ] && {
+ kill $pid
+ sleep 1
+ [ -d "/proc/$pid" ] && kill -9 $pid
+}
+
+# kill any other process associated with the interface
+config_get ifname "$cfg" ifname
+pid="$(cat /var/run/${ifname}.pid 2>/dev/null)"
+[ -n "$pid" -a -d "/proc/$pid" ] && kill -9 $pid
+
+config_get ifname "$cfg" ifname
+ifconfig "$ifname" >/dev/null 2>/dev/null && {
+ ifconfig "$ifname" 0.0.0.0 down
+
+ config_get iftype "$cfg" type
+ [ "$iftype" = "bridge" ] && brctl delbr "$ifname"
+}
diff --git a/package/base-files/default/sbin/ifup b/package/base-files/default/sbin/ifup
new file mode 100755
index 0000000000..c7055d4807
--- /dev/null
+++ b/package/base-files/default/sbin/ifup
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+. /sbin/ifdown "$@"
+
+config_get iftype "$1" type
+case "$iftype" in
+ bridge) config_get ifname "$1" ifnames;;
+ *) config_get ifname "$1" ifname;;
+esac
+
+for dev in $ifname; do
+ setup_interface "$dev" "$1"
+done
diff --git a/package/base-files/default/sbin/mount_root b/package/base-files/default/sbin/mount_root
new file mode 100755
index 0000000000..81660f0067
--- /dev/null
+++ b/package/base-files/default/sbin/mount_root
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+mount none /proc -t proc
+size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
+mount none /tmp -t tmpfs -o size=$size,nosuid,nodev,mode=1777
+mkdir -p /dev/pts
+mount none /dev/pts -t devpts
+mount -t sysfs none /sys 2>&-
+mount -o remount,rw /dev/root /
diff --git a/package/base-files/default/sbin/wifi b/package/base-files/default/sbin/wifi
new file mode 100755
index 0000000000..4a3ec8cfef
--- /dev/null
+++ b/package/base-files/default/sbin/wifi
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright (C) 2006 OpenWrt.org
+
+. /etc/functions.sh
+
+config_get_bool() {
+ local _tmp
+ config_get "$1" "$2" "$3"
+ eval "_tmp=\$$1"
+ case "$_tmp" in
+ 1|on|enabled) eval "$1=1";;
+ 0|off|disabled) eval "$1=0";;
+ *) eval "$1=${4:-0}";;
+ esac
+}
+
+config_cb() {
+ config_get TYPE "$CONFIG_SECTION" TYPE
+ case "$TYPE" in
+ wifi-device)
+ append DEVICES "$CONFIG_SECTION"
+ ;;
+ 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 wireless
+include /lib/wifi
+
+for device in $DEVICES; do (
+ config_get iftype "$device" type
+ eval "type setup_$iftype" 2>/dev/null >/dev/null && {
+ eval "scan_$iftype '$device'"
+ eval "setup_$iftype '$device'" && {
+ # TODO: set up network settings
+ /bin/true
+ } || echo "$device($iftype): Setup failed" || true
+ } || echo "$device($iftype): Interface type not supported"
+); done
diff --git a/package/base-files/default/usr/lib/common.awk b/package/base-files/default/usr/lib/common.awk
new file mode 100644
index 0000000000..c5ce680fa6
--- /dev/null
+++ b/package/base-files/default/usr/lib/common.awk
@@ -0,0 +1,68 @@
+# Copyright (C) 2006 OpenWrt.org
+
+function portstr(type, str) {
+ gsub(/-/, ":", str)
+ if (insmod_mport != 1) {
+ print "insmod ipt_multiport >&- 2>&-"
+ insmod_mport = 1
+ }
+ if (type == "src") return " -m multiport --sports " str
+ else return " -m multiport --dports " str
+}
+
+function str2ipt(str) {
+ str2data(str)
+ _cmd = ""
+ if (_l["src"] != "") _cmd = _cmd " -s " _l["src"]
+ if (_l["dest"] != "") _cmd = _cmd " -d " _l["dest"]
+ if (_l["proto"] != "") {
+ _cmd = _cmd " -p " _l["proto"]
+ }
+ # scripts need to check for proto="" and emit two rules in that case
+ if ((_l["proto"] == "") || (_l["proto"] == "tcp") || (_l["proto"] == "udp")) {
+ if (_l["sport"] != "") _cmd = _cmd portstr("src", _l["sport"])
+ if (_l["dport"] != "") _cmd = _cmd portstr("dest", _l["dport"])
+ }
+ if (_l["layer7"] != "") {
+ if (insmod_l7 != 1) {
+ print "insmod ipt_layer7 >&- 2>&-"
+ insmod_l7 = 1
+ }
+ _cmd = _cmd " -m layer7 --l7proto " _l["layer7"]
+ }
+ return _cmd
+}
+
+function str2data(str) {
+ delete _l
+ _n = split(str, _o, "[\t ]")
+ for (_i = 1; _i <= _n; _i++) {
+ _n2 = split(_o[_i], _c, "=")
+ if (_n2 == 2) _l[_c[1]] = _c[2]
+ }
+}
+
+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 validate_netmask(nm) {
+ return and(-nm,compl(nm))
+}
+
+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
+}
diff --git a/package/base-files/default/usr/lib/parse-config.awk b/package/base-files/default/usr/lib/parse-config.awk
new file mode 100644
index 0000000000..9ce32b74ff
--- /dev/null
+++ b/package/base-files/default/usr/lib/parse-config.awk
@@ -0,0 +1,42 @@
+# Copyright (C) 2006 OpenWrt.org
+
+{
+ line=$0
+ gsub(/^[ \t]*/, "")
+ gsub(/[ \t]*$/, "")
+}
+
+$1 == "@define" {
+ v[$2] = $3
+}
+
+$1 == "@ifdef" {
+ if_open = 1
+ if (v[$2] != "") noprint = 0
+ else noprint = 1
+}
+
+$1 == "@ifndef" {
+ if_open = 1
+ if (v[$2] != "") noprint = 1
+ else noprint = 0
+}
+
+$1 == "@else" {
+ if (noprint == 1) noprint = 0
+ else noprint = 1
+}
+
+($1 !~ /^@[a-zA-Z]/) && (noprint != 1) {
+ n=split(line "@@", a, /@@/)
+ for (i=1; i<=n; i++) {
+ if ((i % 2) == 1) printf a[i]
+ else printf v[a[i]]
+ }
+ print ""
+}
+
+$1 == "@endif" {
+ if_open = 0
+ noprint = 0
+}
diff --git a/package/base-files/default/usr/share/udhcpc/default.script b/package/base-files/default/usr/share/udhcpc/default.script
new file mode 100755
index 0000000000..74e703715b
--- /dev/null
+++ b/package/base-files/default/usr/share/udhcpc/default.script
@@ -0,0 +1,57 @@
+#!/bin/sh
+[ -z "$1" ] && echo "Error: should be run by udhcpc" && exit 1
+. /etc/functions.sh
+include /lib/network
+
+RESOLV_CONF="/tmp/resolv.conf"
+
+hotplug_event() {
+ scan_interfaces
+ for ifc in $interfaces; do
+ config_get ifname $ifc ifname
+ [ "$ifname" = "$interface" ] || continue
+
+ config_get proto $ifc proto
+ [ "$proto" = "dhcp" ] || continue
+
+ env -i ACTION="$1" INTERFACE="$ifname" PROTO=dhcp /sbin/hotplug iface
+ done
+}
+
+case "$1" in
+ deconfig)
+ ifconfig $interface 0.0.0.0
+ hotplug_event ifdown
+ ;;
+ renew|bound)
+ ifconfig $interface $ip \
+ netmask ${subnet:-255.255.255.0} \
+ broadcast ${broadcast:-+}
+
+ if [ -n "$router" ] ; then
+ echo "deleting routers"
+ while route del default gw 0.0.0.0 dev $interface >&- 2>&- ; do :; done
+
+ for i in $router ; do
+ echo "adding router $i"
+ route add default gw $i dev $interface
+ done
+ fi
+
+ [ -n "$dns" ] && {
+ echo -n > $RESOLV_CONF
+ ${domain:+echo search $domain} >> $RESOLV_CONF
+ for i in $dns ; do
+ echo "adding dns $i"
+ echo "nameserver $i" >> $RESOLV_CONF
+ done
+ }
+
+ hotplug_event ifup
+
+ # user rules
+ [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user
+ ;;
+esac
+
+exit 0