diff --git a/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/loader-functions b/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/loader-functions index a3679cbdd..9eaed006f 100644 --- a/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/loader-functions +++ b/src/main/resources/com/typesafe/sbt/packager/archetypes/java_server/systemloader/systemv/loader-functions @@ -4,7 +4,7 @@ # startService() { app_name=$1 - if hash update-rc.d 2>/dev/null; then + if hash update-rc.d >/dev/null 2>&1; then echo "Adding $app_name to autostart using update-rc.d" update-rc.d $app_name defaults service $app_name start @@ -24,7 +24,7 @@ startService() { # stopService() { app_name=$1 - if hash update-rc.d 2>/dev/null; then + if hash update-rc.d >/dev/null 2>&1; then echo "Removing $app_name from autostart using update-rc.d" update-rc.d -f $app_name remove service $app_name stop 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 a7c8e5528..3d3de8171 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/JavaServerApplication.scala @@ -65,11 +65,6 @@ object JavaServerAppPackaging extends AutoPlugin { linuxPackageMappings <++= (makeEtcDefault, packageName in Linux) map { (conf, name) => conf.map(c => LinuxPackageMapping(Seq(c -> ("/etc/default/" + name)), LinuxFileMetaData(Users.Root, Users.Root, "644")).withConfig()).toSeq - }, - - // === /var/run/app pid folder === - linuxPackageMappings <+= (packageName in Linux, daemonUser in Linux, daemonGroup in Linux) map { (name, user, group) => - packageTemplateMapping("/var/run/" + name)() withUser user withGroup group withPerms "755" } ) @@ -100,6 +95,9 @@ object JavaServerAppPackaging extends AutoPlugin { serverLoading in Debian) map makeStartScript, linuxPackageMappings <++= (packageName, linuxMakeStartScript, serverLoading, defaultLinuxStartScriptLocation) map startScriptMapping )) ++ Seq( + // === Daemon User and Group === + daemonUser in Debian <<= daemonUser in Linux, + daemonGroup in Debian <<= daemonGroup in Linux, // === Maintainer scripts === debianMakePreinstScript <<= (target in Universal, serverLoading in Debian, linuxScriptReplacements) map makeMaintainerScript(Preinst), debianMakePostinstScript <<= (target in Universal, serverLoading in Debian, linuxScriptReplacements) map makeMaintainerScript(Postinst), @@ -117,8 +115,16 @@ object JavaServerAppPackaging extends AutoPlugin { requiredStopFacilities in Rpm <<= (serverLoading) apply defaultFacilities, linuxScriptReplacements <++= (requiredStartFacilities, requiredStopFacilities, startRunlevels, stopRunlevels, serverLoading) apply makeStartScriptReplacements, - linuxScriptReplacements += JavaServerLoaderScript.loaderFunctionsReplacement(serverLoading.value, ARCHETYPE) + linuxScriptReplacements += JavaServerLoaderScript.loaderFunctionsReplacement(serverLoading.value, ARCHETYPE), + + // === /var/run/app pid folder === + linuxPackageMappings <+= (packageName, daemonUser, daemonGroup) map { (name, user, group) => + packageTemplateMapping("/var/run/" + name)() withUser user withGroup group withPerms "755" + } )) ++ Seq( + // === Daemon User and Group === + daemonUser in Rpm <<= daemonUser in Linux, + daemonGroup in Rpm <<= daemonGroup in Linux, // === Startscript creation === linuxStartScriptTemplate := JavaServerLoaderScript( script = startScriptName((serverLoading in Rpm).value, Rpm), diff --git a/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala b/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala index c37969cb2..f47c61ace 100644 --- a/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala +++ b/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala @@ -213,7 +213,7 @@ object DebianPlugin extends AutoPlugin with DebianNativePackaging { t }, // Replacement for ${{header}} as debian control scripts are bash scripts - linuxScriptReplacements += ("header" -> "#!/bin/sh\n") + linuxScriptReplacements += ("header" -> "#!/bin/sh\nset -e") // Adding package specific implementation settings ))