Skip to content

Commit

Permalink
Merge pull request #187 from sbt/wip/rpm-server-startup
Browse files Browse the repository at this point in the history
Adding additional features for rpm
  • Loading branch information
jsuereth committed Mar 10, 2014
2 parents 3b92956 + 42e8694 commit 9b55409
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# ${{app_name}} <${{app_name}}>
#
# chkconfig: - 20 80
# chkconfig: 2345 20 80
# description: ${{descr}}
#

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
service ${{app_name}} start
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ if ! getent passwd | grep -q "^${{daemon_user}}:";
then
echo "Creating system user: ${{daemon_user}}"
useradd --gid ${{daemon_group}} --no-create-home --system -c '${{descr}}' ${{daemon_user}}
fi
fi
3 changes: 3 additions & 0 deletions src/main/resources/com/typesafe/sbt/packager/rpm/preuninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Halting ${{app_name}}
echo "Shutdown ${{app_name}}"
service ${{app_name}} stop
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ object JavaServerAppPackaging {
def linuxSettings: Seq[Setting[_]] = Seq(
// This one is begging for sbt 0.13 syntax...
linuxScriptReplacements <<= (
// TODO do we need to separated rpm and debian maintainers?
maintainer in Linux, packageSummary in Linux, daemonUser in Linux, daemonGroup in Linux, normalizedName,
sbt.Keys.version, defaultLinuxInstallLocation, linuxJavaAppStartScriptBuilder in Debian)
apply { (author, descr, daemonUser, daemonGroup, name, version, installLocation, builder) =>
Expand Down Expand Up @@ -117,12 +118,20 @@ object JavaServerAppPackaging {
// == Maintainer scripts ===
// TODO this is very basic - align debian and rpm plugin
rpmPre <<= (rpmPre, linuxScriptReplacements) apply { (pre, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.preinstTemplateSource, replacements)
Some(pre.map(_ + "\n").getOrElse("") + scriptBits)
},
rpmPost <<= (rpmPost, linuxScriptReplacements) apply { (pre, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.postinstTemplateSource, replacements)
Some(pre.map(_ + "\n").getOrElse("") + scriptBits)
},
rpmPostun <<= (rpmPostun, linuxScriptReplacements) apply { (post, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.postuninstallTemplateSource, replacements)
Some(post.map(_ + "\n").getOrElse("") + scriptBits)
},
rpmPreun <<= (rpmPostun, linuxScriptReplacements) apply { (post, replacements) =>
val scriptBits = TemplateWriter.generateScript(RpmPlugin.preuninstallTemplateSource, replacements)
Some(post.map(_ + "\n").getOrElse("") + scriptBits)
}
)

Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ trait RpmPlugin extends Plugin with LinuxPlugin {

object RpmPlugin {

def preinstTemplateSource: java.net.URL = getClass.getResource("preinstall")
def postinstTemplateSource: java.net.URL = getClass.getResource("postinstall")
def preuninstallTemplateSource: java.net.URL = getClass.getResource("preuninstall")
def postuninstallTemplateSource: java.net.URL = getClass.getResource("postuninstall")
def postinstTemplateSource: java.net.URL = getClass.getResource("preinstall")
}

0 comments on commit 9b55409

Please sign in to comment.