diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-05-29 16:39:16 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-05-29 16:39:16 +0000 |
commit | 932f2f9811322e2121e283e090381da023aec543 (patch) | |
tree | ea08beb2f74da428f0f81ccb83e1b2f8c1c27ba6 /package/base-files | |
parent | 1fe95ce50be6a3c6d53ecf08e6f87376539740d3 (diff) | |
download | upstream-932f2f9811322e2121e283e090381da023aec543.tar.gz upstream-932f2f9811322e2121e283e090381da023aec543.tar.bz2 upstream-932f2f9811322e2121e283e090381da023aec543.zip |
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')
-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' |