Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring the SystemV init.d scripts inline with the Debian policies #130

Merged
merged 1 commit into from
Jan 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
update-rc.d ${{app_name}} defaults
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line adds the script to autostart, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

service ${{app_name}} start || echo "${{app_name}} could not be started. Try manually with service ${{app_name}} start"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update-rc.d -f ${{app_name}} remove
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ object JavaAppStartScript {
protected def sysvinitTemplateSource: URL = getClass.getResource("sysvinit-template")
protected def postinstTemplateSource: URL = getClass.getResource("postinst-template")
protected def postinstSysvinitTemplateSource: URL = getClass.getResource("postinst-sysvinit-template")
protected def postrmSysvinitTemplateSource: URL = getClass.getResource("postrm-sysvinit-template")
protected def preremTemplateSource: URL = getClass.getResource("prerem-template")


Expand All @@ -30,6 +31,15 @@ object JavaAppStartScript {
TemplateWriter.generateScript(template, Seq("app_name" -> appName))


def generatePostrm(appName: String, loader: ServerLoader, template: Option[java.net.URL] = None): Option[String] =
(template, loader) match {
case (Some(template), _) => Option(TemplateWriter.generateScript(template, Seq("app_name" -> appName)))
case (_, SystemV) =>
Option(TemplateWriter.generateScript(postrmSysvinitTemplateSource, Seq("app_name" -> appName)))
case (_, _) => None
}


def generatePostinst(appName: String, loader: ServerLoader, template: Option[java.net.URL] = None): String =
(template, loader) match {
// User has overriden the default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ object JavaServerAppPackaging {
},
// TODO - only make these if the upstart config exists...
debianMakePrermScript <<= (normalizedName, target in Universal) map makeDebianPrermScript,
debianMakePostrmScript <<= (normalizedName, target in Universal, serverLoading in Debian) map makeDebianPostrmScript,
debianMakePostinstScript <<= (normalizedName, target in Universal, serverLoading in Debian) map makeDebianPostinstScript)

private def makeDebianStartScript(
Expand All @@ -104,6 +105,16 @@ object JavaServerAppPackaging {
Some(script)
}

protected def makeDebianPostrmScript(name: String, tmpDir: File, loader: ServerLoader): Option[File] = {
JavaAppStartScript.generatePostrm(name, loader) match {
case Some(scriptBits) =>
val script = tmpDir / "tmp" / "bin" / "debian-postrm"
IO.write(script, scriptBits)
Some(script)
case None => None
}
}

protected def makeDebianPostinstScript(name: String, tmpDir: File, loader: ServerLoader): Option[File] = {
val scriptBits = JavaAppStartScript.generatePostinst(name, loader)
val script = tmpDir / "tmp" / "bin" / "debian-postinst"
Expand Down