changeset 7:14282b595c1d

Cygwin/Windows compatibility for thermostat-ng.sh This patch adds Cygwin/Windows compatibility to thermostat-ng.sh. Reviewed-by: sgehwolf Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-July/024312.html
author Simon Tooke <stooke@redhat.com>
date Wed, 26 Jul 2017 10:14:23 -0400
parents 0a17affdae81
children 38d958535be1
files thermostat-ng.sh
diffstat 1 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/thermostat-ng.sh	Fri Jul 21 18:01:22 2017 +0200
+++ b/thermostat-ng.sh	Wed Jul 26 10:14:23 2017 -0400
@@ -78,8 +78,12 @@
     start)
       ;& # fall-through
     stop)
-      $WEB_GATEWAY_ROOT/distribution/target/image/bin/thermostat-mongodb.sh $action
-      check_success_msg $? "Failed to $action mongodb."
+      if [ $CYGWIN_MODE == 1 ] ; then
+        $WEB_GATEWAY_ROOT/distribution/target/image/bin/thermostat-mongodb.sh $action &
+      else
+        $WEB_GATEWAY_ROOT/distribution/target/image/bin/thermostat-mongodb.sh $action
+        check_success_msg $? "Failed to $action mongodb."
+      fi
       ;;
     *)
       fail "Unknown action '$action'"
@@ -206,7 +210,12 @@
   fi
   echo "username=foo-agent-user" >> $agent_conf
   echo "password=agent-pwd" >> $agent_conf
-  cp $AGENT_ROOT/distribution/target/image/etc/examples/ssl.properties.example $AGENT_ROOT/distribution/target/image/etc/ssl.properties
+  ## convert Windows backslashes in paths to '/'
+  if [ $CYGWIN_MODE == 0 ] ; then
+    cp $AGENT_ROOT/distribution/target/image/etc/examples/ssl.properties.example $AGENT_ROOT/distribution/target/image/etc/ssl.properties
+  else
+   sed sX\\\\X/Xg $AGENT_ROOT/distribution/target/image/etc/examples/ssl.properties.example >$AGENT_ROOT/distribution/target/image/etc/ssl.properties
+  fi 
 }
 
 
@@ -252,6 +261,19 @@
   done
 }
 
+# set global variable for Cygwin testing
+# between all shell files, we pass cygwin-compatible paths,
+#    and let each script decide when to convert them.
+# an exception is command line args for java programs, which
+#    need to be converted to windows format at creation time
+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
+
 TOP_DIR="$(script_directory)"
 WEB_GATEWAY_ROOT="${TOP_DIR}/web-gateway"
 AGENT_ROOT="${TOP_DIR}/agent"