uboot-envtools.sh 1.1 KB

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