install-helper.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information rega4rding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. #########################################postinstall.sh#########################
  16. # SERVER INSTALL HELPER #
  17. ##################################################################
  18. COMMON_DIR="/usr/lib/python2.6/site-packages/ambari_commons"
  19. RESOURCE_MANAGEMENT_DIR="/usr/lib/python2.6/site-packages/resource_management"
  20. JINJA_DIR="/usr/lib/python2.6/site-packages/ambari_jinja2"
  21. OLD_COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
  22. INSTALL_HELPER_AGENT="/var/lib/ambari-agent/install-helper.sh"
  23. COMMON_DIR_SERVER="/usr/lib/ambari-server/lib/ambari_commons"
  24. RESOURCE_MANAGEMENT_DIR_SERVER="/usr/lib/ambari-server/lib/resource_management"
  25. JINJA_SERVER_DIR="/usr/lib/ambari-server/lib/ambari_jinja2"
  26. PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
  27. PYTHON_WRAPER_SOURCE="/var/lib/ambari-server/ambari-python-wrap"
  28. do_install(){
  29. # setting ambari_commons shared resource
  30. rm -rf "$OLD_COMMON_DIR"
  31. if [ ! -d "$COMMON_DIR" ]; then
  32. ln -s "$COMMON_DIR_SERVER" "$COMMON_DIR"
  33. fi
  34. # setting resource_management shared resource
  35. if [ ! -d "$RESOURCE_MANAGEMENT_DIR" ]; then
  36. ln -s "$RESOURCE_MANAGEMENT_DIR_SERVER" "$RESOURCE_MANAGEMENT_DIR"
  37. fi
  38. # setting jinja2 shared resource
  39. if [ ! -d "$JINJA_DIR" ]; then
  40. ln -s "$JINJA_SERVER_DIR" "$JINJA_DIR"
  41. fi
  42. # setting python-wrapper script
  43. if [ ! -f "$PYTHON_WRAPER_TARGET" ]; then
  44. ln -s "$PYTHON_WRAPER_SOURCE" "$PYTHON_WRAPER_TARGET"
  45. fi
  46. }
  47. do_remove(){
  48. if [ -f "$PYTHON_WRAPER_TARGET" ]; then
  49. rm -f "$PYTHON_WRAPER_TARGET"
  50. fi
  51. # if server package exists, restore their settings
  52. if [ -f "$INSTALL_HELPER_AGENT" ]; then # call agent shared files installer
  53. $INSTALL_HELPER_AGENT install
  54. fi
  55. }
  56. do_upgrade(){
  57. do_install
  58. }
  59. case "$1" in
  60. install)
  61. do_install
  62. ;;
  63. remove)
  64. do_remove
  65. ;;
  66. upgrade)
  67. do_upgrade
  68. ;;
  69. esac