install-helper.sh 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. JINJA_DIR="/usr/lib/python2.6/site-packages/ambari_jinja2"
  21. SIMPLEJSON_DIR="/usr/lib/python2.6/site-packages/ambari_simplejson"
  22. OLD_COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
  23. INSTALL_HELPER_SERVER="/var/lib/ambari-server/install-helper.sh"
  24. COMMON_DIR_AGENT="/usr/lib/ambari-agent/lib/ambari_commons"
  25. RESOURCE_MANAGEMENT_DIR_AGENT="/usr/lib/ambari-agent/lib/resource_management"
  26. JINJA_AGENT_DIR="/usr/lib/ambari-agent/lib/ambari_jinja2"
  27. SIMPLEJSON_AGENT_DIR="/usr/lib/ambari-agent/lib/ambari_simplejson"
  28. PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
  29. PYTHON_WRAPER_SOURCE="/var/lib/ambari-agent/ambari-python-wrap"
  30. do_install(){
  31. # setting ambari_commons shared resource
  32. rm -rf "$OLD_COMMON_DIR"
  33. if [ ! -d "$COMMON_DIR" ]; then
  34. ln -s "$COMMON_DIR_AGENT" "$COMMON_DIR"
  35. fi
  36. # setting resource_management shared resource
  37. if [ ! -d "$RESOURCE_MANAGEMENT_DIR" ]; then
  38. ln -s "$RESOURCE_MANAGEMENT_DIR_AGENT" "$RESOURCE_MANAGEMENT_DIR"
  39. fi
  40. # setting jinja2 shared resource
  41. if [ ! -d "$JINJA_DIR" ]; then
  42. ln -s "$JINJA_AGENT_DIR" "$JINJA_DIR"
  43. fi
  44. # setting simplejson shared resource
  45. if [ ! -d "$SIMPLEJSON_DIR" ]; then
  46. ln -s "$SIMPLEJSON_AGENT_DIR" "$SIMPLEJSON_DIR"
  47. fi
  48. # setting python-wrapper script
  49. if [ ! -f "$PYTHON_WRAPER_TARGET" ]; then
  50. ln -s "$PYTHON_WRAPER_SOURCE" "$PYTHON_WRAPER_TARGET"
  51. fi
  52. # on nano Ubuntu, when umask=027 those folders are created without 'x' bit for 'others'.
  53. # which causes failures when hadoop users try to access tmp_dir
  54. chmod a+x /var/lib/ambari-agent
  55. chmod a+x /var/lib/ambari-agent/data
  56. chmod 777 /var/lib/ambari-agent/data/tmp
  57. }
  58. do_remove(){
  59. if [ -f "$PYTHON_WRAPER_TARGET" ]; then
  60. rm -f "$PYTHON_WRAPER_TARGET"
  61. fi
  62. # if server package exists, restore their settings
  63. if [ -f "$INSTALL_HELPER_SERVER" ]; then # call server shared files installer
  64. $INSTALL_HELPER_SERVER install
  65. fi
  66. }
  67. do_upgrade(){
  68. do_install
  69. }
  70. case "$1" in
  71. install)
  72. do_install
  73. ;;
  74. remove)
  75. do_remove
  76. ;;
  77. upgrade)
  78. do_upgrade
  79. ;;
  80. esac