瀏覽代碼

AMBARI-6076. Ambari server is not starting after upgrade (aonishuk)

Andrew Onishuk 11 年之前
父節點
當前提交
f033a869fa

+ 17 - 12
ambari-agent/src/main/package/rpm/postinstall.sh

@@ -14,19 +14,24 @@
 # limitations under the License
 
 
-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
+case "$1" in
+  1) # Action 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 ]; 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
-fi
+  ;;
+  2) # Action 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
+
+    if [ -f "/var/lib/ambari-agent/install-helper.sh" ]; then
+        /var/lib/ambari-agent/install-helper.sh upgrade
+    fi
+  ;;
+esac
 
 
 BAK=/etc/ambari-agent/conf/ambari-agent.ini.old

+ 10 - 6
ambari-server/conf/unix/install-helper.sh

@@ -26,9 +26,8 @@ PYTHON_WRAPER_SOURCE="/var/lib/ambari-server/ambari-python-wrap"
 
 do_install(){
   # setting common_functions shared resource
-  if [ ! -d "$COMMON_DIR" ]; then
-    ln -s "$COMMON_DIR_SERVER" "$COMMON_DIR"
-  fi
+  rm -rf "$COMMON_DIR"
+  ln -s "$COMMON_DIR_SERVER" "$COMMON_DIR"
   # setting python-wrapper script
   if [ ! -f "$PYTHON_WRAPER_TARGET" ]; then
     ln -s "$PYTHON_WRAPER_SOURCE" "$PYTHON_WRAPER_TARGET"
@@ -36,9 +35,8 @@ do_install(){
 }
 
 do_remove(){
-  if [ -d "$COMMON_DIR" ]; then  # common dir exists
-    rm -f "$COMMON_DIR"
-  fi
+
+  rm -rf "$COMMON_DIR"
 
   if [ -f "$PYTHON_WRAPER_TARGET" ]; then
     rm -f "$PYTHON_WRAPER_TARGET"
@@ -50,6 +48,9 @@ do_remove(){
   fi
 }
 
+do_upgrade(){
+  do_install
+}
 
 case "$1" in
 install)
@@ -58,4 +59,7 @@ install)
 remove)
   do_remove
   ;;
+upgrade)
+  do_upgrade
+  ;;
 esac

+ 13 - 6
ambari-server/src/main/package/rpm/postinstall.sh

@@ -20,11 +20,18 @@ fi
 
 ln -s /usr/sbin/ambari-server /etc/init.d/ambari-server
 
-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
+case "$1" in
+  1) # Action install
+    if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
+        /var/lib/ambari-server/install-helper.sh install
+    fi
+    chkconfig --add ambari-server
+  ;;
+  2) # Action upgrade
+    if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
+        /var/lib/ambari-server/install-helper.sh upgrade
+    fi
+  ;;
+esac
 
 exit 0