From df159f72fe3859a7de4add513987141f45bcc700 Mon Sep 17 00:00:00 2001 From: ME1312 Date: Mon, 14 Jan 2019 11:02:17 -0500 Subject: [PATCH] Allow different interpreters for SubCreator build scripts --- .../Host/Internal/InternalSubCreator.java | 19 +++-------------- SubServers.Creator/src/Forge/template.yml | 3 +-- SubServers.Creator/src/Spigot/template.yml | 3 +-- SubServers.Creator/src/Sponge/template.yml | 3 +-- SubServers.Creator/src/Vanilla/template.yml | 3 +-- .../Host/Executable/SubCreator.java | 21 +++---------------- 6 files changed, 10 insertions(+), 42 deletions(-) diff --git a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubCreator.java b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubCreator.java index 77f2b030..8f23ef69 100644 --- a/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubCreator.java +++ b/SubServers.Bungee/src/net/ME1312/SubServers/Bungee/Host/Internal/InternalSubCreator.java @@ -122,7 +122,7 @@ public class InternalSubCreator extends SubCreator { e.printStackTrace(); } - if (template.getBuildOptions().contains("Shell-Location")) { + if (template.getBuildOptions().contains("Executable")) { File cache; if (template.getBuildOptions().getBoolean("Use-Cache", true)) { cache = new UniversalFile(host.plugin.dir, "SubServers:Cache:Templates:" + template.getName()); @@ -132,22 +132,9 @@ public class InternalSubCreator extends SubCreator { cache = null; } - if (!System.getProperty("os.name").toLowerCase().startsWith("windows") && template.getBuildOptions().contains("Permission")) { - try { - Process process = Runtime.getRuntime().exec("chmod " + template.getBuildOptions().getRawString("Permission") + ' ' + template.getBuildOptions().getRawString("Shell-Location"), null, dir); - Thread.sleep(500); - if (process.exitValue() != 0) { - System.out.println(name + File.separator + "Creator > Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location")); - } - } catch (Exception e) { - System.out.println(name + File.separator + "Creator > Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location")); - e.printStackTrace(); - } - } - try { - System.out.println(name + File.separator + "Creator > Launching " + template.getBuildOptions().getRawString("Shell-Location")); - ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(gitBash, "bash \"" + template.getBuildOptions().getRawString("Shell-Location") + '\"')).directory(dir); + System.out.println(name + File.separator + "Creator > Launching Build Script..."); + ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(gitBash, template.getBuildOptions().getRawString("Executable"))).directory(dir); pb.environment().putAll(var); process = pb.start(); log.file = new File(dir, "SubCreator-" + template.getName() + "-" + version.toString() + ".log"); diff --git a/SubServers.Creator/src/Forge/template.yml b/SubServers.Creator/src/Forge/template.yml index e8f783fd..049ca00c 100644 --- a/SubServers.Creator/src/Forge/template.yml +++ b/SubServers.Creator/src/Forge/template.yml @@ -5,7 +5,6 @@ Template: Build: Server-Type: 'Forge' Use-Cache: false - Shell-Location: 'build.sh' - Permission: '+x' + Executable: 'bash build.sh' Settings: Executable: 'java -Xmx2048M -jar Forge.jar' \ No newline at end of file diff --git a/SubServers.Creator/src/Spigot/template.yml b/SubServers.Creator/src/Spigot/template.yml index 32bd0831..87b8cd4b 100644 --- a/SubServers.Creator/src/Spigot/template.yml +++ b/SubServers.Creator/src/Spigot/template.yml @@ -4,7 +4,6 @@ Template: Icon: 'lava_bucket' Build: Server-Type: 'Spigot' - Shell-Location: 'build.sh' - Permission: '+x' + Executable: 'bash build.sh' Settings: Executable: 'java -Xmx1024M -Dorg.bukkit.craftbukkit.libs.jline.terminal=unix -Djansi.passthrough=true -jar Spigot.jar -p $port$' \ No newline at end of file diff --git a/SubServers.Creator/src/Sponge/template.yml b/SubServers.Creator/src/Sponge/template.yml index a75c0d71..30d12ffb 100644 --- a/SubServers.Creator/src/Sponge/template.yml +++ b/SubServers.Creator/src/Sponge/template.yml @@ -5,7 +5,6 @@ Template: Build: Server-Type: 'Sponge' Use-Cache: false - Shell-Location: 'build.sh' - Permission: '+x' + Executable: 'bash build.sh' Settings: Executable: 'java -Xmx1024M -jar Sponge.jar' \ No newline at end of file diff --git a/SubServers.Creator/src/Vanilla/template.yml b/SubServers.Creator/src/Vanilla/template.yml index 0774fcae..12bc69b5 100644 --- a/SubServers.Creator/src/Vanilla/template.yml +++ b/SubServers.Creator/src/Vanilla/template.yml @@ -4,7 +4,6 @@ Template: Icon: 'bukkit:grass' Build: Server-Type: 'Vanilla' - Shell-Location: 'build.sh' - Permission: '+x' + Executable: 'bash build.sh' Settings: Executable: 'java -Xmx1024M -jar Vanilla.jar nogui' \ No newline at end of file diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubCreator.java b/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubCreator.java index e835a79e..b7f54b08 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubCreator.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/Executable/SubCreator.java @@ -280,25 +280,10 @@ public class SubCreator { cache = null; } - if (!System.getProperty("os.name").toLowerCase().startsWith("windows") && template.getBuildOptions().contains("Permission")) { - try { - Process process = Runtime.getRuntime().exec("chmod " + template.getBuildOptions().getRawString("Permission") + ' ' + template.getBuildOptions().getRawString("Shell-Location"), null, dir); - Thread.sleep(500); - if (process.exitValue() != 0) { - log.logger.info.println("Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location")); - host.subdata.sendPacket(new PacketOutExLogMessage(address, "Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location"))); - } - } catch (Exception e) { - log.logger.info.println("Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location")); - host.subdata.sendPacket(new PacketOutExLogMessage(address, "Couldn't set " + template.getBuildOptions().getRawString("Permission") + " permissions to " + template.getBuildOptions().getRawString("Shell-Location"))); - log.logger.error.println(e); - } - } - try { - log.logger.info.println("Launching " + template.getBuildOptions().getRawString("Shell-Location")); - host.subdata.sendPacket(new PacketOutExLogMessage(address, "Launching " + template.getBuildOptions().getRawString("Shell-Location"))); - ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(host.host.getRawString("Git-Bash"), "bash \"" + template.getBuildOptions().getRawString("Shell-Location") + '\"')).directory(dir); + log.logger.info.println("Launching Build Script..."); + host.subdata.sendPacket(new PacketOutExLogMessage(address, "Launching Build Script...")); + ProcessBuilder pb = new ProcessBuilder().command(Executable.parse(host.host.getRawString("Git-Bash"), template.getBuildOptions().getRawString("Executable"))).directory(dir); pb.environment().putAll(var); process = pb.start(); log.file = new File(dir, "SubCreator-" + template.getName() + "-" + version.toString().replace(" ", "@") + ".log");