aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/functions
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2012-05-29 16:39:16 +0000
committerGabor Juhos <juhosg@openwrt.org>2012-05-29 16:39:16 +0000
commiteca7502dfd869518512ed172955512370e7a9d49 (patch)
tree9ece1e423ecc338a19f40b9d422fc80795856f0d /package/base-files/files/lib/functions
parentba3ad2451426b5a9db9294ed8ebedc7757c2c6e0 (diff)
downloadupstream-eca7502dfd869518512ed172955512370e7a9d49.tar.gz
upstream-eca7502dfd869518512ed172955512370e7a9d49.tar.bz2
upstream-eca7502dfd869518512ed172955512370e7a9d49.zip
base-files: add LED specific functions to /lib/functions/uci-defaults
SVN-Revision: 31991
Diffstat (limited to 'package/base-files/files/lib/functions')
-rw-r--r--package/base-files/files/lib/functions/uci-defaults.sh98
1 files changed, 98 insertions, 0 deletions
diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index a1371e5e3b..2cbf69a6ff 100644
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -1,6 +1,104 @@
#!/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_commit_leds()
+{
+ [ "$UCIDEF_LEDS_CHANGED" == "1" ] && uci commit system
+}
+
ucidef_set_interface_loopback() {
uci batch <<EOF
set network.loopback='interface'