environment.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/bin/sh
  2. #operating system details
  3. os_name=$(lsb_release -is)
  4. os_codename=$(lsb_release -cs)
  5. os_mode='unknown'
  6. #cpu details
  7. cpu_name=$(uname -m)
  8. cpu_architecture='unknown'
  9. cpu_mode='unknown'
  10. #check what the CPU and OS are
  11. if [ .$cpu_name = .'armv7l' ]; then
  12. # RaspberryPi 3 is actually armv8l but current Raspbian reports the cpu as armv7l and no Raspbian 64Bit has been released at this time
  13. os_mode='32'
  14. cpu_mode='32'
  15. cpu_architecture='arm'
  16. elif [ .$cpu_name = .'armv8l' ]; then
  17. # No test case for armv8l
  18. os_mode='unknown'
  19. cpu_mode='64'
  20. cpu_architecture='arm'
  21. elif [ .$cpu_name = .'i386' ]; then
  22. os_mode='32'
  23. if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then
  24. cpu_mode='64'
  25. else
  26. cpu_mode='32'
  27. fi
  28. cpu_architecture='x86'
  29. elif [ .$cpu_name = .'i686' ]; then
  30. os_mode='32'
  31. if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then
  32. cpu_mode='64'
  33. else
  34. cpu_mode='32'
  35. fi
  36. cpu_architecture='x86'
  37. elif [ .$cpu_name = .'x86_64' ]; then
  38. os_mode='64'
  39. if [ .$(grep -o -w 'lm' /proc/cpuinfo | head -n 1) = .'lm' ]; then
  40. cpu_mode='64'
  41. else
  42. cpu_mode='32'
  43. fi
  44. cpu_architecture='x86'
  45. else
  46. error "You are using an unsupported cpu '$cpu_name'"
  47. exit 3
  48. fi
  49. if [ .$cpu_architecture = .'arm' ]; then
  50. if [ .$os_mode = .'32' ]; then
  51. verbose "Correct CPU and Operating System detected, using the ARM repo"
  52. elif [ .$os_mode = .'64' ]; then
  53. error "You are using a 64bit arm OS this is unsupported"
  54. switch_source=true
  55. switch_package=false
  56. else
  57. error "Unknown OS mode $os_mode this is unsupported"
  58. switch_source=true
  59. switch_package=false
  60. fi
  61. elif [ .$cpu_architecture = .'x86' ]; then
  62. if [ .$os_mode = .'32' ]; then
  63. error "You are using a 32bit OS this is unsupported"
  64. if [ .$cpu_mode = .'64' ]; then
  65. warning " Your CPU is 64bit you should consider reinstalling with a 64bit OS"
  66. fi
  67. switch_source=true
  68. switch_package=false
  69. elif [ .$os_mode = .'64' ]; then
  70. verbose "Correct CPU and Operating System detected"
  71. else
  72. error "Unknown Operating System mode '$os_mode' is unsupported"
  73. switch_source=true
  74. switch_package=false
  75. fi
  76. else
  77. error "You are using an unsupported architecture '$cpu_architecture'"
  78. warning "Detected environment was :-"
  79. warning "os_name:'$os_name'"
  80. warning "os_codename:'$os_codename'"
  81. warning "os_mode:'$os_mode'"
  82. warning "cpu_name:'$cpu_name'"
  83. exit 3
  84. fi