9953: Install/remove systemd unit files wherever systemd exists, even if it is not...
authorTom Clegg <tom@curoverse.com>
Fri, 23 Sep 2016 20:47:29 +0000 (16:47 -0400)
committerTom Clegg <tom@curoverse.com>
Wed, 28 Sep 2016 20:02:08 +0000 (16:02 -0400)
build/go-python-package-scripts/postinst
build/go-python-package-scripts/prerm

index 1e103337eaa5701cf46d3cf90130368fff360240..051c8bd98bd379cf29752f08ea1d88284706d60e 100755 (executable)
@@ -11,7 +11,8 @@ systemd_unit="${pkg}.service"
 
 case "${1}" in
     configure)
-        if [ -e /run/systemd/system ]; then
+        if [ -d /lib/systemd/system ]
+        then
             # Python packages put all data files in /usr, so we copy
             # them to /lib at install time.
             py_unit="/usr/share/doc/${pkg}/${pkg}.service"
@@ -19,7 +20,9 @@ case "${1}" in
             then
                 cp "${py_unit}" /lib/systemd/system/
             fi
+        fi
 
+        if [ -e /run/systemd/system ]; then
             eval "$(systemctl -p UnitFileState show "${systemd_unit}")"
             case "${UnitFileState}" in
                 disabled)
index 7f4b843d61593ee7f8e4aec49e5725bf6ea34cda..c6ec18ca106cb1bba11e761363715fb1ce40c0d2 100755 (executable)
@@ -14,14 +14,14 @@ case "${1}" in
         if [ -e /run/systemd/system ]; then
             systemctl stop "${systemd_unit}" || true
             systemctl disable "${systemd_unit}" || true
+        fi
 
-            # Unit files from Python packages get installed by
-            # postinst so we have to remove them explicitly here.
-            py_unit="/usr/share/doc/${pkg}/${pkg}.service"
-            if [ -e "${py_unit}" ]
-            then
-                rm "/lib/systemd/system/${pkg}.service" || true
-            fi
+        # Unit files from Python packages get installed by postinst so
+        # we have to remove them explicitly here.
+        py_unit="/usr/share/doc/${pkg}/${pkg}.service"
+        if [ -e "${py_unit}" ]
+        then
+            rm "/lib/systemd/system/${pkg}.service" || true
         fi
         ;;
 esac