install-helper.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. SUDOERS_FILE="/etc/sudoers.d/ambari-agent"
  31. do_install(){
  32. # setting ambari_commons shared resource
  33. rm -rf "$OLD_COMMON_DIR"
  34. if [ ! -d "$COMMON_DIR" ]; then
  35. ln -s "$COMMON_DIR_AGENT" "$COMMON_DIR"
  36. fi
  37. # setting resource_management shared resource
  38. if [ ! -d "$RESOURCE_MANAGEMENT_DIR" ]; then
  39. ln -s "$RESOURCE_MANAGEMENT_DIR_AGENT" "$RESOURCE_MANAGEMENT_DIR"
  40. fi
  41. # setting jinja2 shared resource
  42. if [ ! -d "$JINJA_DIR" ]; then
  43. ln -s "$JINJA_AGENT_DIR" "$JINJA_DIR"
  44. fi
  45. # setting simplejson shared resource
  46. if [ ! -d "$SIMPLEJSON_DIR" ]; then
  47. ln -s "$SIMPLEJSON_AGENT_DIR" "$SIMPLEJSON_DIR"
  48. fi
  49. # setting python-wrapper script
  50. if [ ! -f "$PYTHON_WRAPER_TARGET" ]; then
  51. ln -s "$PYTHON_WRAPER_SOURCE" "$PYTHON_WRAPER_TARGET"
  52. fi
  53. chmod 440 "$SUDOERS_FILE"
  54. grep '^#includedir /etc/sudoers.d$' /etc/sudoers > /dev/null
  55. if [ $? -ne 0 ] ; then
  56. echo '#includedir /etc/sudoers.d' >> /etc/sudoers
  57. fi
  58. # on nano Ubuntu, when umask=027 those folders are created without 'x' bit for 'others'.
  59. # which causes failures when hadoop users try to access tmp_dir
  60. chmod a+x /var/lib/ambari-agent
  61. chmod a+x /var/lib/ambari-agent/data
  62. chmod 777 /var/lib/ambari-agent/data/tmp
  63. }
  64. do_remove(){
  65. if [ -f "$PYTHON_WRAPER_TARGET" ]; then
  66. rm -f "$PYTHON_WRAPER_TARGET"
  67. fi
  68. # if server package exists, restore their settings
  69. if [ -f "$INSTALL_HELPER_SERVER" ]; then # call server shared files installer
  70. $INSTALL_HELPER_SERVER install
  71. fi
  72. }
  73. do_upgrade(){
  74. do_install
  75. }
  76. case "$1" in
  77. install)
  78. do_install
  79. ;;
  80. remove)
  81. do_remove
  82. ;;
  83. upgrade)
  84. do_upgrade
  85. ;;
  86. esac