From: rtrimana Date: Thu, 29 Mar 2018 23:52:44 +0000 (-0700) Subject: Changing C++ slave execution into using shell file (to create context for Tomoyo). X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iot2.git;a=commitdiff_plain;h=f496921c43ee7e6d10cc6d6a709eadeed21588c5 Changing C++ slave execution into using shell file (to create context for Tomoyo). --- diff --git a/iotjava/iotruntime/master/IoTMaster.java b/iotjava/iotruntime/master/IoTMaster.java index 70ae6b8..cbcfbf3 100644 --- a/iotjava/iotruntime/master/IoTMaster.java +++ b/iotjava/iotruntime/master/IoTMaster.java @@ -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; }