1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-11-27 15:54:04 +02:00

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
This commit is contained in:
juhosg 2012-05-29 16:39:16 +00:00
parent 3a3aa7378b
commit 5e8d1213bc

View File

@ -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'