oxnas.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2013 OpenWrt.org
  4. #
  5. OXNAS_BOARD_NAME=
  6. OXNAS_MODEL=
  7. bootloader_cmdline_var() {
  8. local param
  9. local pval
  10. for arg in $(cat /proc/device-tree/chosen/bootloader-args); do
  11. param="$(echo $arg | cut -d'=' -f 1)"
  12. pval="$(echo $arg | cut -d'=' -f 2-)"
  13. if [ "$param" = "$1" ]; then
  14. echo "$pval"
  15. fi
  16. done
  17. }
  18. legacy_boot_mac_adr() {
  19. local macstr
  20. local oIFS
  21. macstr="$(bootloader_cmdline_var mac_adr)"
  22. oIFS="$IFS"
  23. IFS=","
  24. set -- $macstr
  25. printf "%02x:%02x:%02x:%02x:%02x:%02x" $1 $2 $3 $4 $5 $6
  26. IFS="$oIFS"
  27. }
  28. oxnas_board_detect() {
  29. local machine
  30. local name
  31. machine=$(cat /proc/device-tree/model)
  32. case "$machine" in
  33. *"Akitio MyCloud mini"*)
  34. name="akitio"
  35. ;;
  36. *"MitraStar Technology Corp. STG-212"*)
  37. name="stg212"
  38. ;;
  39. *"Shuttle KD20"*)
  40. name="kd20"
  41. ;;
  42. *"Pogoplug Pro"*)
  43. name="pogoplug-pro"
  44. ;;
  45. *"Pogoplug V3"*)
  46. name="pogoplug-v3"
  47. ;;
  48. esac
  49. [ -z "$name" ] && name="unknown"
  50. [ -z "$OXNAS_BOARD_NAME" ] && OXNAS_BOARD_NAME="$name"
  51. [ -z "$OXNAS_MODEL" ] && OXNAS_MODEL="$machine"
  52. [ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
  53. echo "$OXNAS_BOARD_NAME" > /tmp/sysinfo/board_name
  54. echo "$OXNAS_MODEL" > /tmp/sysinfo/model
  55. }
  56. oxnas_board_name() {
  57. local name
  58. [ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
  59. [ -z "$name" ] && name="unknown"
  60. echo "$name"
  61. }