Skip to content

Commit

Permalink
Use recommended path for systemd scripts (#795)
Browse files Browse the repository at this point in the history
* Use recommended path for systemd scripts

* Fix tests
  • Loading branch information
muuki88 authored Jun 9, 2016
1 parent 5d11521 commit 1f67bcb
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object SystemdPlugin extends AutoPlugin {
override def requires = SystemloaderPlugin

override def projectSettings: Seq[Setting[_]] =
inConfig(Debian)(systemdSettings) ++ inConfig(Rpm)(systemdSettings)
debianSettings ++ inConfig(Debian)(systemdSettings) ++ rpmSettings ++ inConfig(Rpm)(systemdSettings)

def systemdSettings: Seq[Setting[_]] = Seq(
// used by other archetypes to define systemloader dependent behaviour
Expand All @@ -41,7 +41,6 @@ object SystemdPlugin extends AutoPlugin {
stopRunlevels := None,
requiredStartFacilities := Some("network.target"),
requiredStopFacilities := Some("network.target"),
defaultLinuxStartScriptLocation := "/usr/lib/systemd/system",
linuxStartScriptName := Some(packageName.value + ".service"),
// add systemloader to mappings
linuxPackageMappings ++= startScriptMapping(
Expand All @@ -52,4 +51,12 @@ object SystemdPlugin extends AutoPlugin {
)
)

def debianSettings: Seq[Setting[_]] = inConfig(Debian)(
defaultLinuxStartScriptLocation := "/lib/systemd/system"
)

def rpmSettings: Seq[Setting[_]] = inConfig(Rpm)(
defaultLinuxStartScriptLocation := "/usr/lib/systemd/system"
)

}
2 changes: 1 addition & 1 deletion src/sbt-test/debian/systemd-deb/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ requiredStartFacilities in Debian := Some("network.target")
daemonUser in Linux := "testuser"

TaskKey[Unit]("check-startup-script") <<= (target, streams) map { (target, out) =>
val script = IO.read(target / "debian-test-0.1.0" / "usr" / "lib" / "systemd" / "system" / "debian-test.service")
val script = IO.read(target / "debian-test-0.1.0" / "lib" / "systemd" / "system" / "debian-test.service")
assert(script.contains("Requires=network.target"), "script doesn't contain Default-Start header\n" + script)
assert(script.contains("User=testuser"), "script doesn't contain `User` header\n" + script)
assert(script.contains("EnvironmentFile=/etc/default/debian-test"), "script doesn't contain EnvironmentFile header\n" + script)
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/debian/systemd-deb/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
> debian:package-bin
$ exists target/debian-test_0.1.0_all.deb

$ exists target/debian-test-0.1.0/usr/lib/systemd/system/debian-test.service
$ exists target/debian-test-0.1.0/lib/systemd/system/debian-test.service
> show debian:serverLoader
> show debian:linuxStartScriptTemplate
> plugins
Expand Down
19 changes: 19 additions & 0 deletions src/sphinx/archetypes/systemloaders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ as the* ``daemonUser`` *. Simply disable requiretty to use Upstart or modify the
Customization
-------------

Native packager provides general settings to customize the created systemloader scripts.

Start Script Location
~~~~~~~~~~~~~~~~~~~~~

In order to change the location of the systemloader script/config file you need to adjust the
``defaultLinuxStartScriptLocation`` like this:

.. code-block:: scala
defaultLinuxStartScriptLocation in Debian := "/lib/systemd/system"
You may need to change these paths according to your distribution. References are

- `Ubuntu systemd documentation <https://wiki.ubuntu.com/systemd>`_
- `Debian systemd documentation <https://wiki.debian.org/Teams/pkg-systemd/Packaging>`_
- `RHEL systemd documentation <https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/chap-Managing_Services_with_systemd.html>`_

Customize Start Script
~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 1f67bcb

Please sign in to comment.