hadoop-config.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # included in all the hadoop scripts with source command
  2. # should not be executable directly
  3. # also should not be passed any arguments, since we need original $*
  4. # resolve links - $0 may be a softlink
  5. this="$0"
  6. while [ -h "$this" ]; do
  7. ls=`ls -ld "$this"`
  8. link=`expr "$ls" : '.*-> \(.*\)$'`
  9. if expr "$link" : '.*/.*' > /dev/null; then
  10. this="$link"
  11. else
  12. this=`dirname "$this"`/"$link"
  13. fi
  14. done
  15. # convert relative path to absolute path
  16. bin=`dirname "$this"`
  17. script=`basename "$this"`
  18. bin=`cd "$bin"; pwd`
  19. this="$bin/$script"
  20. # the root of the Hadoop installation
  21. export HADOOP_HOME=`dirname "$this"`/..
  22. #check to see if the conf dir is given as an optional argument
  23. if [ $# -gt 1 ]
  24. then
  25. if [ "--config" = "$1" ]
  26. then
  27. shift
  28. confdir=$1
  29. shift
  30. HADOOP_CONF_DIR=$confdir
  31. fi
  32. fi
  33. # Allow alternate conf dir location.
  34. HADOOP_CONF_DIR="${HADOOP_CONF_DIR:-$HADOOP_HOME/conf}"
  35. #check to see it is specified whether to use the slaves or the
  36. # masters file
  37. if [ $# -gt 1 ]
  38. then
  39. if [ "--hosts" = "$1" ]
  40. then
  41. shift
  42. slavesfile=$1
  43. shift
  44. export HADOOP_SLAVES="${HADOOP_CONF_DIR}/$slavesfile"
  45. fi
  46. fi