aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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'