Skip to content

Commit

Permalink
Fix #98 java server type includes /etc/default by default
Browse files Browse the repository at this point in the history
* Added default configuration location
* Added replacements in /etc/default configuration
* Added tests
* Added default configuration file with examples
* Added /etc/default script to Upstart
  • Loading branch information
muuki88 committed Jan 28, 2014
1 parent 3b1d318 commit d13440b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
#Some start script options could be overridden here
#RUN_OPTS=""
#DAEMON_USER=""
#JAVA_CMD=""
# #################################
# ##### Default configuration #####
# #################################

# Available replacements
# ------------------------------------------------
# ${{author}} debian author
# ${{descr}} debian package description
# ${{exec}} startup script name
# ${{chdir}} app directory
# ${{retries}} retries for startup
# ${{retryTimeout}} retry timeout
# ${{app_name}} normalized app name
# ${{daemon_user}} daemon user
# -------------------------------------------------

# Setting -Xmx and -Xms in Megabyte
# -mem 1024

# Setting -X directly (-J is stripped)
# -J-X
# -J-Xmx 1024

# Add additional jvm parameters
# -Dkey=val

# For play applications you may set
# -Dpidfile.path=/var/run/${{app_name}}.pid

# Turn on JVM debugging, open at the given port
# -jvm-debug <port>

# Don't run the java version check
# -no-version-check
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ object JavaServerAppPackaging {
},

// === etc config mapping ===
bashScriptConfigLocation <<= normalizedName map (name => Some("/etc/default/" + name)),
linuxEtcDefaultTemplate in Debian <<= sourceDirectory map { dir =>
val overrideScript = dir / "templates" / "etc-default"
if (overrideScript.exists) overrideScript.toURI.toURL
else etcDefaultTemplateSource
},
debianMakeEtcDefault <<= (normalizedName, target in Universal, serverLoading in Debian, linuxEtcDefaultTemplate in Debian)
debianMakeEtcDefault <<= (normalizedName, target in Universal, linuxEtcDefaultTemplate in Debian, debianScriptReplacements)
map makeEtcDefaultScript,
linuxPackageMappings in Debian <++= (debianMakeEtcDefault, normalizedName) map { (conf, name) =>
conf.map(c => LinuxPackageMapping(Seq(c -> ("/etc/default/" + name))).withConfig()).toSeq
Expand Down Expand Up @@ -106,15 +107,10 @@ object JavaServerAppPackaging {
}
}

protected def makeEtcDefaultScript(name: String, tmpDir: File, loader: ServerLoader, source: java.net.URL): Option[File] = {
loader match {
case Upstart => None
case SystemV => {
val scriptBits = TemplateWriter.generateScript(source, Seq.empty)
val script = tmpDir / "tmp" / "etc" / "default" / name
IO.write(script, scriptBits)
Some(script)
}
}
protected def makeEtcDefaultScript(name: String, tmpDir: File, source: java.net.URL, replacements: Seq[(String, String)]): Option[File] = {
val scriptBits = TemplateWriter.generateScript(source, replacements)
val script = tmpDir / "tmp" / "etc" / "default" / name
IO.write(script, scriptBits)
Some(script)
}
}
1 change: 1 addition & 0 deletions src/sbt-test/debian/sysvinit-deb/test
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
$ exists target/debian-test-0.1.0.deb

$ exists target/debian-test-0.1.0/etc
$ exists target/debian-test-0.1.0/etc/default/debian-test
$ exists target/debian-test-0.1.0/etc/init.d/debian-test
2 changes: 2 additions & 0 deletions src/sbt-test/debian/upstart-deb/test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
$ exists target/debian-test-0.1.0.deb

$ exists target/debian-test-0.1.0/etc
$ exists target/debian-test-0.1.0/etc/default/debian-test
$ exists target/debian-test-0.1.0/etc/init/debian-test.conf

# Check defaults
$ exists target/debian-test-0.1.0/DEBIAN/prerm
$ exists target/debian-test-0.1.0/DEBIAN/postinst
Expand Down

0 comments on commit d13440b

Please sign in to comment.