ambari-server 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. ### BEGIN INIT INFO
  21. # Provides: ambari-server
  22. # Required-Start:
  23. # Required-Stop:
  24. # Default-Start: 2 3 4 5
  25. # Default-Stop: 0 6
  26. ### END INIT INFO
  27. # /etc/init.d/ambari-server
  28. VERSION="${ambariFullVersion}"
  29. HASH="${buildNumber}"
  30. case "$1" in
  31. --version)
  32. echo -e $VERSION
  33. exit 0
  34. ;;
  35. --hash)
  36. echo -e $HASH
  37. exit 0
  38. ;;
  39. esac
  40. SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  41. export ROOT=`dirname $(dirname $SCRIPT_DIR)`
  42. ROOT=`echo $ROOT | sed 's/\/$//'`
  43. export PATH=$ROOT/usr/lib/ambari-server/*:$PATH:/sbin/:/usr/sbin
  44. export AMBARI_CONF_DIR=$ROOT/etc/ambari-server/conf
  45. PYTHON_WRAP="$ROOT/usr/bin/ambari-python-wrap"
  46. AMBARI_ENV="$ROOT/var/lib/ambari-server/ambari-env.sh"
  47. AMBARI_PYTHON_EXECUTABLE="$ROOT/usr/sbin/ambari-server.py"
  48. AMBARI_EXECUTABLE="$ROOT/usr/sbin/ambari-server"
  49. if [ -z "$PYTHON" ] ; then
  50. export PYTHON=`readlink $PYTHON_WRAP`
  51. fi
  52. if [ -a "$AMBARI_ENV" ]; then
  53. . "$AMBARI_ENV"
  54. fi
  55. if [ -z "$AMBARI_PASSPHRASE" ]; then
  56. AMBARI_PASSPHRASE="DEV"
  57. fi
  58. if [ -n "$JAVA_HOME" ]; then
  59. export JAVA_HOME=$JAVA_HOME
  60. fi
  61. export AMBARI_PASSPHRASE=$AMBARI_PASSPHRASE
  62. # check for version
  63. majversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f1`
  64. minversion=`$PYTHON -V 2>&1 | awk '{print $2}' | cut -d'.' -f2`
  65. numversion=$(( 10 * $majversion + $minversion))
  66. if (( $numversion < 26 )); then
  67. echo "Need python version > 2.6"
  68. exit 1
  69. fi
  70. echo "Using python " $PYTHON
  71. ret=0
  72. case "$1" in
  73. start)
  74. echo -e "Starting ambari-server"
  75. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  76. ;;
  77. stop)
  78. echo -e "Stopping ambari-server"
  79. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  80. ;;
  81. reset)
  82. echo -e "Resetting ambari-server"
  83. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  84. ;;
  85. restart)
  86. echo -e "Restarting ambari-server"
  87. $0 stop
  88. $0 start
  89. ;;
  90. upgrade)
  91. echo -e "Upgrading ambari-server"
  92. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  93. ;;
  94. status)
  95. echo -e "Ambari-server status"
  96. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  97. ;;
  98. upgradestack)
  99. echo -e "Upgrading stack of ambari-server"
  100. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  101. ;;
  102. setup)
  103. echo -e "Setup ambari-server"
  104. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  105. ;;
  106. setup-jce)
  107. echo -e "Updating jce policy"
  108. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  109. ;;
  110. setup-ldap)
  111. echo -e "Setting up LDAP properties..."
  112. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  113. ;;
  114. sync-ldap)
  115. echo -e "Syncing with LDAP..."
  116. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  117. ;;
  118. set-current)
  119. echo -e "Setting current version..."
  120. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  121. ;;
  122. setup-security)
  123. echo -e "Security setup options..."
  124. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  125. ;;
  126. refresh-stack-hash)
  127. echo -e "Refreshing stack hashes..."
  128. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  129. ;;
  130. backup)
  131. echo -e "Backing up Ambari File System state... *this will not backup the server database*"
  132. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  133. ;;
  134. restore)
  135. echo -e "Restoring Ambari File System state"
  136. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  137. ;;
  138. update-host-names)
  139. echo -e "Updating host names"
  140. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  141. ;;
  142. check-database)
  143. echo -e "Checking database"
  144. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  145. ;;
  146. enable-stack)
  147. echo -e "Enabling stack(s)..."
  148. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  149. ;;
  150. setup-sso)
  151. echo -e "Setting up SSO authentication properties..."
  152. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  153. ;;
  154. db-cleanup)
  155. echo -e "Cleanup database..."
  156. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  157. ;;
  158. install-mpack)
  159. echo -e "Installing management pack"
  160. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  161. ;;
  162. upgrade-mpack)
  163. echo -e "Upgrading management pack"
  164. $PYTHON "$AMBARI_PYTHON_EXECUTABLE" $@
  165. ;;
  166. *)
  167. echo "Usage: $AMBARI_PYTHON_EXECUTABLE
  168. {start|stop|restart|setup|setup-jce|upgrade|status|upgradestack|setup-ldap|sync-ldap|set-current|setup-security|setup-sso|refresh-stack-hash|backup|restore|update-host-names|enable-stack|check-database|db-cleanup} [options]
  169. Use $AMBARI_PYTHON_EXECUTABLE <action> --help to get details on options available.
  170. Or, simply invoke ambari-server.py --help to print the options."
  171. exit 1
  172. esac
  173. exit $?