uboot-envtools: filogic: reorder alphabetically
[openwrt/staging/hauke.git] / package / boot / uboot-envtools / files / uboot-envtools.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2011-2012 OpenWrt.org
4 #
5
6 _ubootenv_add_uci_config() {
7 local cfgtype=$1
8 local dev=$2
9 local offset=$3
10 local envsize=$4
11 local secsize=$5
12 local numsec=$6
13 uci batch <<EOF
14 add ubootenv $cfgtype
15 set ubootenv.@$cfgtype[-1].dev='$dev'
16 set ubootenv.@$cfgtype[-1].offset='$offset'
17 set ubootenv.@$cfgtype[-1].envsize='$envsize'
18 set ubootenv.@$cfgtype[-1].secsize='$secsize'
19 set ubootenv.@$cfgtype[-1].numsec='$numsec'
20 EOF
21 uci commit ubootenv
22 }
23
24 ubootenv_add_uci_config() {
25 _ubootenv_add_uci_config "ubootenv" "$@"
26 }
27
28 ubootenv_add_uci_sys_config() {
29 _ubootenv_add_uci_config "ubootsys" "$@"
30 }
31
32 ubootenv_add_app_config() {
33 local cfgtype
34 local dev
35 local offset
36 local envsize
37 local secsize
38 local numsec
39 config_get cfgtype "$1" TYPE
40 config_get dev "$1" dev
41 config_get offset "$1" offset
42 config_get envsize "$1" envsize
43 config_get secsize "$1" secsize
44 config_get numsec "$1" numsec
45 grep -q "^[[:space:]]*${dev}[[:space:]]*${offset}" "/etc/fw_${cfgtype#uboot}.config" || echo "$dev $offset $envsize $secsize $numsec" >>"/etc/fw_${cfgtype#uboot}.config"
46 }