diff options
author | Gabor Juhos <juhosg@openwrt.org> | 2012-05-29 16:39:15 +0000 |
---|---|---|
committer | Gabor Juhos <juhosg@openwrt.org> | 2012-05-29 16:39:15 +0000 |
commit | ba3ad2451426b5a9db9294ed8ebedc7757c2c6e0 (patch) | |
tree | b05a4c827c6326d9240c1a8888f18c49c00aff5f /target/linux/kirkwood/base-files/etc | |
parent | c71838faa1dc9ade9918abbc61b587ff35880a53 (diff) | |
download | upstream-ba3ad2451426b5a9db9294ed8ebedc7757c2c6e0.tar.gz upstream-ba3ad2451426b5a9db9294ed8ebedc7757c2c6e0.tar.bz2 upstream-ba3ad2451426b5a9db9294ed8ebedc7757c2c6e0.zip |
kirkwood: use uci-defaults to configure different boards
Signed-off-by: Luka Perkov <openwrt@lukaperkov.net>
SVN-Revision: 31990
Diffstat (limited to 'target/linux/kirkwood/base-files/etc')
-rw-r--r-- | target/linux/kirkwood/base-files/etc/uci-defaults/leds | 57 | ||||
-rw-r--r-- | target/linux/kirkwood/base-files/etc/uci-defaults/network | 42 |
2 files changed, 99 insertions, 0 deletions
diff --git a/target/linux/kirkwood/base-files/etc/uci-defaults/leds b/target/linux/kirkwood/base-files/etc/uci-defaults/leds new file mode 100644 index 0000000000..a0b1c1c1fa --- /dev/null +++ b/target/linux/kirkwood/base-files/etc/uci-defaults/leds @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Copyright (C) 2012 OpenWrt.org +# + +COMMIT_SYSTEM=0 + +set_led_netdev() { + local cfg="led_$1" + local sysfs=$2 + local dev=$3 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='netdev' +set system.$cfg.dev='$dev' +set system.$cfg.mode='link tx rx' +EOF + COMMIT_SYSTEM=1 +} + +set_led_default() { + local cfg="led_$1" + local sysfs=$2 + local default=$3 + + uci -q get system.$cfg && return 0 + + uci batch <<EOF +set system.$cfg='led' +set system.$cfg.sysfs='$sysfs' +set system.$cfg.trigger='none' +set system.$cfg.default='$default' +EOF + COMMIT_SYSTEM=1 +} + +. /lib/kirkwood.sh + +hardware=$(kirkwood_hardware_name) + +case "$hardware" in +"Seagate FreeAgent DockStar") + set_led_netdev "eth0" "dockstar:orange:misc" "eth0" + set_led_default "health" "dockstar:green:health" "1" + ;; + +*) + ;; +esac + +[ "$COMMIT_SYSTEM" == "1" ] && uci commit system + +exit 0 diff --git a/target/linux/kirkwood/base-files/etc/uci-defaults/network b/target/linux/kirkwood/base-files/etc/uci-defaults/network new file mode 100644 index 0000000000..48c1232d3d --- /dev/null +++ b/target/linux/kirkwood/base-files/etc/uci-defaults/network @@ -0,0 +1,42 @@ +#!/bin/sh +# +# Copyright (C) 2012 OpenWrt.org +# + +[ -e /etc/config/network ] && exit 0 + +set_lan_dhcp() { + local ifname=$1 + uci batch <<EOF +set network.lan='interface' +set network.lan.ifname='$ifname' +set network.lan.proto='dhcp' +EOF +} + +. /lib/functions/uci-defaults.sh +. /lib/kirkwood.sh + +touch /etc/config/network + +ucidef_set_interface_loopback + +hardware=$(kirkwood_hardware_name) + +case "$hardware" in +"Seagate FreeAgent DockStar") + set_lan_dhcp "eth0" + ;; + +"RaidSonic ICY BOX IB-NAS6210") + set_lan_dhcp "eth0" + ;; + +*) + ucidef_set_interface_lan "eth0" + ;; +esac + +uci commit network + +exit 0 |