install-helper.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. OLD_COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
  21. INSTALL_HELPER_AGENT="/var/lib/ambari-agent/install-helper.sh"
  22. COMMON_DIR_SERVER="/usr/lib/ambari-server/lib/ambari_commons"
  23. RESOURCE_MANAGEMENT_DIR_SERVER="/usr/lib/ambari-server/lib/resource_management"
  24. PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
  25. PYTHON_WRAPER_SOURCE="/var/lib/ambari-server/ambari-python-wrap"
  26. do_install(){
  27. # setting ambari_commons shared resource
  28. rm -rf "$OLD_COMMON_DIR"
  29. if [ ! -d "$COMMON_DIR" ]; then
  30. ln -s "$COMMON_DIR_SERVER" "$COMMON_DIR"
  31. fi
  32. # remove RESOURCE_MANAGEMENT_DIR if it's a directory
  33. if [ -d "$RESOURCE_MANAGEMENT_DIR" ]; then # resource_management dir exists
  34. if [ ! -L "$RESOURCE_MANAGEMENT_DIR" ]; then # resource_management dir is not link
  35. rm -rf "$RESOURCE_MANAGEMENT_DIR"
  36. fi
  37. fi
  38. # setting resource_management shared resource
  39. if [ ! -d "$RESOURCE_MANAGEMENT_DIR" ]; then
  40. ln -s "$RESOURCE_MANAGEMENT_DIR_SERVER" "$RESOURCE_MANAGEMENT_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. rm -rf "$COMMON_DIR"
  49. rm -rf "$RESOURCE_MANAGEMENT_DIR"
  50. if [ -f "$PYTHON_WRAPER_TARGET" ]; then
  51. rm -f "$PYTHON_WRAPER_TARGET"
  52. fi
  53. # if server package exists, restore their settings
  54. if [ -f "$INSTALL_HELPER_AGENT" ]; then # call agent shared files installer
  55. $INSTALL_HELPER_AGENT install
  56. fi
  57. }
  58. do_upgrade(){
  59. do_install
  60. }
  61. case "$1" in
  62. install)
  63. do_install
  64. ;;
  65. remove)
  66. do_remove
  67. ;;
  68. upgrade)
  69. do_upgrade
  70. ;;
  71. esac