changeset 150:57ee590a75c7

This patch modifies the web gateways shell scripts to be Cygwin compatible, and adds Windows command files to start uo Mongdb and web-gateway.
author Simon Tooke <stooke@redhat.com>
date Wed, 10 May 2017 21:33:41 -0400
parents 98a6b5520bf5
children c8192ee541b9
files distribution/pom.xml distribution/src/bin/thermostat-mongodb.sh distribution/src/bin/thermostat-web-gateway.sh
diffstat 3 files changed, 78 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/distribution/pom.xml	Fri Apr 28 15:20:43 2017 +0200
+++ b/distribution/pom.xml	Wed May 10 21:33:41 2017 -0400
@@ -51,6 +51,43 @@
 
     <packaging>pom</packaging>
 
+	<profiles>
+	
+	<profile>
+	  <id>windows</id>
+	  <activation>
+		<os><family>Windows</family></os>
+	  </activation>
+	  <build>
+		<plugins>
+		  <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>src/windows/bin</directory>
+					  <targetPath>image/bin</targetPath>
+					  <filtering>true</filtering>
+					</resource>
+				  </resources>
+				</configuration>
+			  </execution>
+			</executions>
+		  </plugin>
+		</plugins>
+	  </build>
+	</profile>
+
+	</profiles>
+	
     <build>
         <plugins>
             <plugin>
--- a/distribution/src/bin/thermostat-mongodb.sh	Fri Apr 28 15:20:43 2017 +0200
+++ b/distribution/src/bin/thermostat-mongodb.sh	Wed May 10 21:33:41 2017 -0400
@@ -50,6 +50,20 @@
   echo "$DIR"
 }
 
+if [ "$(uname -s | cut -b1-6)" == "CYGWIN" ]; then
+  ##echo "Running under Cygwin"
+  export CYGWIN_MODE=1
+else
+  ##echo "Running under Linux"
+  export CYGWIN_MODE=0
+fi
+
+if [ $CYGWIN_MODE -eq 1 ]; then
+  MONGO_FORK_ARG=
+else
+  MONGO_FORK_ARG=--fork
+fi
+
 if [[ "${THERMOSTAT_GATEWAY_HOME}" = "" ]]; then
   THERMOSTAT_GATEWAY_HOME="$(_find_thermostat_gateway_home)"
 fi
@@ -57,17 +71,21 @@
 IP=127.0.0.1
 PORT=27518
 
-
 DB_PATH=${THERMOSTAT_GATEWAY_HOME}/db
 DATA_PATH=${DB_PATH}/data
 JS_PATH=${THERMOSTAT_GATEWAY_HOME}/etc/mongo-dev-setup.js
 
-
 LOG_PATH=${DB_PATH}/db.log
 PID_PATH=${DB_PATH}/db.pid
 
 SETUP_PATH=${DB_PATH}/setup.stamp
 
+# on cygwin, convert to Windows format
+if [ $CYGWIN_MODE -eq 1 ]; then
+  LOG_PATH="`cygpath -w $LOG_PATH`"
+  PID_PATH="`cygpath -w $PID_PATH`"
+  DATA_PATH="`cygpath -w $DATA_PATH`"
+fi
 
 if [ -z "$1" ]; then
     echo "Usage: thermostat-mongodb.sh [start] [stop]"
@@ -78,7 +96,7 @@
     mkdir -p ${DB_PATH}
     mkdir -p ${DATA_PATH}
 
-    mongod --quiet --fork --nohttpinterface --bind_ip ${IP} --nojournal --dbpath ${DATA_PATH} --logpath ${LOG_PATH} --pidfilepath ${PID_PATH} --port ${PORT}
+    mongod --quiet ${MONGO_FORK_ARG} --nohttpinterface --bind_ip ${IP} --nojournal --dbpath ${DATA_PATH} --logpath ${LOG_PATH} --pidfilepath ${PID_PATH} --port ${PORT}
 
     if [ ! -f ${SETUP_PATH} ]; then
         sleep 3
--- a/distribution/src/bin/thermostat-web-gateway.sh	Fri Apr 28 15:20:43 2017 +0200
+++ b/distribution/src/bin/thermostat-web-gateway.sh	Wed May 10 21:33:41 2017 -0400
@@ -49,17 +49,36 @@
   echo "$DIR"
 }
 
+if [ "$(uname -s | cut -b1-6)" == "CYGWIN" ]; then
+  ##echo "Running under Cygwin"
+  export CYGWIN_MODE=1
+else
+  ##echo "Running under Linux"
+  export CYGWIN_MODE=0
+fi
+
 if [[ "${THERMOSTAT_GATEWAY_HOME}" = "" ]]; then
   THERMOSTAT_GATEWAY_HOME="$(_find_thermostat_gateway_home)"
 fi
 
+# on cygwin, convert to Windows format
+if [ $CYGWIN_MODE -eq 1 ]; then
+  THERMOSTAT_GATEWAY_HOME="`cygpath -w $THERMOSTAT_GATEWAY_HOME`"
+fi
+
 THERMOSTAT_GATEWAY_LIBS=${THERMOSTAT_GATEWAY_HOME}/libs
 
 THERMOSTAT_GATEWAY_ETC=${THERMOSTAT_GATEWAY_HOME}/etc
 
 THERMOSTAT_GATEWAY_CONFIG=${THERMOSTAT_GATEWAY_ETC}/services.properties
 
-THERMOSTAT_GATEWAY_SERVICES=${THERMOSTAT_GATEWAY_HOME}/services
+if [ $CYGWIN_MODE -eq 1 ]; then
+  THERMOSTAT_GATEWAY_SERVICES=`echo ${THERMOSTAT_GATEWAY_HOME}/services | tr \\\\ /`
+else 
+  THERMOSTAT_GATEWAY_SERVICES=`echo ${THERMOSTAT_GATEWAY_HOME}/services`
+fi
+
+echo TGS = %THERMOSTAT_GATEWAY_SERVICES%
 
 sed -i -e "s|__SERVICES__|${THERMOSTAT_GATEWAY_SERVICES}|g" ${THERMOSTAT_GATEWAY_CONFIG}