lantiq.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/bin/sh
  2. lantiq_board_detect() {
  3. name=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/\(.*\) - .*/\1/g"`
  4. model=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/.* - \(.*\)/\1/g"`
  5. [ -z "$name" ] && name="unknown"
  6. [ -z "$model" ] && model="unknown"
  7. [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
  8. echo $name > /tmp/sysinfo/board_name
  9. echo $model > /tmp/sysinfo/model
  10. }
  11. lantiq_board_model() {
  12. local model
  13. [ -f /tmp/sysinfo/model ] && model=$(cat /tmp/sysinfo/model)
  14. [ -z "$model" ] && model="unknown"
  15. echo "$model"
  16. }
  17. lantiq_board_name() {
  18. local name
  19. [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
  20. [ -z "$name" ] && name="unknown"
  21. echo "$name"
  22. }
  23. lantiq_is_dt_led_chosen() {
  24. [ -f "/sys/firmware/devicetree/base/chosen/leds/$1" ] && echo "true"
  25. }
  26. lantiq_get_dt_led_chosen() {
  27. local label
  28. local nodepath
  29. local basepath="/sys/firmware/devicetree/base"
  30. local chosenpath="$basepath/chosen/leds/$1"
  31. [ -f "$chosenpath" ] && nodepath=$(cat "$chosenpath")
  32. [ -n "$nodepath" ] && label=$(cat "$basepath$nodepath/label")
  33. echo "$label"
  34. }