diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-rpm-template b/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-rpm-template index 57727568d..162cf2f59 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-rpm-template +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/systemv/start-rpm-template @@ -2,7 +2,7 @@ # # ${{app_name}} <${{app_name}}> # -# chkconfig: - 20 80 +# chkconfig: 2345 20 80 # description: ${{descr}} # diff --git a/src/main/resources/com/typesafe/sbt/packager/rpm/postinstall b/src/main/resources/com/typesafe/sbt/packager/rpm/postinstall new file mode 100644 index 000000000..fb5c13fbd --- /dev/null +++ b/src/main/resources/com/typesafe/sbt/packager/rpm/postinstall @@ -0,0 +1 @@ +service ${{app_name}} start diff --git a/src/main/resources/com/typesafe/sbt/packager/rpm/preinstall b/src/main/resources/com/typesafe/sbt/packager/rpm/preinstall index 904a22cc8..12ae3e449 100644 --- a/src/main/resources/com/typesafe/sbt/packager/rpm/preinstall +++ b/src/main/resources/com/typesafe/sbt/packager/rpm/preinstall @@ -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 \ No newline at end of file +fi diff --git a/src/main/resources/com/typesafe/sbt/packager/rpm/preuninstall b/src/main/resources/com/typesafe/sbt/packager/rpm/preuninstall new file mode 100644 index 000000000..2ffa1da1a --- /dev/null +++ b/src/main/resources/com/typesafe/sbt/packager/rpm/preuninstall @@ -0,0 +1,3 @@ +# Halting ${{app_name}} +echo "Shutdown ${{app_name}}" +service ${{app_name}} stop \ No newline at end of file diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala index 2c4b6a977..bda8120c9 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -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) => @@ -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) } ) diff --git a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala index d5579af3c..e83e22c9b 100644 --- a/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala @@ -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") }