summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-11-23 10:54:29 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-12-06 10:19:35 +0100
commitcfdda37c9fe0d28fd29a74b665072b92228d68f2 (patch)
tree93bdd57c0de36b9167be7a0970b80b9e4f268969
parenttmpfiles: add --user switch (diff)
downloadsystemd-cfdda37c9fe0d28fd29a74b665072b92228d68f2.tar.xz
systemd-cfdda37c9fe0d28fd29a74b665072b92228d68f2.zip
Hook up systemd-tmpfiles as user units
An explicit --user switch is necessary because for the user@0.service instance systemd-tmpfiles is running as root, and we need to distinguish that from systemd-tmpfiles running in systemd-tmpfiles*.service. Fixes #2208. v2: - restore "systemd-" prefix - add systemd-tmpfiles-clean.{service,timer}, systemd-setup.service to systemd-tmpfiles(8)
-rw-r--r--man/systemd-tmpfiles.xml14
-rw-r--r--presets/meson.build3
-rw-r--r--presets/user/90-systemd.preset14
-rw-r--r--units/user/meson.build3
-rw-r--r--units/user/systemd-tmpfiles-clean.service.in21
-rw-r--r--units/user/systemd-tmpfiles-clean.timer19
-rw-r--r--units/user/systemd-tmpfiles-setup.service.in25
7 files changed, 95 insertions, 4 deletions
diff --git a/man/systemd-tmpfiles.xml b/man/systemd-tmpfiles.xml
index 5c9660df64..24a08b0354 100644
--- a/man/systemd-tmpfiles.xml
+++ b/man/systemd-tmpfiles.xml
@@ -62,10 +62,16 @@
<arg choice="opt" rep="repeat"><replaceable>CONFIGFILE</replaceable></arg>
</cmdsynopsis>
- <para><filename>systemd-tmpfiles-setup.service</filename></para>
- <para><filename>systemd-tmpfiles-setup-dev.service</filename></para>
- <para><filename>systemd-tmpfiles-clean.service</filename></para>
- <para><filename>systemd-tmpfiles-clean.timer</filename></para>
+ <para>System units:
+<literallayout><filename>systemd-tmpfiles-setup.service</filename>
+<filename>systemd-tmpfiles-setup-dev.service</filename>
+<filename>systemd-tmpfiles-clean.service</filename>
+<filename>systemd-tmpfiles-clean.timer</filename></literallayout></para>
+
+ <para>User units:
+<literallayout><filename>systemd-tmpfiles-setup.service</filename>
+<filename>systemd-tmpfiles-clean.service</filename>
+<filename>systemd-tmpfiles-clean.timer</filename></literallayout></para>
</refsynopsisdiv>
<refsect1>
diff --git a/presets/meson.build b/presets/meson.build
index 89bed8a05a..48aa8c9796 100644
--- a/presets/meson.build
+++ b/presets/meson.build
@@ -17,3 +17,6 @@
install_data('90-systemd.preset',
install_dir : systempresetdir)
+
+install_data('user/90-systemd.preset',
+ install_dir : userpresetdir)
diff --git a/presets/user/90-systemd.preset b/presets/user/90-systemd.preset
new file mode 100644
index 0000000000..22fe41fc33
--- /dev/null
+++ b/presets/user/90-systemd.preset
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1+
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+# These ones should be enabled by default, even if distributions
+# generally follow a default-off policy.
+
+enable systemd-tmpfiles-setup.service
+enable systemd-tmpfiles-clean.timer
diff --git a/units/user/meson.build b/units/user/meson.build
index fbe6e3fb13..e463ae226c 100644
--- a/units/user/meson.build
+++ b/units/user/meson.build
@@ -29,6 +29,7 @@ units = [
'sockets.target',
'sound.target',
'timers.target',
+ 'systemd-tmpfiles-clean.timer',
]
foreach file : units
@@ -38,6 +39,8 @@ endforeach
in_units = [
'systemd-exit.service',
+ 'systemd-tmpfiles-clean.service',
+ 'systemd-tmpfiles-setup.service',
]
foreach file : in_units
diff --git a/units/user/systemd-tmpfiles-clean.service.in b/units/user/systemd-tmpfiles-clean.service.in
new file mode 100644
index 0000000000..9cd19720d3
--- /dev/null
+++ b/units/user/systemd-tmpfiles-clean.service.in
@@ -0,0 +1,21 @@
+# SPDX-License-Identifier: LGPL-2.1+
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Cleanup of User's Temporary Files and Directories
+Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=basic.target shutdown.target
+
+[Service]
+Type=oneshot
+ExecStart=@rootbindir@/systemd-tmpfiles --user --clean
+SuccessExitStatus=65
+IOSchedulingClass=idle
diff --git a/units/user/systemd-tmpfiles-clean.timer b/units/user/systemd-tmpfiles-clean.timer
new file mode 100644
index 0000000000..d1dbad98de
--- /dev/null
+++ b/units/user/systemd-tmpfiles-clean.timer
@@ -0,0 +1,19 @@
+# SPDX-License-Identifier: LGPL-2.1+
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Daily Cleanup of User's Temporary Directories
+Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
+
+[Timer]
+OnStartupSec=5min
+OnUnitActiveSec=1d
+
+[Install]
+WantedBy=timers.target
diff --git a/units/user/systemd-tmpfiles-setup.service.in b/units/user/systemd-tmpfiles-setup.service.in
new file mode 100644
index 0000000000..6467dab896
--- /dev/null
+++ b/units/user/systemd-tmpfiles-setup.service.in
@@ -0,0 +1,25 @@
+# SPDX-License-Identifier: LGPL-2.1+
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Create User's Volatile Files and Directories
+Documentation=man:tmpfiles.d(5) man:systemd-tmpfiles(8)
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=basic.target shutdown.target
+RefuseManualStop=yes
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=@rootbindir@/systemd-tmpfiles --user --create --remove --boot
+SuccessExitStatus=65
+
+[Install]
+WantedBy=basic.target