hadoop_env_checks.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/usr/bin/env bash
  2. # Licensed to the Apache Software Foundation (ASF) under one
  3. # or more contributor license agreements. See the NOTICE file
  4. # distributed with this work for additional information
  5. # regarding copyright ownership. The ASF licenses this file
  6. # to you under the Apache License, Version 2.0 (the
  7. # "License"); you may not use this file except in compliance
  8. # with the License. You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # SHELLDOC-IGNORE
  18. # -------------------------------------------------------
  19. function showWelcome {
  20. cat <<Welcome-message
  21. _ _ _ ______
  22. | | | | | | | _ \\
  23. | |_| | __ _ __| | ___ ___ _ __ | | | |_____ __
  24. | _ |/ _\` |/ _\` |/ _ \\ / _ \\| '_ \\ | | | / _ \\ \\ / /
  25. | | | | (_| | (_| | (_) | (_) | |_) | | |/ / __/\\ V /
  26. \\_| |_/\\__,_|\\__,_|\\___/ \\___/| .__/ |___/ \\___| \\_(_)
  27. | |
  28. |_|
  29. This is the standard Hadoop Developer build environment.
  30. This has all the right tools installed required to build
  31. Hadoop from source.
  32. Welcome-message
  33. }
  34. # -------------------------------------------------------
  35. function showAbort {
  36. cat <<Abort-message
  37. ___ _ _ _
  38. / _ \\| | | | (_)
  39. / /_\\ \\ |__ ___ _ __| |_ _ _ __ __ _
  40. | _ | '_ \\ / _ \\| '__| __| | '_ \\ / _\` |
  41. | | | | |_) | (_) | | | |_| | | | | (_| |
  42. \\_| |_/_.__/ \\___/|_| \\__|_|_| |_|\\__, |
  43. __/ |
  44. |___/
  45. Abort-message
  46. }
  47. # -------------------------------------------------------
  48. function failIfUserIsRoot {
  49. if [ "$(id -u)" -eq "0" ]; # If you are root then something went wrong.
  50. then
  51. cat <<End-of-message
  52. Apparently you are inside this docker container as the user root.
  53. Putting it simply:
  54. This should not occur.
  55. Known possible causes of this are:
  56. 1) Running this script as the root user ( Just don't )
  57. 2) Running an old docker version ( upgrade to 1.4.1 or higher )
  58. End-of-message
  59. showAbort
  60. logout
  61. fi
  62. }
  63. # -------------------------------------------------------
  64. function warnIfLowMemory {
  65. MINIMAL_MEMORY=2046755
  66. INSTALLED_MEMORY=$(grep -F MemTotal /proc/meminfo | awk '{print $2}')
  67. if [[ $((INSTALLED_MEMORY)) -lt $((MINIMAL_MEMORY)) ]]; then
  68. cat <<End-of-message
  69. _ ___ ___
  70. | | | \\/ |
  71. | | _____ __ | . . | ___ _ __ ___ ___ _ __ _ _
  72. | | / _ \\ \\ /\\ / / | |\\/| |/ _ \\ '_ \` _ \\ / _ \\| '__| | | |
  73. | |___| (_) \\ V V / | | | | __/ | | | | | (_) | | | |_| |
  74. \\_____/\\___/ \\_/\\_/ \\_| |_/\\___|_| |_| |_|\\___/|_| \\__, |
  75. __/ |
  76. |___/
  77. Your system is running on very little memory.
  78. This means it may work but it wil most likely be slower than needed.
  79. If you are running this via boot2docker you can simply increase
  80. the available memory to at least ${MINIMAL_MEMORY}KiB
  81. (you have ${INSTALLED_MEMORY}KiB )
  82. End-of-message
  83. fi
  84. }
  85. # -------------------------------------------------------
  86. showWelcome
  87. warnIfLowMemory
  88. failIfUserIsRoot
  89. # -------------------------------------------------------