commit:     5abb788486521824225f7290dde64ed0a4f5132a
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 25 18:54:41 2017 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Sun Sep  3 01:14:43 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5abb7884

systemd.eclass: add systemd_reenable function

 eclass/systemd.eclass | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index 4b7f5c4cb5f..63ff5609589 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -418,3 +418,24 @@ systemd_tmpfiles_create() {
        type systemd-tmpfiles &> /dev/null || return 0
        systemd-tmpfiles --create "${@}"
 }
+
+# @FUNCTION: systemd_reenable
+# @USAGE: <unit> ...
+# @DESCRIPTION:
+# Re-enables units if they are currently enabled. This resets symlinks to the
+# defaults specified in the [Install] section.
+#
+# This function is intended to fix broken symlinks that result from moving
+# the systemd system unit directory. It should be called from pkg_postinst
+# for system units that define the 'Alias' option in their [Install] section.
+# It is not necessary to call this function to fix dependency symlinks
+# generated by the 'WantedBy' and 'RequiredBy' options.
+systemd_reenable() {
+       type systemctl &>/dev/null || return 0
+       local x
+       for x; do
+               if systemctl --quiet --root="${ROOT}" is-enabled "${x}"; then
+                       systemctl --root="${ROOT}" reenable "${x}"
+               fi
+       done
+}

Reply via email to