ambari-server 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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:/sbin/:/usr/sbin
  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.7 ] && [ -z "$PYTHON" ]; then
  38. PYTHON=/usr/bin/python2.7
  39. fi
  40. if [ -a /usr/bin/python2.6 ] && [ -z "$PYTHON" ]; then
  41. PYTHON=/usr/bin/python2.6
  42. fi
  43. if [ -a /var/lib/ambari-server/ambari-env.sh ]; then
  44. . /var/lib/ambari-server/ambari-env.sh
  45. fi
  46. if [ -z "$PYTHON" ]; then
  47. PYTHON=/usr/bin/python
  48. fi
  49. if [ -z "$AMBARI_PASSPHRASE" ]; then
  50. AMBARI_PASSPHRASE="DEV"
  51. fi
  52. if [ -n "$JAVA_HOME" ]; then
  53. export JAVA_HOME=$JAVA_HOME
  54. fi
  55. export AMBARI_PASSPHRASE=$AMBARI_PASSPHRASE
  56. # check for version
  57. majversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f1`
  58. minversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f2`
  59. numversion=$(( 10 * $majversion + $minversion))
  60. if (( $numversion < 26 )); then
  61. echo "Need python version > 2.6"
  62. exit 1
  63. fi
  64. echo "Using python " $PYTHON
  65. case "$1" in
  66. start)
  67. echo -e "Starting ambari-server"
  68. $PYTHON /usr/sbin/ambari-server.py $@
  69. ;;
  70. stop)
  71. echo -e "Stopping ambari-server"
  72. $PYTHON /usr/sbin/ambari-server.py $@
  73. ;;
  74. reset)
  75. echo -e "Resetting ambari-server"
  76. $PYTHON /usr/sbin/ambari-server.py $@
  77. ;;
  78. restart)
  79. echo -e "Restarting ambari-server"
  80. $0 stop
  81. $0 start
  82. ;;
  83. upgrade)
  84. echo -e "Upgrading ambari-server"
  85. $PYTHON /usr/sbin/ambari-server.py $@
  86. ;;
  87. status)
  88. echo -e "Ambari-server status"
  89. $PYTHON /usr/sbin/ambari-server.py $@
  90. ;;
  91. upgradestack)
  92. echo -e "Upgrading stack of ambari-server"
  93. $PYTHON /usr/sbin/ambari-server.py $@
  94. ;;
  95. setup)
  96. echo -e "Setup ambari-server"
  97. $PYTHON /usr/sbin/ambari-server.py $@
  98. ;;
  99. setup-ldap)
  100. echo -e "Setting up LDAP properties..."
  101. $PYTHON /usr/sbin/ambari-server.py $@
  102. ;;
  103. sync-ldap)
  104. echo -e "Syncing with LDAP..."
  105. $PYTHON /usr/sbin/ambari-server.py $@
  106. ;;
  107. setup-security)
  108. echo -e "Security setup options..."
  109. $PYTHON /usr/sbin/ambari-server.py $@
  110. ;;
  111. refresh-stack-hash)
  112. echo -e "Refreshing stack hashes..."
  113. $PYTHON /usr/sbin/ambari-server.py $@
  114. ;;
  115. backup)
  116. echo -e "Backing up Ambari File System state... *this will not backup the server database*"
  117. $PYTHON /usr/sbin/ambari-server.py $@
  118. ;;
  119. restore)
  120. echo -e "Restoring Ambari File System state"
  121. $PYTHON /usr/sbin/ambari-server.py $@
  122. ;;
  123. *)
  124. echo "Usage: /usr/sbin/ambari-server
  125. {start|stop|restart|setup|upgrade|status|upgradestack|setup-ldap|sync-ldap|setup-security|refresh-stack-hash|backup|restore} [options]
  126. Use usr/sbin/ambari-server <action> --help to get details on options available.
  127. Or, simply invoke ambari-server.py --help to print the options."
  128. exit 1
  129. esac
  130. exit 0