Changing C++ slave execution into using shell file (to create context for Tomoyo).
[iot2.git] / iotjava / iotruntime / master / IoTMaster.java
index 70ae6b876c9e8cd849b266a2a5032cf6dd2753ae..cbcfbf36bd4eb822508c342d2ba892650470daae 100644 (file)
@@ -939,7 +939,7 @@ public final class IoTMaster {
                String shellFile = "./" + strObjName + STR_SHELL_FILE_EXT;
                createWrapperShellScript(strJavaCommand, shellFile);
                // Send the file to the compute node
-               String strCmdSend = "scp " + shellFile + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + ":" + STR_RUNTIME_DIR;
+               String strCmdSend = STR_SCP + " " + shellFile + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + ":" + STR_RUNTIME_DIR;
                runCommand(strCmdSend);
                RuntimeOutput.print("IoTMaster: Sending shell file: " + strCmdSend, BOOL_VERBOSE);
                return STR_SSH + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + " cd " + STR_RUNTIME_DIR + " " + shellFile;
@@ -953,9 +953,16 @@ public final class IoTMaster {
         */
        private String getCmdCppDriverIoTSlave(String strIoTMasterHostAdd, String strIoTSlaveObjectHostAdd, String strObjName) {
 
-               return STR_SSH + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + " cd " +
-                                       STR_SLAVE_DIR + " sudo " + STR_IOTSLAVE_CPP + " " + strIoTMasterHostAdd + " " +
-                                       commHan.getComPort(strObjName) + " " + strObjName;
+               // Create an Shell executable
+               String strCppCommand =  STR_SHELL_HEADER + "\ncd " + STR_SLAVE_DIR + " exec sudo " + STR_IOTSLAVE_CPP + " " + 
+                           strIoTMasterHostAdd + " " + commHan.getComPort(strObjName) + " " + strObjName;
+               String shellFile = "./" + strObjName + STR_SHELL_FILE_EXT;
+               createWrapperShellScript(strCppCommand, shellFile);
+               // Send the file to the compute node
+               String strCmdSend = STR_SCP + " " + shellFile + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + ":" + STR_RUNTIME_DIR;
+               runCommand(strCmdSend);
+               RuntimeOutput.print("IoTMaster: Sending shell file: " + strCmdSend, BOOL_VERBOSE);
+               return STR_SSH + " " + STR_USERNAME + strIoTSlaveObjectHostAdd + " cd " + STR_RUNTIME_DIR + " " + shellFile;
        }
 
 
@@ -1602,7 +1609,7 @@ public final class IoTMaster {
                String shellFile = "./" + strObjControllerName + STR_SHELL_FILE_EXT;
                createWrapperShellScript(strJavaCommand, shellFile);
                // Send the file to the compute node
-               String strCmdSend = "scp " + shellFile + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + ":" + STR_RUNTIME_DIR;
+               String strCmdSend = STR_SCP + " " + shellFile + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + ":" + STR_RUNTIME_DIR;
                runCommand(strCmdSend);
                System.out.println("IoTMaster: Sending main controller shell file: " + strCmdSend);
                return STR_SSH + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + " cd " + STR_RUNTIME_DIR + " " + shellFile;
@@ -1616,9 +1623,17 @@ public final class IoTMaster {
         */
        private String getCmdCppIoTSlave(String strObjControllerName) {
 
-               return STR_SSH + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + " cd " +
-                                       STR_SLAVE_DIR + " sudo " + STR_IOTSLAVE_CPP + " " + strIoTMasterHostAdd + " " +
-                                       commHan.getComPort(strObjControllerName) + " " + strObjControllerName;
+               // Create an Shell executable
+               String strCppCommand =  STR_SHELL_HEADER + "\ncd " + STR_SLAVE_DIR + " exec sudo " + 
+                           STR_IOTSLAVE_CPP + " " + strIoTMasterHostAdd + " " +
+                                       commHan.getComPort(strObjControllerName) + " " + strObjControllerName;;
+               String shellFile = "./" + strObjControllerName + STR_SHELL_FILE_EXT;
+               createWrapperShellScript(strCppCommand, shellFile);
+               // Send the file to the compute node
+               String strCmdSend = STR_SCP + " " + shellFile + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + ":" + STR_RUNTIME_DIR;
+               runCommand(strCmdSend);
+               System.out.println("IoTMaster: Sending main controller shell file: " + strCmdSend);
+               return STR_SSH + " " + STR_USERNAME + strIoTSlaveControllerHostAdd + " cd " + STR_RUNTIME_DIR + " " + shellFile;
        }