starter.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env bash
  2. ##
  3. # Licensed to the Apache Software Foundation (ASF) under one
  4. # or more contributor license agreements. See the NOTICE file
  5. # distributed with this work for additional information
  6. # regarding copyright ownership. The ASF licenses this file
  7. # to you under the Apache License, Version 2.0 (the
  8. # "License"); you may not use this file except in compliance
  9. # with the License. You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. ##
  19. set -e
  20. #To avoid docker volume permission problems
  21. sudo chmod o+rwx /data
  22. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  23. $DIR/envtoconf.py --destination /opt/hadoop/etc/hadoop
  24. if [ -n "$SLEEP_SECONDS" ]; then
  25. echo "Sleeping for $SLEEP_SECONDS seconds"
  26. sleep $SLEEP_SECONDS
  27. fi
  28. if [ -n "$ENSURE_NAMENODE_DIR" ]; then
  29. CLUSTERID_OPTS=""
  30. if [ -n "$ENSURE_NAMENODE_CLUSTERID" ]; then
  31. CLUSTERID_OPTS="-clusterid $ENSURE_NAMENODE_CLUSTERID"
  32. fi
  33. if [ ! -d "$ENSURE_NAMENODE_DIR" ]; then
  34. /opt/hadoop/bin/hdfs namenode -format -force $CLUSTERID_OPTS
  35. fi
  36. fi
  37. if [ -n "$ENSURE_STANDBY_NAMENODE_DIR" ]; then
  38. if [ ! -d "$ENSURE_STANDBY_NAMENODE_DIR" ]; then
  39. /opt/hadoop/bin/hdfs namenode -bootstrapStandby
  40. fi
  41. fi
  42. if [ -n "$ENSURE_SCM_INITIALIZED" ]; then
  43. if [ ! -f "$ENSURE_SCM_INITIALIZED" ]; then
  44. /opt/hadoop/bin/ozone scm -init
  45. fi
  46. fi
  47. if [ -n "$ENSURE_OM_INITIALIZED" ]; then
  48. if [ ! -f "$ENSURE_OM_INITIALIZED" ]; then
  49. # To make sure SCM is running in dockerized environment we will sleep
  50. # Could be removed after HDFS-13203
  51. echo "Waiting 15 seconds for SCM startup"
  52. sleep 15
  53. /opt/hadoop/bin/ozone om -createObjectStore
  54. fi
  55. fi
  56. # The KSM initialization block will go away eventually once
  57. # we have completed renaming KSM to OzoneManager (OM).
  58. #
  59. if [ -n "$ENSURE_KSM_INITIALIZED" ]; then
  60. if [ ! -f "$ENSURE_KSM_INITIALIZED" ]; then
  61. # To make sure SCM is running in dockerized environment we will sleep
  62. # Could be removed after HDFS-13203
  63. echo "Waiting 15 seconds for SCM startup"
  64. sleep 15
  65. /opt/hadoop/bin/ozone ksm -createObjectStore
  66. fi
  67. fi
  68. $@