environment.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. #operating system details
  3. os_name=$(uname -s)
  4. os_version=$(uname -r)
  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. # We currently have 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)" = '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)" = '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)" = 'lm' ]; then
  40. os_mode='64'
  41. else
  42. os_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. error "CentOS on arm is not supported at this time"
  51. exit 3
  52. elif [ .$cpu_architecture = .'x86' ]; then
  53. if [ .$os_mode = .'32' ]; then
  54. error "You are using a 32bit OS this is unsupported"
  55. if [ .$cpu_mode = .'64' ]; then
  56. warning " Your CPU is 64bit you should consider reinstalling with a 64bit OS"
  57. fi
  58. exit 3
  59. elif [ .$os_mode = .'64' ]; then
  60. verbose "Correct CPU and Operating System detected"
  61. else
  62. error "Unknown Operating System mode '$os_mode' is unsupported"
  63. warning "Detected environment was :-"
  64. warning "os_name:'$os_name'"
  65. warning "os_mode:'$os_mode'"
  66. warning "cpu_name:'$cpu_name'"
  67. warning "cpu_architecture:'$cpu_architecture'"
  68. exit 3
  69. fi
  70. else
  71. error "You are using an unsupported architecture '$cpu_architecture'"
  72. warning "Detected environment was :-"
  73. warning "os_name:'$os_name'"
  74. warning "os_mode:'$os_mode'"
  75. warning "cpu_name:'$cpu_name'"
  76. exit 3
  77. fi