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

Use recommended path for systemd scripts #795

Merged
merged 2 commits into from
Jun 9, 2016
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
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 @@ -74,6 +74,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