summaryrefslogtreecommitdiff
path: root/package/base-files/default/sbin
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/sbin
parentd58a09110ccfa95f06c983fe796806f2e035c9d2 (diff)
parentb3ce218b51746d3a576221ea542facf3a1703ab2 (diff)
downloadmtk-20170518-60c1f0f64d23003a19a07d6b9638542130f6641d.zip
mtk-20170518-60c1f0f64d23003a19a07d6b9638542130f6641d.tar.gz
mtk-20170518-60c1f0f64d23003a19a07d6b9638542130f6641d.tar.bz2
finally move buildroot-ng to trunk
Diffstat (limited to 'package/base-files/default/sbin')
-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
5 files changed, 128 insertions, 0 deletions
diff --git a/package/base-files/default/sbin/hotplug b/package/base-files/default/sbin/hotplug
new file mode 100755
index 0000000..b1b6f97
--- /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 0000000..073e80d
--- /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 0000000..c7055d4
--- /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 0000000..81660f0
--- /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 0000000..4a3ec8c
--- /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