Browse Source

Fixed argument passing to unix runtime.

master
MagicBot 2 years ago
parent
commit
d4d24c9443
  1. 12
      src/discord/handlers/DevRequestHandler.java

12
src/discord/handlers/DevRequestHandler.java

@ -19,7 +19,7 @@ public class DevRequestHandler {
public static void handleRequest(MessageReceivedEvent event, String[] args) { public static void handleRequest(MessageReceivedEvent event, String[] args) {
String serverCommand; String serverCommand;
String buildTarget = ""; String commandArgument = "";
String execString = ""; String execString = "";
// Early exit if database unavailable or is not an admin // Early exit if database unavailable or is not an admin
@ -35,12 +35,12 @@ public class DevRequestHandler {
serverCommand = args[0].toLowerCase().trim(); serverCommand = args[0].toLowerCase().trim();
if (args.length == 2) if (args.length == 2)
buildTarget = args[1].toLowerCase().trim(); commandArgument = args[1].toLowerCase().trim();
switch (serverCommand) { switch (serverCommand) {
case "build" : case "build" :
execString = "/bin/sh -c ./mbdevbuild.sh " + buildTarget; execString = "/bin/sh -c ./mbdevbuild.sh ";
break; break;
case "restart": case "restart":
execString = "/bin/sh -c ./mbdevrestart.sh"; execString = "/bin/sh -c ./mbdevrestart.sh";
@ -57,12 +57,12 @@ public class DevRequestHandler {
if (execString.isEmpty() == false) { if (execString.isEmpty() == false) {
try { try {
Runtime.getRuntime().exec(execString); Runtime.getRuntime().exec(new String[]{execString, commandArgument});
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
MagicBot.sendResponse(event, "Executed on dev: " + serverCommand + " " + buildTarget); MagicBot.sendResponse(event, "Executed on dev: " + serverCommand + " " + commandArgument);
Logger.info(event.getAuthor().getName() + " told dev to " + serverCommand + " " + buildTarget); Logger.info(event.getAuthor().getName() + " told dev to " + serverCommand + " " + commandArgument);
} }
} }
} }
Loading…
Cancel
Save