Mercurial > hg > thermostat-ng > agent
changeset 2469:cc3ad789a580
Windows: add cmd files, stub keyring, fix mongo invocation
Adding Windows batch files to (thermostat)/bin (on Windows only,
shell scripts stay for Cygwin compatibility
Keyring stub on Windows (not building windows native code)
Small fixes to setup code for Windows
Reviewed-by: neugens
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2016-October/021172.html
line wrap: on
line diff
--- a/distribution/pom.xml Fri Sep 30 11:20:00 2016 -0400 +++ b/distribution/pom.xml Tue Oct 04 10:09:17 2016 -0700 @@ -175,7 +175,31 @@ </execution> </executions> </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy-windows-scripts</id> + <phase>prepare-package</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${project.build.directory}</outputDirectory> + <resources> + <resource> + <directory>windows/scripts</directory> + <targetPath>image/bin</targetPath> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <executions> @@ -184,11 +208,16 @@ <goals> <goal>exec</goal> </goals> + <configuration> + <!-- the script itself has the wrong permissions, but using cmd.exe works properly --> + <executable>cmd.exe</executable> + <arguments> + <argument>/c</argument> + <argument>${project.basedir}/tools/verify-bash-completion.cmd</argument> + </arguments> + </configuration> </execution> </executions> - <configuration> - <executable>${project.basedir}/tools/verify-bash-completion.cmd</executable> - </configuration> </plugin> </plugins> </build>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-agent-proxy.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,41 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal + +%~dp0\thermostat-common.cmd + +echo thermostat-agent-proxy not implemented on Windows.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-agent-syd.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,41 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal + +%~dp0\thermostat-common.cmd + +echo thermostat-agent-syd not implemented on Windows.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-command-channel.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,93 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and\or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal + +if "%3"=="" goto usage +if not "%4"=="" goto usage + +goto skipfuncdefs + +:usage + echo "usage: %~f0 <hostname> <port> <ipcConfigFile>" + exit /b 1 + +:skipfuncdefs + +set HOSTNAME=%1 +set PORT=%2 +set CONFIG_FILE=%3 + +:: Source thermostat-ipc-client-common from same directory as this script +:: Defines IPC_CLASSPATH variable with JARs necessary for the IPC service + +call %~dp0\thermostat-ipc-client-common.cmd +if not "%errorlevel%"=="0" exit /b %errorlevel% + +:: Ensure thermostat-ipc-client-common sourced correctly +if not defined IPC_CLASSPATH ( + echo "Classpath not properly defined for command channel" + exit /b 1 +) + +:: Additional JARs necessary for the server +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-common-core-@project.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-shared-config-@project.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-command-@project.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-common-command-@project.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-command-server-@project.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\netty-buffer-@netty.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\netty-common-@netty.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\netty-transport-@netty.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\netty-codec-@netty.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\netty-handler-@netty.version@.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\gson-@gson.version@.jar + +set CMD_CHANNEL_CLASS=com.redhat.thermostat.agent.command.server.internal.CommandChannelServerMain + +:: Set this to remote debug +if defined THERMOSTAT_CMDC_DEBUG ( + set DEBUG_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,quiet=y,address=1083 +) + + +:: Start server + +set CONFIG_FILE_ARG=-DipcConfigFile=%CONFIG_FILE% +%JAVA% %CONFIG_FILE_ARG% %LOGGING_ARGS% -cp %IPC_CLASSPATH% %DEBUG_OPTS% %CMD_CHANNEL_CLASS% %HOSTNAME% %PORT% + + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-common.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,80 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +set THERMOSTAT_HOME=%~dp0.. +set THERMOSTAT_LIBS=%THERMOSTAT_HOME%\libs +set USER_THERMOSTAT_HOME=%USERPROFILE%\.thermostat + +:: Duplicated in ThermostatVmMainLabelDecorator +set THERMOSTAT_MAIN=com.redhat.thermostat.main.Thermostat + +if not defined JAVA_HOME ( + set jdk_home_candidate="@thermostat.jdk.home@" + if exist %jdk_home_candidate%\bin\javac.exe ( + set JAVA_HOME=%jdk_home_candidate% + ) else ( + :: Got likely a JRE, but thermostat expects a full JDK, try + :: one level up and hope this will work. We check + :: if JAVA_HOME is a valid value below. + set JAVA_HOME=%jdk_home_candidate%\.. + ) +) + +if exist %THERMOSTAT_HOME%\etc\thermostatrc.cmd call %THERMOSTAT_HOME%\etc\thermostatrc.cmd +if exist %USER_THERMOSTAT_HOME%\etc\thermostatrc.cmd call %USER_THERMOSTAT_HOME%\etc\thermostatrc.cmd + +:: Verify that JAVA_HOME is a real JDK +if not exist %JAVA_HOME%\bin\javac.exe ( + echo JAVA_HOME does not seem to be a JDK. Thermostat needs a JDK to run. + echo JAVA_HOME was set to '%JAVA_HOME%' + exit /b 2 +) + +set JAVA=%JAVA_HOME%\bin\java + +set SYSTEM_LOG_CONFIG_FILE=%THERMOSTAT_HOME%\etc\logging.properties +if exist %SYSTEM_LOG_CONFIG_FILE% ( + set LOGGING_ARGS=-Djava.util.logging.config.file=%SYSTEM_LOG_CONFIG_FILE% +) + +set USER_LOG_CONFIG_FILE=%USER_THERMOSTAT_HOME%\etc\logging.properties +if exist %USER_LOG_CONFIG_FILE% ( + set LOGGING_ARGS=-Djava.util.logging.config.file=%USER_LOG_CONFIG_FILE% +) + +set LOGGING_ARGS=%LOGGING_ARGS% -Djline.log.jul=true + +exit /b 0 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-debug.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,41 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal + +%~dp0\thermostat-common.cmd + +echo thermostat-debug not implemented on Windows.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-devsetup.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,41 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal + +%~dp0\thermostat-common.cmd + +echo thermostat-devsetup not implemented on Windows.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-ipc-client-common.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,69 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and\or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http:\\www.gnu.org\licenses\>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +rem setlocal + +call %~dp0\thermostat-common.cmd + +rem endlocal & ( set THERMOSTAT_LIBS=%THERMOSTAT_LIBS% ) + +rem Build classpath shared by all IPC clients + +set IPC_CLASSPATH=%THERMOSTAT_LIBS%\thermostat-agent-ipc-client-%project.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-ipc-common-%project.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-ipc-unixsocket-client-%project.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-ipc-unixsocket-common-%project.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-ipc-tcpsocket-client-%project.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\thermostat-agent-ipc-tcpsocket-common-%project.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jnr-unixsocket-%jnr-unixsocket.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jnr-enxio-%jnr-enxio.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jnr-constants-%jnr-constants.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jnr-posix-%jnr-posix.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jnr-ffi-%jnr-ffi.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jnr-x86asm-%jnr-x86asm.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jffi-%jffi.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\jffi-%jffi.version%-native.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\asm-%asm.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\asm-commons-%asm.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\asm-util-%asm.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\asm-analysis-%asm.version%.jar +set IPC_CLASSPATH=%IPC_CLASSPATH%:%THERMOSTAT_LIBS%\asm-tree-%asm.version%.jar + +rem set THERMOSTAT_LIBS= + +echo %IPC_CLASSPATH% + +exit /b 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat-webservice.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,221 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal + +%~dp0\thermostat-common.cmd + +echo thermostat-webservice not implemented on Windows. + +set TOMCAT_DIR=tomcat + +process_args() { + while [ $# -gt 0 ]; do + THIS_ARG=$1 + shift + if [ $THIS_ARG = "-h" -o $THIS_ARG = "--help" -o $THIS_ARG = "help" ] ; then + do_help + exit + break + elif [ $THIS_ARG = "-t" ] ; then + TOMCAT_DIR=$1 + shift + elif [ $THIS_ARG = "start" -o $THIS_ARG = "stop" ] ; then + FUNCTION=$THIS_ARG + else + echo "Unrecognized argument: $THIS_ARG" + exit 1 + fi + done + check_valid_args +} + +do_start() { + rm -rf webapps/thermostat + cp -r "$TH/web/war/target/thermostat-web-war-@project.version@" webapps/thermostat + if [ $CYGWIN_MODE -eq 1 ]; then + JAVA_OPTS="-Djava.security.auth.login.config=`cygpath -w ${TH}/distribution/target/image/etc/thermostat_jaas.conf`" ./bin/startup.sh + else + JAVA_OPTS="-Djava.security.auth.login.config=${TH}/distribution/target/image/etc/thermostat_jaas.conf" ./bin/startup.sh + fi +} + +do_stop() { + ./bin/shutdown.sh +} + +do_function() { + TH="$(pwd)" + cd %TOMCAT_DIR% + case $1 in + start ) + do_start + ;; + stop ) + do_stop + ;; + esac + cd ${TH} +} + +process_args $* +do_function $FUNCTION + +:: Please be familiar with these privileges to decide whether this +:: set of users and roles is appropriate for you or your testing. +:: +:: TH="$(pwd)" +:: cd path/to/tomcat +:: rm -rf webapps/thermostat +:: cp -r $TH/web/war/target/thermostat-web-war-0.16.0-SNAPSHOT webapps/thermostat +:: export JAVA_OPTS="-Djava.security.auth.login.config=${TH}/distribution/target/image/etc/thermostat_jaas.conf" +:: ./bin/startup.sh +:: cd $TH +:: ./distribution/target/image/bin/thermostat storage --start +:: mkdir -p ~/.thermostat/etc +:: echo -e "username=agent-tester\npassword=tester" > ~/.thermostat/etc/agent.auth +:: ./distribution/target/image/bin/thermostat agent -d http://127.0.0.1:8080/thermostat/storage + + +rem functions + +:usage + echo Usage: + echo thermostat-webservice [-t <root of tomcat directory>] <start|stop> + exit /b 0 + + +:check_valid_args + if "x%FUNCTION%" = "x" ( + echo "You must specify either start, stop, or help." + call usage + exit /b 1 + ) + if not exist %TOMCAT_DIR% ( + echo "Tomcat directory does not exist: %TOMCAT_DIR%" + call usage + exit /b 1 + fi + exit /b 0 + + +print_help: +echo thermostat-webservice: A convenience script for starting and stopping +echo tomcat with thermostat web storage application deployed. +echo +echo This script is intended to be an aid for developers to start up +echo tomcat and deploy thermostat web storage app. It is assumed that +echo there is already a backing storage running that the web app can +echo connect to, and that the web.xml file from the build image is +echo correctly configured for this backing storage connection. See +echo the file: +echo +echo web/war/target/thermostat-web-war-0.16.0-SNAPSHOT/WEB-INF/web.xml +echo +echo In addition, an appropriate user and role configuration must be +echo present in the build image. See the files: +echo +echo distribution/target/image/etc/thermostat-users.properties +echo distribution/target/image/etc/thermostat-roles.properties +echo +echo An agent requires authentication configuration in order to connect +echo to secured storage. See the file: +echo +echo ~/.thermostat/etc/agent.auth +echo +echo Possible contents of thermostat-users.properties: +echo +echo agent-tester=tester +echo client-tester=tester +echo +echo Corresponding potential thermostat-roles.properties: +echo +echo agent-tester=thermostat-agent, thermostat-files-grant-write-filename-ALL +echo client-tester=thermostat-client, thermostat-cmdc-allPrivs, \\ +echo thermostat-files-grant-read-filename-ALL +echo thermostat-agent=thermostat-write, thermostat-prepare-statement, \\ +echo thermostat-save-file, thermostat-purge, \\ +echo thermostat-register-category, thermostat-cmdc-verify, \\ +echo thermostat-login, thermostat-realm +echo thermostat-client=thermostat-agents-grant-read-agentId-ALL, \\ +echo thermostat-hosts-grant-read-hostname-ALL, \\ +echo thermostat-vms-grant-read-vmId-ALL, \\ +echo thermostat-vms-grant-read-username-ALL, thermostat-realm, \\ +echo thermostat-login, thermostat-query, \\ +echo thermostat-prepare-statement, thermostat-cmdc-generate, \\ +echo thermostat-load-file, thermostat-get-count, \\ +echo thermostat-register-category +echo thermostat-cmdc-allPrivs = thermostat-cmdc-grant-garbage-collect, \\ +echo thermostat-cmdc-grant-dump-heap, \\ +echo thermostat-cmdc-grant-thread-harvester, \\ +echo thermostat-cmdc-grant-killvm, \\ +echo thermostat-cmdc-grant-ping, \\ +echo thermostat-cmdc-grant-jmx-toggle-notifications +echo +echo Please be familiar with these privileges to decide whether this +echo set of users and roles is appropriate for you or your testing. +echo +echo Contents of ~\.thermostat\etc\agent.auth that would be valid with the above: +echo +echo username=agent-tester +echo password=tester +echo +echo Here is typical use of this script: +echo +echo $ echo %USER_FLUFF% > distribution\target\image\etc\thermostat-users.properties +echo $ echo %ROLE_FLUFF% > distribution\target\image\etc\thermostat-roles.properties +echo $ echo %AGENT_FLUFF% > ~\.thermostat\etc\agent.auth +echo $ .\distribution\target\image\bin\thermostat storage --start +echo $ .\distribution\target\image\bin\thermostat-webservice -t \path\to\tomcat start +echo $ .\distribution\target\image\bin\thermostat agent -d http:/127.0.0.1:8080/thermostat/storage +echo $ .\distribution\target\image\bin\thermostat gui +echo +echo ... and so forth. +echo +echo .\distribution\target\image\bin\thermostat-webservice -t \path\to\tomcat stop +echo .\distribution\target\image\bin\thermostat storage --stop +echo +echo NOTE: Use of this script to start tomcat will blow away webapps/thermostat +echo in your tomcat directory and replace it with the corresponding contents +echo from your build image. +echo +echo NOTE2: If tomcat is already running, results of this script are undefined. +echo +echo . + +:done +exit /b 0 +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/distribution/windows/scripts/thermostat.cmd Tue Oct 04 10:09:17 2016 -0700 @@ -0,0 +1,150 @@ +@echo off + +:: Copyright 2016 Red Hat, Inc. +:: +:: This file is part of Thermostat. +:: +:: Thermostat is free software; you can redistribute it and/or modify +:: it under the terms of the GNU General Public License as published +:: by the Free Software Foundation; either version 2, or (at your +:: option) any later version. +:: +:: Thermostat is distributed in the hope that it will be useful, but +:: WITHOUT ANY WARRANTY; without even the implied warranty of +:: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +:: General Public License for more details. +:: +:: You should have received a copy of the GNU General Public License +:: along with Thermostat; see the file COPYING. If not see +:: <http://www.gnu.org/licenses/>. +:: +:: Linking this code with other modules is making a combined work +:: based on this code. Thus, the terms and conditions of the GNU +:: General Public License cover the whole combination. +:: +:: As a special exception, the copyright holders of this code give +:: you permission to link this code with independent modules to +:: produce an executable, regardless of the license terms of these +:: independent modules, and to copy and distribute the resulting +:: executable under terms of your choice, provided that you also +:: meet, for each linked independent module, the terms and conditions +:: of the license of that module. An independent module is a module +:: which is not derived from or based on this code. If you modify +:: this code, you may extend this exception to your version of the +:: library, but you are not obligated to do so. If you do not wish +:: to do so, delete this exception statement from your version. + +setlocal +setlocal EnableDelayedExpansion +set retval=0 + +call %~dp0\thermostat-common.cmd +if not "%errorlevel%"=="0" exit /b %errorlevel% + +:: //////////////////////////////////////////////////////////////////// + +:: NOTE: The following variables come from the system/user +:: profiles (if any) +:: +:: THERMOSTAT_EXT_BOOT_CLASSPATH +:: THERMOSTAT_EXT_JAVA_OPTS +:: THERMOSTAT_EXT_OPTS + +:: This is the minimal boot classpath thermostat needs. Other dependencies +:: will get started by the OSGi framework once that's up. +set BOOT_CLASSPATH=%THERMOSTAT_LIBS%\org.apache.felix.framework-@felix.framework.version@.jar +set BOOT_CLASSPATH=%BOOT_CLASSPATH%;%THERMOSTAT_LIBS%\thermostat-launcher-@project.version@.jar +set BOOT_CLASSPATH=%BOOT_CLASSPATH%;%THERMOSTAT_LIBS%\thermostat-main-@project.version@.jar +set BOOT_CLASSPATH=%BOOT_CLASSPATH%;%THERMOSTAT_LIBS%\thermostat-shared-config-@project.version@.jar + +goto skip_setclasspath +set BOOT_CLASSPATH= +for %%f in (%THERMOSTAT_LIBS%\*.jar) do ( + rem echo jar file %%f + set BOOT_CLASSPATH=!BOOT_CLASSPATH!;%f +) +:skip_setclasspath + +goto foo +echo on +set WANTED_JARS=org.apache.felix.framework- thermostat-launcher- thermostat-main- thermostat-shared-config- +set BOOT_CLASSPATH= +for %%j in (%WANTED_JARS%) do ( + rem echo jar file %%j + for %%f in (%THERMOSTAT_LIBS%\%%j*.jar) do ( + rem echo found file %f + set BOOT_CLASSPATH=!BOOT_CLASSPATH!;%f + ) +) +echo off +:foo + +echo off +set WANTED_JARS=org.apache.felix.framework-4.2.0.jar thermostat-launcher-1.99.12-SNAPSHOT.jar thermostat-main-1.99.12-SNAPSHOT.jar thermostat-shared-config-1.99.12-SNAPSHOT.jar +set BOOT_CLASSPATH=. +for %%j in (%WANTED_JARS%) do ( + rem echo jar file %%j + set BOOT_CLASSPATH=!BOOT_CLASSPATH!;%THERMOSTAT_LIBS%\%%j +) + +:: Append extra class path entries coming from the profiles +if defined THERMOSTAT_EXT_BOOT_CLASSPATH ( + set BOOT_CLASSPATH=%BOOT_CLASSPATH%;%THERMOSTAT_EXT_BOOT_CLASSPATH% +) + +goto skip1 +:usage + echo %~n0 "[-J<java-opt>] [-Tbg PIDFILE] [THERMOSTAT_ARGS]" + exit /b 1 +:skip1 + +:: start parsing arguments, we intercept jvm arguments vs thermostat specific arguments +::echo Thermostat for Windows + +set JVM_ARGS= +set CMD_ARGS= +set RUN_IN_BG=0 +set PID_FILE="" + +:cmdloop +if not x%1==x ( + if "x%1"=="x-Tbg" ( + shift + set RUN_IN_BG=1 + set PID_FILE=%1 + goto argparsed + ) + if "-J"=="%1:~0,2%" ( + set JVM_ARGS=!JAVA_ARGS! %1:~2% + goto argparsed + ) + set CMD_ARGS=%CMD_ARGS% %1 +:argparsed + shift + goto cmdloop +) + +:: in a VM, jline can cause 100 CPU usage on Windows without this +set THERMOSTAT_EXT_JAVA_OPTS=%THERMOSTAT_EXT_JAVA_OPTS% -Djline.terminal=jline.UnsupportedTerminal + +:: Finally run thermostat (optionally in the background +if "%RUN_IN_BG%"=="1" ( + :: The thermostat-agent-sysd script uses this. + if not defined PID_FILE ( + echo "PID_FILE must be defined" + exit /b 1 + ) else ( + start "%JAVA%" %THERMOSTAT_EXT_JAVA_OPTS% %LOGGING_ARGS% "%JVM_ARGS%" -cp "%BOOT_CLASSPATH%" %THERMOSTAT_MAIN% %THERMOSTAT_EXT_OPTS% %CMD_ARGS% + set retval=%ERRORLEVEL% + rem TODO echo thejavapid to a PID_FILE + ) +) else ( + %JAVA% %THERMOSTAT_EXT_JAVA_OPTS% %LOGGING_ARGS% %JVM_ARGS% -cp %BOOT_CLASSPATH% %THERMOSTAT_MAIN% %THERMOSTAT_EXT_OPTS% %CMD_ARGS% + set retval=%ERRORLEVEL% +) +endlocal + +exit /b %retval% + + +
--- a/keyring/pom.xml Fri Sep 30 11:20:00 2016 -0400 +++ b/keyring/pom.xml Tue Oct 04 10:09:17 2016 -0700 @@ -48,6 +48,75 @@ <packaging>bundle</packaging> <name>Thermostat Keyring API</name> + <profiles> + <profile> + <id>linux</id> + <activation> + <os><family>Unix</family></os> + </activation> + <properties> + <script.extension>.sh</script.extension> + <c.compiler>gcc</c.compiler> + <cflags></cflags> + <jni.platform>linux</jni.platform> + <sharedlib.prefix>lib</sharedlib.prefix> + <sharedlib.suffix>.so</sharedlib.suffix> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <executions> + <execution> + <id>id1</id> + <phase>compile</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>autoreconf</executable> + <arguments> + <argument>--install</argument> + </arguments> + </configuration> + </execution> + <execution> + <id>id2</id> + <phase>compile</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>./configure</executable> + </configuration> + </execution> + <execution> + <id>id3</id> + <phase>compile</phase> + <goals> + <goal>exec</goal> + </goals> + <configuration> + <executable>make</executable> + <arguments> + <argument>all</argument> + </arguments> + <systemProperties> + <systemProperty> + <key>JAVA_HOME</key> + <value>${java.home}</value> + </systemProperty> + </systemProperties> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + <build> <plugins> <plugin> @@ -80,54 +149,6 @@ </configuration> </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>exec-maven-plugin</artifactId> - <executions> - <execution> - <id>id1</id> - <phase>compile</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>autoreconf</executable> - <arguments> - <argument>--install</argument> - </arguments> - </configuration> - </execution> - <execution> - <id>id2</id> - <phase>compile</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>./configure</executable> - </configuration> - </execution> - <execution> - <id>id3</id> - <phase>compile</phase> - <goals> - <goal>exec</goal> - </goals> - <configuration> - <executable>make</executable> - <arguments> - <argument>all</argument> - </arguments> - <systemProperties> - <systemProperty> - <key>JAVA_HOME</key> - <value>${java.home}</value> - </systemProperty> - </systemProperties> - </configuration> - </execution> - </executions> - </plugin> </plugins> <pluginManagement> <plugins>
--- a/pom.xml Fri Sep 30 11:20:00 2016 -0400 +++ b/pom.xml Tue Oct 04 10:09:17 2016 -0700 @@ -343,7 +343,6 @@ <module>common</module> <module>agent</module> <module>client</module> - <module>keyring</module> <module>process-handler</module> <module>thread</module> <module>killvm</module> @@ -369,6 +368,7 @@ <module>notes</module> <module>numa</module> <module>vm-numa</module> + <module>keyring</module> <module>laf-utils</module> <module>thermostat-plugin-validator</module> <module>validate-command</module>
--- a/setup/command/src/main/java/com/redhat/thermostat/setup/command/internal/model/MongodbUserSetup.java Fri Sep 30 11:20:00 2016 -0400 +++ b/setup/command/src/main/java/com/redhat/thermostat/setup/command/internal/model/MongodbUserSetup.java Tue Oct 04 10:09:17 2016 -0700 @@ -71,6 +71,8 @@ static final String[] STORAGE_START_ARGS = {"storage", "--start", "--permitLocalhostException"}; static final String[] STORAGE_STOP_ARGS = {"storage", "--stop"}; + + private static final boolean IS_UNIX = !System.getProperty("os.name").contains("Windows"); private static final String WEB_AUTH_FILE = "web.auth"; private static final String MONGO_PROCESS = "mongod"; private static final Logger logger = LoggingUtils.getLogger(MongodbUserSetup.class); @@ -246,11 +248,15 @@ stampFiles.createSetupCompleteStamp(setupTmpUnlockContent); return true; } - + + String[] getMongoRunnerCmdline( final String arg ) { + return IS_UNIX ? new String[] { "mongo", arg} : new String[] { "cmd", "/C", "mongo.exe", arg }; + } + //package-private for testing int runMongo() throws IOException, InterruptedException { logger.fine("running 'mongo 127.0.0.1:27518/thermostat' with piped input"); - ProcessBuilder mongoProcessBuilder = new ProcessBuilder("mongo", "127.0.0.1:27518/thermostat"); + ProcessBuilder mongoProcessBuilder = new ProcessBuilder(getMongoRunnerCmdline("127.0.0.1:27518/thermostat")); mongoProcessBuilder.redirectInput(Redirect.PIPE); Process process = mongoProcessBuilder.start(); ProcOutErrReader reader = new ProcOutErrReader(process);
--- a/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoOSUtilInterface.java Fri Sep 30 11:20:00 2016 -0400 +++ b/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoOSUtilInterface.java Tue Oct 04 10:09:17 2016 -0700 @@ -42,4 +42,5 @@ interface MongoOSUtilInterface { String[] getMongoStartCmd(); String[] getMongoStopCmd(); + String[] getDbVersionCmd(); }
--- a/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoProcessRunner.java Fri Sep 30 11:20:00 2016 -0400 +++ b/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoProcessRunner.java Tue Oct 04 10:09:17 2016 -0700 @@ -313,7 +313,7 @@ } private String getDBVersion() throws IOException { - Process process = new ProcessBuilder(Arrays.asList("mongod", "--version")).start(); + Process process = new ProcessBuilder(util.getDbVersionCmd()).start(); InputStream out = process.getInputStream(); return doGetDBVersion(out); }
--- a/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoUnixUtil.java Fri Sep 30 11:20:00 2016 -0400 +++ b/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoUnixUtil.java Tue Oct 04 10:09:17 2016 -0700 @@ -44,10 +44,16 @@ private static final String[] UNIX_MONGO_START_CMD = { "mongod", "--quiet", "--fork", "--auth", "--nohttpinterface", "--bind_ip" }; + private static final String[] UNIX_MONGO_STOP_CMD = { "kill", "-s", "TERM" }; + private static final String[] UNIX_MONGO_DBVERSION_CMD = { + "mongod", "--version" + }; + + @Override public String[] getMongoStartCmd() { return UNIX_MONGO_START_CMD; @@ -57,4 +63,9 @@ public String[] getMongoStopCmd() { return UNIX_MONGO_STOP_CMD; } + + @Override + public String[] getDbVersionCmd() { + return UNIX_MONGO_DBVERSION_CMD; + } }
--- a/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoWindowsUtil.java Fri Sep 30 11:20:00 2016 -0400 +++ b/storage/cli/src/main/java/com/redhat/thermostat/storage/cli/internal/MongoWindowsUtil.java Tue Oct 04 10:09:17 2016 -0700 @@ -44,10 +44,16 @@ private static final String[] WIN_MONGO_START_CMD = { "cmd", "/c", "start", "/b", "mongod", "--quiet", "--auth", "--nohttpinterface", "--bind_ip" }; + private static final String[] WIN_MONGO_STOP_CMD = { "cmd", "/c", "taskkill", "/F", "/PID" }; + private static final String[] WIN_MONGO_DBVERSION_CMD = { + "cmd", "/c", "mongod", "--version" + }; + + @Override public String[] getMongoStartCmd() { return WIN_MONGO_START_CMD; @@ -57,4 +63,9 @@ public String[] getMongoStopCmd() { return WIN_MONGO_STOP_CMD; } + + @Override + public String[] getDbVersionCmd() { + return WIN_MONGO_DBVERSION_CMD; + } } \ No newline at end of file