diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-05-29 16:39:16 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-05-29 16:39:16 +0000 |
commit | 5e8d1213bcf575a39d80c65b1598cf9335a94c0d (patch) | |
tree | ea08beb2f74da428f0f81ccb83e1b2f8c1c27ba6 /package/base-files/files/lib | |
parent | 3a3aa7378b980fcd2ef7c1284d52ec4fe510aacb (diff) |
base-files: add LED specific functions to /lib/functions/uci-defaults
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@31991 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files/lib')
-rw-r--r-- | package/base-files/files/lib/functions/uci-defaults.sh | 98 |
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' |