Last active
October 10, 2020 14:46
-
-
Save lhns/d04e239a499df499df4d4499934764af to your computer and use it in GitHub Desktop.
see https://gist.github.com/LolHens/ee821a5cd1b2031856b21a0e78e1ecc9 for universalScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def defaultUniversalScript(javaOpts: Seq[String] = Seq.empty, | |
shebang: Boolean, | |
console: Boolean = true): Seq[String] = { | |
val javaOptsString = javaOpts.map(_ + " ").mkString | |
Seq(universalScript( | |
shellCommands = { | |
def javaCommand(args: String): String = | |
if (console) s"exec java $args" | |
else s"nohup java $args </dev/null &>/dev/null &" | |
"if [ -n \"$JAVA_HOME\" ]; then PATH=\"$JAVA_HOME/bin:$PATH\"; fi\n" + | |
javaCommand(s"""-jar $javaOptsString$$JAVA_OPTS "$$0" "$$@"""") | |
}, | |
cmdCommands = { | |
def javaCommand(args: String): String = | |
if (console) s"java $args" | |
else | |
s"""start "" javaw $args""" | |
"if not \"%JAVA_HOME%\"==\"\" set \"PATH=%JAVA_HOME%\\bin;%PATH%\"\n" + | |
javaCommand(s"""-jar $javaOptsString%JAVA_OPTS% "%~dpnx0" %*""") | |
}, | |
shebang = shebang | |
)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment