install-helper.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. # SERVER INSTALL HELPER #
  17. ##################################################################
  18. COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
  19. INSTALL_HELPER_AGENT="/var/lib/ambari-agent/install-helper.sh"
  20. COMMON_DIR_SERVER="/usr/lib/ambari-server/lib/common_functions"
  21. PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
  22. PYTHON_WRAPER_SOURCE="/var/lib/ambari-server/ambari-python-wrap"
  23. do_install(){
  24. # setting common_functions shared resource
  25. if [ ! -d "$COMMON_DIR" ]; then
  26. ln -s "$COMMON_DIR_SERVER" "$COMMON_DIR"
  27. fi
  28. # setting python-wrapper script
  29. if [ ! -f "$PYTHON_WRAPER_TARGET" ]; then
  30. ln -s "$PYTHON_WRAPER_SOURCE" "$PYTHON_WRAPER_TARGET"
  31. fi
  32. }
  33. do_remove(){
  34. if [ -d "$COMMON_DIR" ]; then # common dir exists
  35. rm -f "$COMMON_DIR"
  36. fi
  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. case "$1" in
  46. install)
  47. do_install
  48. ;;
  49. remove)
  50. do_remove
  51. ;;
  52. esac