install-helper.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. ##################################################################
  16. # AGENT 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_SERVER="/var/lib/ambari-server/install-helper.sh"
  22. COMMON_DIR_AGENT="/usr/lib/ambari-agent/lib/ambari_commons"
  23. RESOURCE_MANAGEMENT_DIR_AGENT="/usr/lib/ambari-agent/lib/resource_management"
  24. PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
  25. PYTHON_WRAPER_SOURCE="/var/lib/ambari-agent/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_AGENT" "$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_AGENT" "$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. if [ -d "$COMMON_DIR" ]; then # common dir exists
  49. rm -f "$COMMON_DIR"
  50. fi
  51. if [ -d "$RESOURCE_MANAGEMENT_DIR" ]; then # resource_management dir exists
  52. rm -f "$RESOURCE_MANAGEMENT_DIR"
  53. fi
  54. if [ -f "$PYTHON_WRAPER_TARGET" ]; then
  55. rm -f "$PYTHON_WRAPER_TARGET"
  56. fi
  57. # if server package exists, restore their settings
  58. if [ -f "$INSTALL_HELPER_SERVER" ]; then # call server shared files installer
  59. $INSTALL_HELPER_SERVER install
  60. fi
  61. }
  62. do_upgrade(){
  63. do_install
  64. }
  65. case "$1" in
  66. install)
  67. do_install
  68. ;;
  69. remove)
  70. do_remove
  71. ;;
  72. upgrade)
  73. do_upgrade
  74. ;;
  75. esac