ambari-server 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. #!/usr/bin/env bash
  2. # chkconfig: 345 95 20
  3. # description: ambari-server daemon
  4. # processname: ambari-server
  5. # Licensed to the Apache Software Foundation (ASF) under one
  6. # or more contributor license agreements. See the NOTICE file
  7. # distributed with this work for additional information
  8. # regarding copyright ownership. The ASF licenses this file
  9. # to you under the Apache License, Version 2.0 (the
  10. # "License"); you may not use this file except in compliance
  11. # with the License. You may obtain a copy of the License at
  12. #
  13. # http://www.apache.org/licenses/LICENSE-2.0
  14. #
  15. # Unless required by applicable law or agreed to in writing, software
  16. # distributed under the License is distributed on an "AS IS" BASIS,
  17. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  18. # See the License for the specific language governing permissions and
  19. # limitations under the License.
  20. # /etc/init.d/ambari-server
  21. VERSION="${ambariVersion}"
  22. HASH="${buildNumber}"
  23. case "$1" in
  24. --version)
  25. echo -e $VERSION
  26. exit 0
  27. ;;
  28. --hash)
  29. echo -e $HASH
  30. exit 0
  31. ;;
  32. esac
  33. export PATH=/usr/lib/ambari-server/*:$PATH
  34. export AMBARI_CONF_DIR=/etc/ambari-server/conf:$PATH
  35. # Because Ambari rpm unpacks modules here on all systems
  36. export PYTHONPATH=/usr/lib/python2.6/site-packages:$PYTHONPATH
  37. if [ -a /usr/bin/python2.6 ]; then
  38. PYTHON=/usr/bin/python2.6
  39. fi
  40. if [ -a /var/lib/ambari-server/ambari-env.sh ]; then
  41. . /var/lib/ambari-server/ambari-env.sh
  42. fi
  43. if [ -z "$PYTHON" ]; then
  44. PYTHON=/usr/bin/python
  45. fi
  46. if [ -z "$AMBARI_PASSPHRASE" ]; then
  47. AMBARI_PASSPHRASE="DEV"
  48. fi
  49. if [ -n "$JAVA_HOME" ]; then
  50. export JAVA_HOME=$JAVA_HOME
  51. fi
  52. export AMBARI_PASSPHRASE=$AMBARI_PASSPHRASE
  53. # check for version
  54. majversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f1`
  55. minversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f2`
  56. numversion=$(( 10 * $majversion + $minversion))
  57. if (( $numversion < 26 )); then
  58. echo "Need python version > 2.6"
  59. exit 1
  60. fi
  61. echo "Using python " $PYTHON
  62. case "$1" in
  63. start)
  64. echo -e "Starting ambari-server"
  65. $PYTHON /usr/sbin/ambari-server.py $@
  66. ;;
  67. stop)
  68. echo -e "Stopping ambari-server"
  69. $PYTHON /usr/sbin/ambari-server.py $@
  70. ;;
  71. reset)
  72. echo -e "Resetting ambari-server"
  73. $PYTHON /usr/sbin/ambari-server.py $@
  74. ;;
  75. restart)
  76. echo -e "Restarting ambari-server"
  77. $0 stop
  78. $0 start
  79. ;;
  80. upgrade)
  81. echo -e "Upgrading ambari-server"
  82. $PYTHON /usr/sbin/ambari-server.py $@
  83. ;;
  84. status)
  85. echo -e "Ambari-server status"
  86. $PYTHON /usr/sbin/ambari-server.py $@
  87. ;;
  88. upgradestack)
  89. echo -e "Upgrading stack of ambari-server"
  90. $PYTHON /usr/sbin/ambari-server.py $@
  91. ;;
  92. setup)
  93. echo -e "Setup ambari-server"
  94. $PYTHON /usr/sbin/ambari-server.py $@
  95. ;;
  96. setup-ldap)
  97. echo -e "Setting up LDAP properties..."
  98. $PYTHON /usr/sbin/ambari-server.py $@
  99. ;;
  100. setup-security)
  101. echo -e "Security setup options..."
  102. $PYTHON /usr/sbin/ambari-server.py $@
  103. ;;
  104. *)
  105. echo "Usage: /usr/sbin/ambari-server
  106. {start|stop|restart|setup|upgrade|status|upgradestack|setup-ldap|setup-security} [options]
  107. Use usr/sbin/ambari-server <action> --help to get details on options available.
  108. Or, simply invoke ambari-server.py --help to print the options."
  109. exit 1
  110. esac
  111. exit 0