Mercurial > hg > release > thermostat-1.6
changeset 2040:e4e0f9654a04
Make built thermostat image portable
Backport of: http://icedtea.classpath.org/hg/thermostat/rev/e635014e3559
PR3238
Reviewed-by: jerboaa
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-December/021885.html
author | Jie Kang <jkang@redhat.com> |
---|---|
date | Tue, 20 Dec 2016 15:25:58 -0500 |
parents | 89807d0b1dfe |
children | 46f5eeeb2578 |
files | README config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java distribution/pom.xml distribution/scripts/thermostat distribution/scripts/thermostat-agent-proxy distribution/scripts/thermostat-agent-sysd distribution/scripts/thermostat-debug distribution/scripts/thermostat-devsetup distribution/scripts/thermostat-setup web/server/src/main/java/com/redhat/thermostat/web/server/PropertySettingServletContextListener.java web/war/src/main/webapp/WEB-INF/web.xml |
diffstat | 11 files changed, 54 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/README Tue Dec 20 15:24:46 2016 -0500 +++ b/README Tue Dec 20 15:25:58 2016 -0500 @@ -106,13 +106,14 @@ The resulting Thermostat system can now be found under the directory distribution/target/image. - Please note that the resulting build is non-relocatable. If you move it to - some other directory, it will not work. Use the thermostat.home maven - property to set that at build time: + If you want to install thermostat to a system location, use the + thermostat.home maven property to set that at build time: mvn -Dthermostat.home=/path/to/install/thermostat - You will have to move the resulting build to the path manually. + You will have to move the resulting build to the path manually. This property + sets up mostly distribution related files (for services) that need the full + path to Thermostat. It is not required to run thermostat normally. -------------------------------------------------------------------------------- 3. RUNNING THERMOSTAT
--- a/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java Tue Dec 20 15:24:46 2016 -0500 +++ b/config/src/main/java/com/redhat/thermostat/shared/config/internal/CommonPathsImpl.java Tue Dec 20 15:25:58 2016 -0500 @@ -107,16 +107,28 @@ private CommonPathsImpl(File defaultPrefix) { CommonPathsImpl.defaultSystemUserPrefix = defaultPrefix; + + // When THERMOSTAT_HOME is fetched from env, write back the results to + // System properties too so other parts of thermostat (specially the web + // bits) make use of the right THERMOSTAT_HOME + boolean homeFetchedFromEnv = false; + // allow this to be specified also as a property, especially for // tests, this overrides the env setting String home = System.getProperty(THERMOSTAT_HOME); if (home == null) { + homeFetchedFromEnv = true; home = System.getenv(THERMOSTAT_HOME); } if (home == null) { throw new InvalidConfigurationException(t.localize(LocaleResources.SYSHOME_NO_HOME)); } + + if (homeFetchedFromEnv) { + System.setProperty(THERMOSTAT_HOME, home); + } + this.systemHome = new File(home); if (!systemHome.exists()) { throw new InvalidConfigurationException(t.localize(LocaleResources.SYSHOME_DOESNT_EXIST, home));
--- a/distribution/pom.xml Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/pom.xml Tue Dec 20 15:25:58 2016 -0500 @@ -256,6 +256,7 @@ <configuration> <target> <chmod file="${project.build.directory}/image/bin/*" perm="755" /> + <chmod file="${project.build.directory}/image/bin/thermostat-functions" perm="644" /> <chmod file="${project.build.directory}/tools/*" perm="755" /> <chmod file="${project.build.directory}/image/etc/thermostat-roles.properties" perm="600" /> <chmod file="${project.build.directory}/image/etc/thermostat-users.properties" perm="600" />
--- a/distribution/scripts/thermostat Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/scripts/thermostat Tue Dec 20 15:25:58 2016 -0500 @@ -36,8 +36,11 @@ # ##################################################################### +# Source thermostat-functions from same directory as this script +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/thermostat-functions + if [ x"${THERMOSTAT_HOME}" = x ]; then - THERMOSTAT_HOME="@thermostat.home@" + THERMOSTAT_HOME=$(_find_thermostat_home) export THERMOSTAT_HOME fi if [ x"${USER_THERMOSTAT_HOME}" = x ]; then
--- a/distribution/scripts/thermostat-agent-proxy Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/scripts/thermostat-agent-proxy Tue Dec 20 15:25:58 2016 -0500 @@ -44,8 +44,11 @@ echo "usage: $0 <pidOfTargetJvm> <userNameOfJvmOwner>" >&2 fi +# Source thermostat-functions from same directory as this script +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/thermostat-functions + if [ x"$THERMOSTAT_INSTALL_DIR" = x ] ; then - THERMOSTAT_INSTALL_DIR="@thermostat.home@" + THERMOSTAT_INSTALL_DIR=$(_find_thermostat_home) fi # Not always are installation directory and thermostat home one and # the same location.
--- a/distribution/scripts/thermostat-agent-sysd Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/scripts/thermostat-agent-sysd Tue Dec 20 15:25:58 2016 -0500 @@ -44,8 +44,11 @@ exit 1 fi +# Source thermostat-functions from same directory as this script +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/thermostat-functions + if [ x"$THERMOSTAT_HOME" = x ] ; then - THERMOSTAT_HOME="@thermostat.home@" + THERMOSTAT_HOME=$(_find_thermostat_home) fi export THERMOSTAT_HOME
--- a/distribution/scripts/thermostat-debug Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/scripts/thermostat-debug Tue Dec 20 15:25:58 2016 -0500 @@ -37,8 +37,12 @@ ##################################################################### # # Some necessary variables. + +# Source thermostat-functions from same directory as this script +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/thermostat-functions + if [ x"$THERMOSTAT_HOME" = x ] ; then - THERMOSTAT_HOME="@thermostat.home@" + THERMOSTAT_HOME=$(_find_thermostat_home) fi export THERMOSTAT_HOME
--- a/distribution/scripts/thermostat-devsetup Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/scripts/thermostat-devsetup Tue Dec 20 15:25:58 2016 -0500 @@ -43,8 +43,11 @@ # file devsetup.input and then copies an appropriate agent.auth # file into the right place. +# Source thermostat-functions from same directory as this script +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/thermostat-functions + if [ "x$THERMOSTAT_HOME" == "x" ]; then - THERMOSTAT_HOME="@thermostat.home@" + THERMOSTAT_HOME=$(_find_thermostat_home) fi THERMOSTAT_SETUP="$THERMOSTAT_HOME/bin/thermostat-setup" DEV_INPUT="$THERMOSTAT_HOME/etc/devsetup.input"
--- a/distribution/scripts/thermostat-setup Tue Dec 20 15:24:46 2016 -0500 +++ b/distribution/scripts/thermostat-setup Tue Dec 20 15:25:58 2016 -0500 @@ -35,15 +35,10 @@ # to do so, delete this exception statement from your version. # ##################################################################### -if [ x"$THERMOSTAT_INSTALL_DIR" = x ] ; then - THERMOSTAT_INSTALL_DIR="@thermostat.home@" -fi -# Not always are installation directory and thermostat home one and -# the same location. -if [ x"$THERMOSTAT_HOME" = x ] ; then - THERMOSTAT_HOME=${THERMOSTAT_INSTALL_DIR} - export THERMOSTAT_HOME -fi + +# Source thermostat-functions from same directory as this script +. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"/thermostat-functions + echo "THIS SCRIPT IS DEPRECATED! Please use 'thermostat setup -c' instead." 1>&2 # Call the thermostat non-gui version of setup ${THERMOSTAT_HOME}/bin/thermostat setup -c
--- a/web/server/src/main/java/com/redhat/thermostat/web/server/PropertySettingServletContextListener.java Tue Dec 20 15:24:46 2016 -0500 +++ b/web/server/src/main/java/com/redhat/thermostat/web/server/PropertySettingServletContextListener.java Tue Dec 20 15:25:58 2016 -0500 @@ -44,7 +44,8 @@ /** * Sets the THERMOSTAT_HOME system property as * configured via said context-param in web.xml. - * + * <p> + * Does not set THERMOSTAT_HOME if the system property is already defined. */ public class PropertySettingServletContextListener implements ServletContextListener { @@ -54,7 +55,9 @@ @Override public void contextInitialized(ServletContextEvent sce) { String thermostatHome = sce.getServletContext().getInitParameter(PROPERTY_NAME); - System.setProperty(PROPERTY_NAME, thermostatHome); + if (System.getProperty(PROPERTY_NAME) == null) { + System.setProperty(PROPERTY_NAME, thermostatHome); + } System.setProperty(Constants.IS_PROXIED_STORAGE, Boolean.TRUE.toString()); }
--- a/web/war/src/main/webapp/WEB-INF/web.xml Tue Dec 20 15:24:46 2016 -0500 +++ b/web/war/src/main/webapp/WEB-INF/web.xml Tue Dec 20 15:25:58 2016 -0500 @@ -85,7 +85,12 @@ <role-name>thermostat-realm</role-name> </security-role> - <!-- THERMOSTAT_HOME is set via the listener below --> + <!-- + The system property THERMOSTAT_HOME is set via the listener below. + This hard-coded value is only used if this war is deployed into a web + server. It is ignored if the thermostat command is used to run this war + inside an embedded server. + --> <context-param> <param-name>THERMOSTAT_HOME</param-name> <param-value>${thermostat.home}</param-value>