You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/02/23 22:21:51 UTC
[06/11] ambari git commit: AMBARI-15135. [Ambari tarballs]
ambari-server java-side should support running from custom root (aonishuk)
AMBARI-15135. [Ambari tarballs] ambari-server java-side should support running from custom root (aonishuk)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/18d5a696
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/18d5a696
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/18d5a696
Branch: refs/heads/branch-dev-patch-upgrade
Commit: 18d5a6964212237c0cd9a5c8c8211cd059cae716
Parents: df0b18c
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Tue Feb 23 19:42:54 2016 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Tue Feb 23 19:42:54 2016 +0200
----------------------------------------------------------------------
Committed | 0
.../src/main/repo/install_ambari_tarball.py | 2 +-
ambari-server/conf/unix/ca.config | 3 +-
ambari-server/conf/unix/install-helper.sh | 28 +++++++++++---
ambari-server/conf/unix/log4j.properties | 3 +-
ambari-server/pom.xml | 1 +
.../server/configuration/Configuration.java | 24 ++++++------
.../ambari/server/controller/AmbariServer.java | 6 ++-
.../encryption/MasterKeyServiceImpl.java | 3 +-
.../apache/ambari/server/utils/AmbariPath.java | 39 ++++++++++++++++++++
.../src/main/package/deb/control/postinst | 2 +-
.../src/main/package/deb/control/preinst | 22 ++++++-----
.../src/main/package/deb/control/prerm | 2 +-
.../src/main/package/rpm/postinstall.sh | 10 +++--
.../src/main/package/rpm/posttrans_server.sh | 10 +++--
.../src/main/package/rpm/preinstall.sh | 19 ++++++----
ambari-server/src/main/package/rpm/preremove.sh | 6 ++-
17 files changed, 127 insertions(+), 53 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/Committed
----------------------------------------------------------------------
diff --git a/Committed b/Committed
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-common/src/main/repo/install_ambari_tarball.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/repo/install_ambari_tarball.py b/ambari-common/src/main/repo/install_ambari_tarball.py
index e6578b0..a22823f 100644
--- a/ambari-common/src/main/repo/install_ambari_tarball.py
+++ b/ambari-common/src/main/repo/install_ambari_tarball.py
@@ -42,7 +42,7 @@ DEB_DEPENDENCIES_PROPERTY = "deb.dependency.list"
FILES_TO_DOWNLOAD = [PREINST_SCRIPT, PRERM_SCRIPT, POSTINST_SCRIPT, POSTRM_SCRIPT, OS_CHECK, OS_FAMILY_DESCRIPTION, OS_PACKAGE_DEPENDENCIES]
-ROOT_FOLDER_ENV_VARIABLE = "AMBARI_ROOT_FOLDER"
+ROOT_FOLDER_ENV_VARIABLE = "RPM_INSTALL_PREFIX"
class Utils:
verbose = False
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/conf/unix/ca.config
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/ca.config b/ambari-server/conf/unix/ca.config
index 45fdda0..c34f387 100644
--- a/ambari-server/conf/unix/ca.config
+++ b/ambari-server/conf/unix/ca.config
@@ -1,7 +1,8 @@
[ ca ]
default_ca = CA_CLIENT
[ CA_CLIENT ]
-dir = /var/lib/ambari-server/keys/db
+root_dir = /
+dir = $root_dir/var/lib/ambari-server/keys/db
certs = $dir/certs
new_certs_dir = $dir/newcerts
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/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
index 0ccfc63..918ea1d 100644
--- a/ambari-server/conf/unix/install-helper.sh
+++ b/ambari-server/conf/unix/install-helper.sh
@@ -16,8 +16,7 @@
#########################################postinstall.sh#########################
# SERVER INSTALL HELPER #
##################################################################
-
-ROOT="${AMBARI_ROOT_FOLDER}"
+ROOT="${RPM_INSTALL_PREFIX}" # Customized folder, which ambari-server files are installed into ('/' or '' are default).
COMMON_DIR="${ROOT}/usr/lib/python2.6/site-packages/ambari_commons"
RESOURCE_MANAGEMENT_DIR="${ROOT}/usr/lib/python2.6/site-packages/resource_management"
@@ -25,7 +24,8 @@ JINJA_DIR="${ROOT}/usr/lib/python2.6/site-packages/ambari_jinja2"
SIMPLEJSON_DIR="${ROOT}/usr/lib/python2.6/site-packages/ambari_simplejson"
OLD_COMMON_DIR="${ROOT}/usr/lib/python2.6/site-packages/common_functions"
AMBARI_SERVER="${ROOT}/usr/lib/python2.6/site-packages/ambari_server"
-INSTALL_HELPER_AGENT="${ROOT}/var/lib/ambari-agent/install-helper.sh"
+INSTALL_HELPER_AGENT="/var/lib/ambari-agent/install-helper.sh"
+CA_CONFIG="${ROOT}/var/lib/ambari-server/keys/ca.config"
COMMON_DIR_SERVER="${ROOT}/usr/lib/ambari-server/lib/ambari_commons"
RESOURCE_MANAGEMENT_DIR_SERVER="${ROOT}/usr/lib/ambari-server/lib/resource_management"
JINJA_SERVER_DIR="${ROOT}/usr/lib/ambari-server/lib/ambari_jinja2"
@@ -41,6 +41,7 @@ AMBARI_SERVER_EXECUTABLE="${ROOT}/etc/init.d/ambari-server"
AMBARI_CONFIGS_DIR="${ROOT}/etc/ambari-server/conf"
AMBARI_CONFIGS_DIR_SAVE="${ROOT}/etc/ambari-server/conf.save"
AMBARI_CONFIGS_DIR_SAVE_BACKUP="${ROOT}/etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save"
+AMBARI_LOG4J="${AMBARI_CONFIGS_DIR}/log4j.properties"
do_install(){
rm -f "$AMBARI_SERVER_EXECUTABLE_LINK"
@@ -86,14 +87,29 @@ do_install(){
ln -s "$AMBARI_PYTHON" "$PYTHON_WRAPER_TARGET"
fi
+ sed -i "s|ambari.root.dir\s*=\s*/|ambari.root.dir=${ROOT}|g" "$AMBARI_LOG4J"
+ sed -i "s|root_dir\s*=\s*/|root_dir = ${ROOT}|g" "$CA_CONFIG"
+
+ AUTOSTART_SERVER_CMD=""
which chkconfig > /dev/null 2>&1
if [ "$?" -eq 0 ] ; then
- chkconfig --add ambari-server
+ AUTOSTART_SERVER_CMD="chkconfig --add ambari-server"
fi
which update-rc.d > /dev/null 2>&1
if [ "$?" -eq 0 ] ; then
- update-rc.d ambari-server defaults
- fi
+ AUTOSTART_SERVER_CMD="update-rc.d ambari-server defaults"
+ fi
+
+ # if installed to customized root folder, skip ambari-server service actions,
+ # as no file in /etc/init.d/ambari-server is present
+ if [ ! "${ROOT}/" -ef "/" ] ; then
+ echo "Not adding ambari-server service to startup, as installed to customized root."
+ echo "If you need this functionality run the commands below, which create ambari-server service and configure it to run at startup: "
+ echo "sudo ln -s ${AMBARI_SERVER_EXECUTABLE} /etc/init.d/ambari-server"
+ echo "sudo $AUTOSTART_SERVER_CMD"
+ else
+ $AUTOSTART_SERVER_CMD
+ fi
}
do_remove(){
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/conf/unix/log4j.properties
----------------------------------------------------------------------
diff --git a/ambari-server/conf/unix/log4j.properties b/ambari-server/conf/unix/log4j.properties
index 0ccab22..2ee32d4 100644
--- a/ambari-server/conf/unix/log4j.properties
+++ b/ambari-server/conf/unix/log4j.properties
@@ -18,7 +18,8 @@
# Define some default values that can be overridden by system properties
# Root logger option
-ambari.log.dir=/var/log/ambari-server
+ambari.root.dir=/
+ambari.log.dir=${ambari.root.dir}/var/log/ambari-server
ambari.log.file=ambari-server.log
ambari.config-changes.file=ambari-config-changes.log
ambari.alerts.file=ambari-alerts.log
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 2d0559c..e3409b9 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -366,6 +366,7 @@
<group>Development</group>
<description>Maven Recipe: RPM Package.</description>
<autoRequires>no</autoRequires>
+ <prefix>/</prefix>
<requires>
<require>${rpm.dependency.list}</require>
</requires>
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
index 4a980ee..1cb935b 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/configuration/Configuration.java
@@ -37,6 +37,7 @@ import org.apache.ambari.server.security.authorization.jwt.JwtAuthenticationProp
import org.apache.ambari.server.security.encryption.CredentialProvider;
import org.apache.ambari.server.state.stack.OsFamily;
import org.apache.ambari.server.security.encryption.CertificateUtils;
+import org.apache.ambari.server.utils.AmbariPath;
import org.apache.ambari.server.utils.Parallel;
import org.apache.ambari.server.utils.ShellCommandUtil;
import org.apache.commons.io.FileUtils;
@@ -57,7 +58,6 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
-
import java.security.cert.CertificateException;
import java.security.interfaces.RSAPublicKey;
@@ -81,23 +81,23 @@ public class Configuration {
*/
public static final String PREFIX_DIR = "/var/lib/ambari-agent/data";
- public static final String BOOTSTRAP_DIR_DEFAULT = "/var/run/ambari-server/bootstrap";
+ public static final String BOOTSTRAP_DIR_DEFAULT = AmbariPath.getPath("/var/run/ambari-server/bootstrap");
public static final String VIEWS_DIR = "views.dir";
- public static final String VIEWS_DIR_DEFAULT = "/var/lib/ambari-server/resources/views";
+ public static final String VIEWS_DIR_DEFAULT = AmbariPath.getPath("/var/lib/ambari-server/resources/views");
public static final String VIEWS_VALIDATE = "views.validate";
public static final String VIEWS_VALIDATE_DEFAULT = "false";
public static final String VIEWS_REMOVE_UNDEPLOYED = "views.remove.undeployed";
public static final String VIEWS_REMOVE_UNDEPLOYED_DEFAULT = "false";
public static final String WEBAPP_DIR = "webapp.dir";
public static final String BOOTSTRAP_SCRIPT = "bootstrap.script";
- public static final String BOOTSTRAP_SCRIPT_DEFAULT = "/usr/bin/ambari_bootstrap";
+ public static final String BOOTSTRAP_SCRIPT_DEFAULT = AmbariPath.getPath("/usr/bin/ambari_bootstrap");
public static final String BOOTSTRAP_SETUP_AGENT_SCRIPT = "bootstrap.setup_agent.script";
public static final String BOOTSTRAP_SETUP_AGENT_PASSWORD = "bootstrap.setup_agent.password";
public static final String BOOTSTRAP_MASTER_HOSTNAME = "bootstrap.master_host_name";
public static final String RECOMMENDATIONS_DIR = "recommendations.dir";
- public static final String RECOMMENDATIONS_DIR_DEFAULT = "/var/run/ambari-server/stack-recommendations";
+ public static final String RECOMMENDATIONS_DIR_DEFAULT = AmbariPath.getPath("/var/run/ambari-server/stack-recommendations");
public static final String STACK_ADVISOR_SCRIPT = "stackadvisor.script";
- public static final String STACK_ADVISOR_SCRIPT_DEFAULT = "/var/lib/ambari-server/resources/scripts/stack_advisor.py";
+ public static final String STACK_ADVISOR_SCRIPT_DEFAULT = AmbariPath.getPath("/var/lib/ambari-server/resources/scripts/stack_advisor.py");
public static final String AMBARI_PYTHON_WRAP_KEY = "ambari.python.wrap";
public static final String AMBARI_PYTHON_WRAP_DEFAULT = "ambari-python-wrap";
public static final String API_AUTHENTICATED_USER = "api.authenticated.user";
@@ -302,7 +302,7 @@ public class Configuration {
public static final String DEFAULT_SCHEDULER_START_DELAY_SECONDS = "120";
public static final String DEFAULT_EXECUTION_SCHEDULER_WAIT_SECONDS = "1";
public static final String SERVER_TMP_DIR_KEY = "server.tmp.dir";
- public static final String SERVER_TMP_DIR_DEFAULT = "/var/lib/ambari-server/tmp";
+ public static final String SERVER_TMP_DIR_DEFAULT = AmbariPath.getPath("/var/lib/ambari-server/tmp");
public static final String EXTERNAL_SCRIPT_TIMEOUT_KEY = "server.script.timeout";
public static final String EXTERNAL_SCRIPT_TIMEOUT_DEFAULT = "5000";
public static final String DEF_ARCHIVE_EXTENSION;
@@ -316,7 +316,7 @@ public class Configuration {
public static final String KDC_CONNECTION_CHECK_TIMEOUT_KEY = "kdcserver.connection.check.timeout";
public static final String KDC_CONNECTION_CHECK_TIMEOUT_DEFAULT = "10000";
public static final String KERBEROS_KEYTAB_CACHE_DIR_KEY = "kerberos.keytab.cache.dir";
- public static final String KERBEROS_KEYTAB_CACHE_DIR_DEFAULT = "/var/lib/ambari-server/data/cache";
+ public static final String KERBEROS_KEYTAB_CACHE_DIR_DEFAULT = AmbariPath.getPath("/var/lib/ambari-server/data/cache");
public static final String KERBEROS_CHECK_JAAS_CONFIGURATION_KEY = "kerberos.check.jaas.configuration";
public static final String KERBEROS_CHECK_JAAS_CONFIGURATION_DEFAULT = "false";
@@ -375,7 +375,7 @@ public class Configuration {
protected static final long SERVER_HRC_STATUS_SUMMARY_CACHE_SIZE_DEFAULT = 10000L;
protected static final long SERVER_HRC_STATUS_SUMMARY_CACHE_EXPIRY_DURATION_DEFAULT = 30; //minutes
- private static final String CUSTOM_ACTION_DEFINITION_DEF_VALUE = "/var/lib/ambari-server/resources/custom_action_definitions";
+ private static final String CUSTOM_ACTION_DEFINITION_DEF_VALUE = AmbariPath.getPath("/var/lib/ambari-server/resources/custom_action_definitions");
private static final long SERVER_EC_CACHE_SIZE_DEFAULT = 10000L;
private static final String SERVER_STALE_CONFIG_CACHE_ENABLED_DEFAULT = "true";
@@ -393,8 +393,8 @@ public class Configuration {
private static final String SRVR_DISABLED_CIPHERS_DEFAULT = "";
private static final String SRVR_DISABLED_PROTOCOLS_DEFAULT = "";
private static final String PASSPHRASE_ENV_DEFAULT = "AMBARI_PASSPHRASE";
- private static final String RESOURCES_DIR_DEFAULT = "/var/lib/ambari-server/resources/";
- private static final String SHARED_RESOURCES_DIR_DEFAULT = "/usr/lib/ambari-server/lib/ambari_commons/resources";
+ private static final String RESOURCES_DIR_DEFAULT = AmbariPath.getPath("/var/lib/ambari-server/resources/");
+ private static final String SHARED_RESOURCES_DIR_DEFAULT = AmbariPath.getPath("/usr/lib/ambari-server/lib/ambari_commons/resources");
private static final String ANONYMOUS_AUDIT_NAME_KEY = "anonymous.audit.name";
private static final int CLIENT_API_PORT_DEFAULT = 8080;
@@ -996,7 +996,7 @@ public class Configuration {
public String getBootSetupAgentScript() {
return properties.getProperty(BOOTSTRAP_SETUP_AGENT_SCRIPT,
- "/usr/lib/python2.6/site-packages/ambari_server/setupAgent.py");
+ AmbariPath.getPath("/usr/lib/python2.6/site-packages/ambari_server/setupAgent.py"));
}
public String getBootSetupAgentPassword() {
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
index ad4a59b..4695990 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/AmbariServer.java
@@ -29,6 +29,7 @@ import com.google.inject.Singleton;
import com.google.inject.name.Named;
import com.google.inject.persist.Transactional;
import com.sun.jersey.spi.container.servlet.ServletContainer;
+
import org.apache.ambari.eventdb.webservice.WorkflowJsonService;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.StateRecoveryManager;
@@ -103,6 +104,7 @@ import org.apache.ambari.server.topology.BlueprintFactory;
import org.apache.ambari.server.topology.SecurityConfigurationFactory;
import org.apache.ambari.server.topology.TopologyManager;
import org.apache.ambari.server.topology.TopologyRequestFactoryImpl;
+import org.apache.ambari.server.utils.AmbariPath;
import org.apache.ambari.server.utils.RetryHelper;
import org.apache.ambari.server.utils.StageUtils;
import org.apache.ambari.server.utils.VersionUtils;
@@ -137,6 +139,7 @@ import org.springframework.web.filter.DelegatingFilterProxy;
import javax.crypto.BadPaddingException;
import javax.servlet.DispatcherType;
+
import java.io.File;
import java.io.IOException;
import java.net.Authenticator;
@@ -166,8 +169,7 @@ public class AmbariServer {
private static final String CLASSPATH_CHECK_CLASS = "org/apache/ambari/server/controller/AmbariServer.class";
private static final String CLASSPATH_SANITY_CHECK_FAILURE_MESSAGE = "%s class is found in multiple jar files. Possible reasons include multiple ambari server jar files in the ambari classpath.\n" +
- "Check for additional ambari server jar files and check that /usr/lib/ambari-server/ambari-server*.jar matches only one file.";
-
+ String.format("Check for additional ambari server jar files and check that %s matches only one file.", AmbariPath.getPath("/usr/lib/ambari-server/ambari-server*.jar"));
static {
Enumeration<URL> ambariServerClassUrls;
try {
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
index 19056fa..6c52cf4 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/security/encryption/MasterKeyServiceImpl.java
@@ -20,6 +20,7 @@ package org.apache.ambari.server.security.encryption;
import org.apache.ambari.server.AmbariException;
import org.apache.ambari.server.configuration.Configuration;
+import org.apache.ambari.server.utils.AmbariPath;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
@@ -104,7 +105,7 @@ public class MasterKeyServiceImpl implements MasterKeyService {
public static void main(String args[]) {
String masterKey = "ThisissomeSecretPassPhrasse";
- String masterKeyLocation = "/var/lib/ambari-server/keys/master";
+ String masterKeyLocation = AmbariPath.getPath("/var/lib/ambari-server/keys/master");
boolean persistMasterKey = false;
if (args != null && args.length > 0) {
masterKey = args[0];
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/java/org/apache/ambari/server/utils/AmbariPath.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/utils/AmbariPath.java b/ambari-server/src/main/java/org/apache/ambari/server/utils/AmbariPath.java
new file mode 100644
index 0000000..d73226d
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/utils/AmbariPath.java
@@ -0,0 +1,39 @@
+/*
+ * 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
+ * regarding 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.
+ */
+
+package org.apache.ambari.server.utils;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class AmbariPath {
+ private static Logger LOG = LoggerFactory.getLogger(AmbariPath.class);
+
+ public static final String AMBARI_SERVER_ROOT_ENV_VARIABLE = "ROOT";
+ public static final String rootDirectory = System.getenv(AMBARI_SERVER_ROOT_ENV_VARIABLE);
+
+ public static String getPath(String path) {
+ if(rootDirectory == null) {
+ LOG.warn("Cannot get $ROOT enviroment varaible. Installed to custom root directory Ambari might not work correctly.");
+ return path;
+ }
+ String result = (rootDirectory + path).replaceAll("/+","/");
+ LOG.info(result);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/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 886e4fc..9546009 100644
--- a/ambari-server/src/main/package/deb/control/postinst
+++ b/ambari-server/src/main/package/deb/control/postinst
@@ -16,7 +16,7 @@
# Warning: don't add changes to this script directly, please add changes to install-helper.sh.
-INSTALL_HELPER="${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/install-helper.sh"
+INSTALL_HELPER="${RPM_INSTALL_PREFIX}/var/lib/ambari-server/install-helper.sh"
if [ "$1" == "configure" ] ; then
if [ -f "$INSTALL_HELPER" ]; then
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/package/deb/control/preinst
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/deb/control/preinst b/ambari-server/src/main/package/deb/control/preinst
index 9dcd8bf..eb94f95 100644
--- a/ambari-server/src/main/package/deb/control/preinst
+++ b/ambari-server/src/main/package/deb/control/preinst
@@ -14,26 +14,28 @@
# See the License for the specific language governing permissions and
# limitations under the License
-STACKS_FOLDER="${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/resources/stacks"
-STACKS_FOLDER_OLD=${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/resources/stacks_$(date '+%d_%m_%y_%H_%M').old
+ROOT="${RPM_INSTALL_PREFIX}"
-COMMON_SERVICES_FOLDER="${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/resources/common-services"
-COMMON_SERVICES_FOLDER_OLD=${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/resources/common-services_$(date '+%d_%m_%y_%H_%M').old
+STACKS_FOLDER="${ROOT}/var/lib/ambari-server/resources/stacks"
+STACKS_FOLDER_OLD=${ROOT}/var/lib/ambari-server/resources/stacks_$(date '+%d_%m_%y_%H_%M').old
-AMBARI_PROPERTIES="${AMBARI_ROOT_FOLDER}/etc/ambari-server/conf/ambari.properties"
+COMMON_SERVICES_FOLDER="${ROOT}/var/lib/ambari-server/resources/common-services"
+COMMON_SERVICES_FOLDER_OLD=${ROOT}/var/lib/ambari-server/resources/common-services_$(date '+%d_%m_%y_%H_%M').old
+
+AMBARI_PROPERTIES="${ROOT}/etc/ambari-server/conf/ambari.properties"
AMBARI_PROPERTIES_OLD="$AMBARI_PROPERTIES.rpmsave"
-AMBARI_ENV="${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/ambari-env.sh"
+AMBARI_ENV="${ROOT}/var/lib/ambari-server/ambari-env.sh"
AMBARI_ENV_OLD="$AMBARI_ENV.rpmsave"
-AMBARI_KRB_JAAS_LOGIN_FILE="${AMBARI_ROOT_FOLDER}/etc/ambari-server/conf/krb5JAASLogin.conf"
+AMBARI_KRB_JAAS_LOGIN_FILE="${ROOT}/etc/ambari-server/conf/krb5JAASLogin.conf"
AMBARI_KRB_JAAS_LOGIN_FILE_OLD="$AMBARI_KRB_JAAS_LOGIN_FILE.rpmsave"
-AMBARI_VIEWS_FOLDER="${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/resources/views"
+AMBARI_VIEWS_FOLDER="${ROOT}/var/lib/ambari-server/resources/views"
AMBARI_VIEWS_BACKUP_FOLDER="$AMBARI_VIEWS_FOLDER/backups"
-SERVER_CONF_SAVE="${AMBARI_ROOT_FOLDER}/etc/ambari-server/conf.save"
-SERVER_CONF_SAVE_BACKUP="${AMBARI_ROOT_FOLDER}/etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save"
+SERVER_CONF_SAVE="${ROOT}/etc/ambari-server/conf.save"
+SERVER_CONF_SAVE_BACKUP="${ROOT}/etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save"
if [ -d "$SERVER_CONF_SAVE" ]
then
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/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 cac2abe..b85bd3b 100644
--- a/ambari-server/src/main/package/deb/control/prerm
+++ b/ambari-server/src/main/package/deb/control/prerm
@@ -16,7 +16,7 @@
# Warning: don't add changes to this script directly, please add changes to install-helper.sh.
-INSTALL_HELPER="${AMBARI_ROOT_FOLDER}/var/lib/ambari-server/install-helper.sh"
+INSTALL_HELPER="${RPM_INSTALL_PREFIX}/var/lib/ambari-server/install-helper.sh"
if [ "$1" == "remove" ] ; then # Action is uninstall
if [ -f "$INSTALL_HELPER" ]; then
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/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 5ca1d17..1e8e0f0 100644
--- a/ambari-server/src/main/package/rpm/postinstall.sh
+++ b/ambari-server/src/main/package/rpm/postinstall.sh
@@ -15,15 +15,17 @@
# Warning: don't add changes to this script directly, please add changes to install-helper.sh.
+INSTALL_HELPER="${RPM_INSTALL_PREFIX}/var/lib/ambari-server/install-helper.sh"
+
case "$1" in
1) # Action install
- if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
- /var/lib/ambari-server/install-helper.sh install
+ if [ -f "$INSTALL_HELPER" ]; then
+ $INSTALL_HELPER install
fi
;;
2) # Action upgrade
- if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
- /var/lib/ambari-server/install-helper.sh upgrade
+ if [ -f "$INSTALL_HELPER" ]; then
+ $INSTALL_HELPER upgrade
fi
;;
esac
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/package/rpm/posttrans_server.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/rpm/posttrans_server.sh b/ambari-server/src/main/package/rpm/posttrans_server.sh
index 6df3c5d..6aa5612 100644
--- a/ambari-server/src/main/package/rpm/posttrans_server.sh
+++ b/ambari-server/src/main/package/rpm/posttrans_server.sh
@@ -14,10 +14,12 @@
# limitations under the License
-RESOURCE_MANAGEMENT_DIR="/usr/lib/python2.6/site-packages/resource_management"
-RESOURCE_MANAGEMENT_DIR_SERVER="/usr/lib/ambari-server/lib/resource_management"
-JINJA_DIR="/usr/lib/python2.6/site-packages/ambari_jinja2"
-JINJA_SERVER_DIR="/usr/lib/ambari-server/lib/ambari_jinja2"
+ROOT="${RPM_INSTALL_PREFIX}"
+
+RESOURCE_MANAGEMENT_DIR="${ROOT}/usr/lib/python2.6/site-packages/resource_management"
+RESOURCE_MANAGEMENT_DIR_SERVER="${ROOT}/usr/lib/ambari-server/lib/resource_management"
+JINJA_DIR="${ROOT}/usr/lib/python2.6/site-packages/ambari_jinja2"
+JINJA_SERVER_DIR="${ROOT}/usr/lib/ambari-server/lib/ambari_jinja2"
# remove RESOURCE_MANAGEMENT_DIR if it's a directory
if [ -d "$RESOURCE_MANAGEMENT_DIR" ]; then # resource_management dir exists
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/ambari-server/src/main/package/rpm/preinstall.sh
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/package/rpm/preinstall.sh b/ambari-server/src/main/package/rpm/preinstall.sh
index 9533964..a8e781e 100644
--- a/ambari-server/src/main/package/rpm/preinstall.sh
+++ b/ambari-server/src/main/package/rpm/preinstall.sh
@@ -13,18 +13,23 @@
# See the License for the specific language governing permissions and
# limitations under the License
-STACKS_FOLDER="/var/lib/ambari-server/resources/stacks"
-STACKS_FOLDER_OLD=/var/lib/ambari-server/resources/stacks_$(date '+%d_%m_%y_%H_%M').old
+ROOT="${RPM_INSTALL_PREFIX}"
-COMMON_SERVICES_FOLDER="/var/lib/ambari-server/resources/common-services"
-COMMON_SERVICES_FOLDER_OLD=/var/lib/ambari-server/resources/common-services_$(date '+%d_%m_%y_%H_%M').old
+STACKS_FOLDER="${ROOT}/var/lib/ambari-server/resources/stacks"
+STACKS_FOLDER_OLD="${ROOT}/var/lib/ambari-server/resources/stacks_$(date '+%d_%m_%y_%H_%M').old"
-AMBARI_VIEWS_FOLDER="/var/lib/ambari-server/resources/views"
+COMMON_SERVICES_FOLDER=${ROOT}"/var/lib/ambari-server/resources/common-services"
+COMMON_SERVICES_FOLDER_OLD="${ROOT}/var/lib/ambari-server/resources/common-services_$(date '+%d_%m_%y_%H_%M').old"
+
+AMBARI_VIEWS_FOLDER="${ROOT}/var/lib/ambari-server/resources/views"
AMBARI_VIEWS_BACKUP_FOLDER="$AMBARI_VIEWS_FOLDER/backups"
-if [ -d "/etc/ambari-server/conf.save" ]
+SERVER_CONF_SAVE="${ROOT}/etc/ambari-server/conf.save"
+SERVER_CONF_SAVE_BACKUP="${ROOT}/etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save"
+
+if [ -d "$SERVER_CONF_SAVE" ]
then
- mv /etc/ambari-server/conf.save /etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save
+ mv "$SERVER_CONF_SAVE" "$SERVER_CONF_SAVE_BACKUP"
fi
if [ -d "$STACKS_FOLDER" ]
http://git-wip-us.apache.org/repos/asf/ambari/blob/18d5a696/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 445e9ad..bd20323 100644
--- a/ambari-server/src/main/package/rpm/preremove.sh
+++ b/ambari-server/src/main/package/rpm/preremove.sh
@@ -19,9 +19,11 @@
# Warning: don't add changes to this script directly, please add changes to install-helper.sh.
+INSTALL_HELPER="${RPM_INSTALL_PREFIX}/var/lib/ambari-server/install-helper.sh"
+
if [ "$1" -eq 0 ]; then # Action is uninstall
- if [ -f "/var/lib/ambari-server/install-helper.sh" ]; then
- /var/lib/ambari-server/install-helper.sh remove
+ if [ -f "$INSTALL_HELPER" ]; then
+ $INSTALL_HELPER remove
fi
fi