install-helper.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. OLD_COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
  20. INSTALL_HELPER_AGENT="/var/lib/ambari-agent/install-helper.sh"
  21. COMMON_DIR_SERVER="/usr/lib/ambari-server/lib/ambari_commons"
  22. PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
  23. PYTHON_WRAPER_SOURCE="/var/lib/ambari-server/ambari-python-wrap"
  24. do_install(){
  25. # setting ambari_commons shared resource
  26. rm -rf "$OLD_COMMON_DIR"
  27. if [ ! -d "$COMMON_DIR" ]; then
  28. ln -s "$COMMON_DIR_AGENT" "$COMMON_DIR"
  29. fi
  30. # setting python-wrapper script
  31. if [ ! -f "$PYTHON_WRAPER_TARGET" ]; then
  32. ln -s "$PYTHON_WRAPER_SOURCE" "$PYTHON_WRAPER_TARGET"
  33. fi
  34. }
  35. do_remove(){
  36. rm -rf "$COMMON_DIR"
  37. if [ -f "$PYTHON_WRAPER_TARGET" ]; then
  38. rm -f "$PYTHON_WRAPER_TARGET"
  39. fi
  40. # if server package exists, restore their settings
  41. if [ -f "$INSTALL_HELPER_AGENT" ]; then # call agent shared files installer
  42. $INSTALL_HELPER_AGENT install
  43. fi
  44. }
  45. do_upgrade(){
  46. do_install
  47. }
  48. case "$1" in
  49. install)
  50. do_install
  51. ;;
  52. remove)
  53. do_remove
  54. ;;
  55. upgrade)
  56. do_upgrade
  57. ;;
  58. esac