environment.sh 2.6 KB

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