summaryrefslogtreecommitdiff
diff options
-rw-r--r--tools/systemd-prestart-check19
1 files changed, 8 insertions, 11 deletions
diff --git a/tools/systemd-prestart-check b/tools/systemd-prestart-check
index d07b7bc0e..191ff4f10 100644
--- a/tools/systemd-prestart-check
+++ b/tools/systemd-prestart-check
@@ -1,15 +1,16 @@
#!/bin/bash
-this_unit=$(sed -n "s,.*:name=systemd:.*/\([^/]\+.service\)[/\b]\?.*,\1,p" /proc/self/cgroup)
+this_unit=$(sed -n "s,.*:name=systemd:.*/\([^/]\+\.service\)/\?.*,\1,p" /proc/self/cgroup)
+
+if [ -n "$this_unit" ] && [[ $this_unit == "unity"* ]]; then
+ this_job=$(systemctl --user list-jobs $this_unit | sed -n "s,\([0-9]\+\)\s\+${this_unit//./\\.}.*,\1,p")
+fi
# If gnome-session is going to start compiz,
# we don't want to be the ones doing it.
-if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session ; then
+if grep -q compiz /usr/share/gnome-session/sessions/ubuntu.session; then
echo "GNOME Session is starting Compiz"
-
- if [ -n "$this_unit" ] && [[ $this_unit == "unity"* ]]; then
- systemctl --user stop $this_unit
- fi
+ [ -n "$this_job" ] && systemctl --user cancel $this_job
exit 1
fi
@@ -21,11 +22,7 @@ upstart_status=$(initctl status unity7) || true
if (echo "$upstart_status" | grep -q "start/running"); then
echo "Unity is managed by Upstart"
-
- if [ -n "$this_unit" ] && [[ $this_unit == "unity"* ]]; then
- systemctl --user stop $this_unit
- fi
-
+ [ -n "$this_job" ] && systemctl --user cancel $this_job
exit 1
fi