The Unified and Autonomous Development Platform
Do not copy server.sh upon upgrade
robin shine9bdf81b84f92
diff --git a/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/DefaultUpgradeCommand.java b/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/DefaultUpgradeCommand.javaindex 6f7051eee7..8ea4071532 100644--- a/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/DefaultUpgradeCommand.java+++ b/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/DefaultUpgradeCommand.java@@ -320,18 +320,16 @@ public class DefaultUpgradeCommand extends DefaultPersistManager {}protected void copyProgramFilesTo(File upgradeDir) {- String result;- try {- String from = FileUtils.readFileToString(new File(upgradeDir, "bin/server.sh"));- String to = FileUtils.readFileToString(new File(Bootstrap.getBinDir(), "server.sh"));- result = UpgradeUtils.copyRunAs(from, to);- } catch (IOException e) {- throw new RuntimeException(e);- }-cleanAndCopy(new File(Bootstrap.installDir, "3rdparty-licenses"), new File(upgradeDir, "3rdparty-licenses"));- cleanAndCopy(Bootstrap.getBinDir(), new File(upgradeDir, "bin"));- FileUtils.writeFile(new File(upgradeDir, "bin/server.sh"), result);+ for (File file: Bootstrap.getBinDir().listFiles()) {+ if (!file.getName().equals("server.sh")) { // server.sh may be customized by user+ try {+ FileUtils.copyFile(file, new File(upgradeDir, "bin/" + file.getName()));+ } catch (IOException e) {+ throw new RuntimeException(e);+ }+ }+ }cleanAndCopy(Bootstrap.getBootDir(), new File(upgradeDir, "boot"));cleanAndCopy(Bootstrap.getLibDir(), new File(upgradeDir, "lib"));for (File file: Bootstrap.getSiteLibDir().listFiles()) {diff --git a/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/UpgradeUtils.java b/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/UpgradeUtils.javadeleted file mode 100644index 81f528c0c1..0000000000--- a/commons.hibernate/src/main/java/com/gitplex/commons/hibernate/command/UpgradeUtils.java+++ /dev/null@@ -1,19 +0,0 @@-package com.gitplex.commons.hibernate.command;--import java.util.regex.Matcher;-import java.util.regex.Pattern;--import org.apache.commons.lang3.StringUtils;--public class UpgradeUtils {-- public static String copyRunAs(String from, String to) {- Matcher matcher = Pattern.compile("(?m)^(#|\\s)*RUN_AS_USER\\s*=.*$").matcher(from);- if (matcher.find()) {- String runAs = matcher.group();- to = StringUtils.replace(to, "#RUN_AS_USER=", runAs);- }- return to;- }--}diff --git a/commons.hibernate/src/test/java/com/gitplex/commons/hibernate/command/UpgradeUtilsTest.java b/commons.hibernate/src/test/java/com/gitplex/commons/hibernate/command/UpgradeUtilsTest.javadeleted file mode 100644index 634995b6cb..0000000000--- a/commons.hibernate/src/test/java/com/gitplex/commons/hibernate/command/UpgradeUtilsTest.java+++ /dev/null@@ -1,70 +0,0 @@-package com.gitplex.commons.hibernate.command;--import static org.junit.Assert.assertEquals;--import org.junit.Test;--import com.gitplex.commons.hibernate.command.UpgradeUtils;--public class UpgradeUtilsTest {-- @Test- public void test() {- String from = ""- + "# specify RUN_AS_USER here\n"- + "RUN_AS_USER = robin \n"- + "some String here RUN_AS_USER=\"\"\n";- String to = ""- + "# specify RUN_AS_USER here\n"- + "#RUN_AS_USER=\n"- + "some String here RUN_AS_USER=\"\"\n";- String expected = ""- + "# specify RUN_AS_USER here\n"- + "RUN_AS_USER = robin \n"- + "some String here RUN_AS_USER=\"\"\n";- assertEquals(expected, UpgradeUtils.copyRunAs(from, to));-- from = ""- + "# specify RUN_AS_USER here\r\n"- + "#RUN_AS_USER = robin \r\n"- + "some String here RUN_AS_USER=\"\"\r\n";- to = ""- + "# specify RUN_AS_USER here\r\n"- + "#RUN_AS_USER=\r\n"- + "some String here RUN_AS_USER=\"\"\r\n";- expected = ""- + "# specify RUN_AS_USER here\r\n"- + "#RUN_AS_USER = robin \r\n"- + "some String here RUN_AS_USER=\"\"\r\n";- assertEquals(expected, UpgradeUtils.copyRunAs(from, to));-- from = ""- + "# specify RUN_AS_USER here\n"- + "#RUN_AS_USER=\n"- + "some String here RUN_AS_USER=\"\"\n";- to = ""- + "# specify RUN_AS_USER here\n"- + "#RUN_AS_USER=\n"- + "some String here RUN_AS_USER=\"\"\n";- expected = ""- + "# specify RUN_AS_USER here\n"- + "#RUN_AS_USER=\n"- + "some String here RUN_AS_USER=\"\"\n";- assertEquals(expected, UpgradeUtils.copyRunAs(from, to));-- from = ""- + "# specify RUN_AS_USER here\n"- + "## RUN_AS_USER = robinshen \n"- + "some String here RUN_AS_USER=\"\"\n";- to = ""- + "# specify RUN_AS_USER here\n"- + "#RUN_AS_USER=\n"- + "some String here RUN_AS_USER=\"\"\n";- expected = ""- + "# specify RUN_AS_USER here\n"- + "## RUN_AS_USER = robinshen \n"- + "some String here RUN_AS_USER=\"\"\n";- assertEquals(expected, UpgradeUtils.copyRunAs(from, to));- }--}