summaryrefslogtreecommitdiff
path: root/tools
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-09-06 16:08:15 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-09-06 16:08:15 +0200
commitf1bc209e5a5fc4dfc105a3baafa1ca3f97751049 (patch)
treebb52a45883714eece775ec75072ca42b224f8a35 /tools
parent63b7d68d7f4babfe5f64009027c0e2b39db6e6d9 (diff)
systemd-prestart-check: use systemctl --user cancel to stop the currently running job
(bzr r4153.9.65)
Diffstat (limited to 'tools')
-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