1 |
commit: 5abb788486521824225f7290dde64ed0a4f5132a |
2 |
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Aug 25 18:54:41 2017 +0000 |
4 |
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 3 01:14:43 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5abb7884 |
7 |
|
8 |
systemd.eclass: add systemd_reenable function |
9 |
|
10 |
eclass/systemd.eclass | 21 +++++++++++++++++++++ |
11 |
1 file changed, 21 insertions(+) |
12 |
|
13 |
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass |
14 |
index 4b7f5c4cb5f..63ff5609589 100644 |
15 |
--- a/eclass/systemd.eclass |
16 |
+++ b/eclass/systemd.eclass |
17 |
@@ -418,3 +418,24 @@ systemd_tmpfiles_create() { |
18 |
type systemd-tmpfiles &> /dev/null || return 0 |
19 |
systemd-tmpfiles --create "${@}" |
20 |
} |
21 |
+ |
22 |
+# @FUNCTION: systemd_reenable |
23 |
+# @USAGE: <unit> ... |
24 |
+# @DESCRIPTION: |
25 |
+# Re-enables units if they are currently enabled. This resets symlinks to the |
26 |
+# defaults specified in the [Install] section. |
27 |
+# |
28 |
+# This function is intended to fix broken symlinks that result from moving |
29 |
+# the systemd system unit directory. It should be called from pkg_postinst |
30 |
+# for system units that define the 'Alias' option in their [Install] section. |
31 |
+# It is not necessary to call this function to fix dependency symlinks |
32 |
+# generated by the 'WantedBy' and 'RequiredBy' options. |
33 |
+systemd_reenable() { |
34 |
+ type systemctl &>/dev/null || return 0 |
35 |
+ local x |
36 |
+ for x; do |
37 |
+ if systemctl --quiet --root="${ROOT}" is-enabled "${x}"; then |
38 |
+ systemctl --root="${ROOT}" reenable "${x}" |
39 |
+ fi |
40 |
+ done |
41 |
+} |