You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2014/05/06 18:39:29 UTC

git commit: AMBARI-5620. agent and server packages on Ubuntu conflict on the same node (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk 0aaba364c -> 246d82fbf


AMBARI-5620. agent and server packages on Ubuntu conflict on the same node (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/246d82fb
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/246d82fb
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/246d82fb

Branch: refs/heads/trunk
Commit: 246d82fbfb7f0781cb3375ecd19db16dbf047866
Parents: 0aaba36
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue May 6 19:39:16 2014 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Tue May 6 19:39:16 2014 +0300

----------------------------------------------------------------------
 ambari-agent/conf/unix/install-helper.sh        | 49 ++++++++++++++++++++
 ambari-agent/pom.xml                            | 24 +++++++++-
 .../src/main/package/deb/control/postinst       |  9 ++--
 ambari-agent/src/main/package/deb/control/prerm | 10 ++--
 .../src/main/package/rpm/postinstall.sh         | 20 ++++----
 ambari-agent/src/main/package/rpm/preremove.sh  | 11 +++--
 ambari-server/conf/unix/install-helper.sh       | 48 +++++++++++++++++++
 ambari-server/pom.xml                           | 24 +++++++++-
 .../src/main/package/deb/control/postinst       |  9 ++--
 .../src/main/package/deb/control/prerm          | 17 ++++---
 .../src/main/package/rpm/postinstall.sh         | 11 +++--
 ambari-server/src/main/package/rpm/preremove.sh | 14 +++---
 12 files changed, 198 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-agent/conf/unix/install-helper.sh
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/install-helper.sh b/ambari-agent/conf/unix/install-helper.sh
new file mode 100644
index 0000000..65bc7bd
--- /dev/null
+++ b/ambari-agent/conf/unix/install-helper.sh
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information rega4rding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+
+##################################################################
+#                      AGENT INSTALL HELPER                      #
+##################################################################
+
+COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
+INSTALL_HELPER_SERVER="/var/lib/ambari-server/install-helper.sh"
+COMMON_DIR_AGENT="/usr/lib/ambari-agent/lib/common_functions"
+
+
+do_install(){
+  if [ ! -d "$COMMON_DIR" ]; then
+    ln -s "$COMMON_DIR_AGENT" "$COMMON_DIR"
+  fi
+}
+
+do_remove(){
+  if [ -d "$COMMON_DIR" ]; then  # common dir exists
+    rm -f "$COMMON_DIR"
+    if [ -f "$INSTALL_HELPER_SERVER" ]; then  #  call server shared files installer
+      $INSTALL_HELPER_SERVER install
+    fi
+  fi
+}
+
+
+case "$1" in
+install)
+  do_install
+  ;;
+remove)
+  do_remove
+  ;;
+esac

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index d072e0f..9e1baa1 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -41,7 +41,7 @@
     <puppet.tar>http://downloads.puppetlabs.com/puppet/puppet-2.7.9.tar.gz</puppet.tar>
     <agent.install.dir>/usr/lib/python2.6/site-packages/ambari_agent</agent.install.dir>
     <resmgmt.install.dir>/usr/lib/python2.6/site-packages/resource_management</resmgmt.install.dir>
-    <common_functions.install.dir>/usr/lib/python2.6/site-packages/common_functions</common_functions.install.dir>
+    <common_functions.install.dir>/usr/lib/ambari-agent/lib/common_functions</common_functions.install.dir>
     <jinja.install.dir>/usr/lib/python2.6/site-packages/jinja2</jinja.install.dir>
     <ruby.tar>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.15/repos/centos6/ruby-1.8.7-p370.tar.gz</ruby.tar>
     <lib.dir>/usr/lib/ambari-agent/lib</lib.dir>
@@ -323,6 +323,17 @@
               </sources>
             </mapping>
             <mapping>
+              <directory>/var/lib/ambari-agent</directory>
+              <filemode>700</filemode>
+              <username>root</username>
+              <groupname>root</groupname>
+              <sources>
+                <source>
+                  <location>conf/unix/install-helper.sh</location>
+                </source>
+              </sources>
+            </mapping>
+            <mapping>
               <directory>${package.pid.dir}</directory>
               <filemode>755</filemode>
               <username>root</username>
@@ -491,6 +502,17 @@
               </mapper>
             </data>
             <data>
+              <src>conf/unix/install-helper.sh</src>
+              <type>file</type>
+              <mapper>
+                <type>perm</type>
+                <prefix>/var/lib/ambari-agent</prefix>
+                <user>root</user>
+                <group>root</group>
+                <filemode>700</filemode>
+              </mapper>
+            </data>
+            <data>
               <type>template</type>
               <paths>
                 <path>${package.pid.dir}</path>

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-agent/src/main/package/deb/control/postinst
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/package/deb/control/postinst b/ambari-agent/src/main/package/deb/control/postinst
index c40cb62..0ddd842 100644
--- a/ambari-agent/src/main/package/deb/control/postinst
+++ b/ambari-agent/src/main/package/deb/control/postinst
@@ -14,8 +14,10 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
-if [ "$1" == "configure" ]; # Action is install
-then
+if [ "$1" == "configure" ]; then  # Action is install
+  if [ -f "/var/lib/ambari-agent/install-helper.sh" ]; then
+    /var/lib/ambari-agent/install-helper.sh install
+  fi
   update-rc.d ambari-agent defaults
 fi
 
@@ -25,8 +27,7 @@ chmod 755 /usr/lib/ambari-agent/lib/facter-1.6.10/bin/facter /usr/lib/ambari-age
 BAK=/etc/ambari-agent/conf/ambari-agent.ini.old
 ORIG=/etc/ambari-agent/conf/ambari-agent.ini
 
-if [ -f $BAK ];
-then
+if [ -f $BAK ];then
   SERV_HOST=`grep -e hostname\s*= $BAK | sed -r -e 's/hostname\s*=//' -e 's/\./\\\./g'`
   sed -i -r -e "s/(hostname\s*=).*/\1$SERV_HOST/" $ORIG
   rm $BAK -f

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-agent/src/main/package/deb/control/prerm
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/package/deb/control/prerm b/ambari-agent/src/main/package/deb/control/prerm
index dec2690..70a9c63 100644
--- a/ambari-agent/src/main/package/deb/control/prerm
+++ b/ambari-agent/src/main/package/deb/control/prerm
@@ -18,15 +18,17 @@
 # during package update. See http://www.ibm.com/developerworks/library/l-rpm2/
 # for details
 
-if [ "$1" == "remove" ]; # Action is uninstall
-then
+if [ "$1" == "remove" ]; then # Action is uninstall
     /usr/sbin/ambari-agent stop > /dev/null 2>&1
-    if [ -d "/etc/ambari-agent/conf.save" ]
-    then
+    if [ -d "/etc/ambari-agent/conf.save" ];  then
         mv /etc/ambari-agent/conf.save /etc/ambari-agent/conf_$(date '+%d_%m_%y_%H_%M').save
     fi
     mv /etc/ambari-agent/conf /etc/ambari-agent/conf.save
 
+    if [ -f "/var/lib/ambari-agent/install-helper.sh" ]; then
+      /var/lib/ambari-agent/install-helper.sh remove
+    fi
+
     update-rc.d -f ambari-agent remove
 fi
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-agent/src/main/package/rpm/postinstall.sh
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/package/rpm/postinstall.sh b/ambari-agent/src/main/package/rpm/postinstall.sh
index 39686f3..da3ba0d 100644
--- a/ambari-agent/src/main/package/rpm/postinstall.sh
+++ b/ambari-agent/src/main/package/rpm/postinstall.sh
@@ -13,15 +13,16 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
-if [ "$1" -eq 1 ]; # Action is install
-then
+
+if [ "$1" -eq 1 ]; then # Action is install
+  if [ -f "/var/lib/ambari-agent/install-helper.sh" ]; then
+    /var/lib/ambari-agent/install-helper.sh install
+  fi
   chkconfig --add ambari-agent
 fi
 
-if [ "$1" -eq 2 ]; # Action is upgrade
-then
-  if [ -d "/etc/ambari-agent/conf.save" ]
-  then
+if [ "$1" -eq 2 ]; then # Action is upgrade
+  if [ -d "/etc/ambari-agent/conf.save" ]; then
       cp -f /etc/ambari-agent/conf.save/* /etc/ambari-agent/conf
       mv /etc/ambari-agent/conf.save /etc/ambari-agent/conf_$(date '+%d_%m_%y_%H_%M').save
   fi
@@ -32,10 +33,11 @@ chmod 755 /usr/lib/ambari-agent/lib/facter-1.6.10/bin/facter /usr/lib/ambari-age
 BAK=/etc/ambari-agent/conf/ambari-agent.ini.old
 ORIG=/etc/ambari-agent/conf/ambari-agent.ini
 
-if [ -f $BAK ];
-then
+if [ -f $BAK ]; then
   SERV_HOST=`grep -e hostname\s*= $BAK | sed -r -e 's/hostname\s*=//' -e 's/\./\\\./g'`
   sed -i -r -e "s/(hostname\s*=).*/\1$SERV_HOST/" $ORIG
   rm $BAK -f
 fi
-exit 0
\ No newline at end of file
+
+
+exit 0

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-agent/src/main/package/rpm/preremove.sh
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/package/rpm/preremove.sh b/ambari-agent/src/main/package/rpm/preremove.sh
index 5ac78c5..5fb9be2 100644
--- a/ambari-agent/src/main/package/rpm/preremove.sh
+++ b/ambari-agent/src/main/package/rpm/preremove.sh
@@ -17,15 +17,18 @@
 # during package update. See http://www.ibm.com/developerworks/library/l-rpm2/
 # for details
 
-if [ "$1" -eq 0 ]; # Action is uninstall
-then
+
+if [ "$1" -eq 0 ]; then  # Action is uninstall
     /usr/sbin/ambari-agent stop > /dev/null 2>&1
-    if [ -d "/etc/ambari-agent/conf.save" ]
-    then
+    if [ -d "/etc/ambari-agent/conf.save" ]; then
         mv /etc/ambari-agent/conf.save /etc/ambari-agent/conf_$(date '+%d_%m_%y_%H_%M').save
     fi
     mv /etc/ambari-agent/conf /etc/ambari-agent/conf.save
 
+    if [ -f "/var/lib/ambari-agent/install-helper.sh" ]; then
+      /var/lib/ambari-agent/install-helper.sh remove
+    fi
+
     chkconfig --del ambari-agent
 fi
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-server/conf/unix/install-helper.sh
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/install-helper.sh b/ambari-server/conf/unix/install-helper.sh
new file mode 100644
index 0000000..a1d5cb2
--- /dev/null
+++ b/ambari-server/conf/unix/install-helper.sh
@@ -0,0 +1,48 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information rega4rding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##################################################################
+#                      SERVER INSTALL HELPER                     #
+##################################################################
+
+COMMON_DIR="/usr/lib/python2.6/site-packages/common_functions"
+INSTALL_HELPER_AGENT="/var/lib/ambari-agent/install-helper.sh"
+COMMON_DIR_SERVER="/usr/lib/ambari-server/lib/common_functions"
+
+
+do_install(){
+  if [ ! -d "$COMMON_DIR" ]; then
+    ln -s "$COMMON_DIR_SERVER" "$COMMON_DIR"
+  fi
+}
+
+do_remove(){
+  if [ -d "$COMMON_DIR" ]; then  # common dir exists
+    rm -f "$COMMON_DIR"
+    if [ -f "$INSTALL_HELPER_AGENT" ]; then  #  call agent shared files installer
+      $INSTALL_HELPER_AGENT install
+    fi
+  fi
+}
+
+
+case "$1" in
+install)
+  do_install
+  ;;
+remove)
+  do_remove
+  ;;
+esac

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index d04fc19..7258ac6 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -31,7 +31,7 @@
     <custom.tests>false</custom.tests>
     <hdpUrlForCentos6>http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.1.1.0</hdpUrlForCentos6>
     <hdpLatestUrl>http://public-repo-1.hortonworks.com/HDP/hdp_urlinfo.json</hdpLatestUrl>
-    <common_functions.install.dir>/usr/lib/python2.6/site-packages/common_functions</common_functions.install.dir>
+    <common_functions.install.dir>/usr/lib/ambari-server/lib/common_functions</common_functions.install.dir>
     <ambari-web-dir>${basedir}/../ambari-web/public</ambari-web-dir>
   </properties>
   <build>
@@ -297,6 +297,17 @@
               </sources>
             </mapping>
             <mapping>
+              <directory>/var/lib/ambari-server/</directory>
+              <filemode>700</filemode>
+              <username>root</username>
+              <groupname>root</groupname>
+              <sources>
+                <source>
+                  <location>conf/unix/install-helper.sh</location>
+                </source>
+              </sources>
+            </mapping>
+            <mapping>
               <directory>/var/lib/ambari-server/keys</directory>
               <sources>
                 <source>
@@ -570,6 +581,17 @@
             </mapper>
           </data>
           <data>
+            <src>conf/unix/install-helper.sh</src>
+            <type>file</type>
+            <mapper>
+              <type>perm</type>
+              <prefix>/var/lib/ambari-server/</prefix>
+              <user>root</user>
+              <group>root</group>
+              <filemode>700</filemode>
+            </mapper>
+          </data>
+          <data>
             <src>conf/unix/ca.config</src>
             <type>file</type>
             <mapper>

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-server/src/main/package/deb/control/postinst
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/deb/control/postinst b/ambari-server/src/main/package/deb/control/postinst
index a274ca3..629ab09 100644
--- a/ambari-server/src/main/package/deb/control/postinst
+++ b/ambari-server/src/main/package/deb/control/postinst
@@ -14,16 +14,17 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
-if [ -e "/etc/init.d/ambari-server" ];
-then # Check is needed for upgrade
+if [ -e "/etc/init.d/ambari-server" ]; then # Check is needed for upgrade
     # Remove link created by previous package version
     rm /etc/init.d/ambari-server
 fi
 
 ln -s /usr/sbin/ambari-server /etc/init.d/ambari-server
 
-if [ "$1" == "configure" ]; # Action is install
-then
+if [ "$1" == "configure" ]; then  # Action is install
+  if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
+      /var/lib/ambari-server/install-helper.sh install
+  fi
   update-rc.d ambari-server defaults
 fi
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-server/src/main/package/deb/control/prerm
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/deb/control/prerm b/ambari-server/src/main/package/deb/control/prerm
index 2c4e97a..15d05c4 100644
--- a/ambari-server/src/main/package/deb/control/prerm
+++ b/ambari-server/src/main/package/deb/control/prerm
@@ -14,26 +14,25 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
-# WARNING: This script is performed not only on uninstall, but also
-# during package update. See http://www.ibm.com/developerworks/library/l-rpm2/
-# for details
 
-if [ "$1" == "remove" ]; # Action is uninstall
-then
+
+if [ "$1" == "remove" ]; then # Action is uninstall
     /usr/sbin/ambari-server stop > /dev/null 2>&1
-    if [ -d "/etc/ambari-server/conf.save" ]
-    then
+    if [ -d "/etc/ambari-server/conf.save" ]; then
         mv /etc/ambari-server/conf.save /etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save
     fi
 
-    if [ -e "/etc/init.d/ambari-server" ];
-    then
+    if [ -e "/etc/init.d/ambari-server" ]; then
         # Remove link created during install
         rm /etc/init.d/ambari-server
     fi
 
     mv /etc/ambari-server/conf /etc/ambari-server/conf.save
 
+    if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
+      /var/lib/ambari-server/install-helper.sh remove
+    fi
+
     update-rc.d -f ambari-server remove
 fi
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-server/src/main/package/rpm/postinstall.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/rpm/postinstall.sh b/ambari-server/src/main/package/rpm/postinstall.sh
index 8a531db..55b0ffa 100644
--- a/ambari-server/src/main/package/rpm/postinstall.sh
+++ b/ambari-server/src/main/package/rpm/postinstall.sh
@@ -13,17 +13,18 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
-if [ -e "/etc/init.d/ambari-server" ];
-then # Check is needed for upgrade
+if [ -e "/etc/init.d/ambari-server" ]; then # Check is needed for upgrade
     # Remove link created by previous package version
     rm /etc/init.d/ambari-server
 fi
 
 ln -s /usr/sbin/ambari-server /etc/init.d/ambari-server
 
-if [ "$1" -eq 1 ]; # Action is install
-then
+if [ "$1" -eq 1 ]; then # Action is install
+  if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
+      /var/lib/ambari-server/install-helper.sh install
+  fi
   chkconfig --add ambari-server
 fi
 
-exit 0
\ No newline at end of file
+exit 0

http://git-wip-us.apache.org/repos/asf/ambari/blob/246d82fb/ambari-server/src/main/package/rpm/preremove.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/rpm/preremove.sh b/ambari-server/src/main/package/rpm/preremove.sh
index a916b0b..073c07f 100644
--- a/ambari-server/src/main/package/rpm/preremove.sh
+++ b/ambari-server/src/main/package/rpm/preremove.sh
@@ -17,24 +17,24 @@
 # during package update. See http://www.ibm.com/developerworks/library/l-rpm2/
 # for details
 
-if [ "$1" -eq 0 ]; # Action is uninstall
-then
+if [ "$1" -eq 0 ]; then  # Action is uninstall
     /usr/sbin/ambari-server stop > /dev/null 2>&1
-    if [ -d "/etc/ambari-server/conf.save" ]
-    then
+    if [ -d "/etc/ambari-server/conf.save" ]; then
         mv /etc/ambari-server/conf.save /etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save
     fi
 
-    if [ -e "/etc/init.d/ambari-server" ];
-    then
+    if [ -e "/etc/init.d/ambari-server" ]; then
         # Remove link created during install
         rm /etc/init.d/ambari-server
     fi
 
     mv /etc/ambari-server/conf /etc/ambari-server/conf.save
 
-    chkconfig --del ambari-server
+    if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
+      /var/lib/ambari-server/install-helper.sh remove
+    fi
 
+    chkconfig --del ambari-server
 fi
 
 exit 0