aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2012-04-03 00:19:15 +0000
committerColin Guthrie <colin@mageia.org>2012-04-03 00:19:15 +0000
commit919213be6334e8d73c929876417c94f2856e5b25 (patch)
tree872409e6e63f68ca4760df22ee881f40a05c165a
parent3eb2b77e7158673b5a6d807985c82686cf982d43 (diff)
downloadrpm-helper-919213be6334e8d73c929876417c94f2856e5b25.tar
rpm-helper-919213be6334e8d73c929876417c94f2856e5b25.tar.gz
rpm-helper-919213be6334e8d73c929876417c94f2856e5b25.tar.bz2
rpm-helper-919213be6334e8d73c929876417c94f2856e5b25.tar.xz
rpm-helper-919213be6334e8d73c929876417c94f2856e5b25.zip
add-service: on package upgrade, restart all instances of template units.
-rw-r--r--NEWS2
-rwxr-xr-xadd-service19
2 files changed, 19 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index 5be5fd2..53a6fe5 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@
* when migrating sysvinit script to systemd, attempt to deal with
template units gracefully - i.e. forget which runlevels it's
configured for and just enable it
+ * when reloading a template unit, search and fine all instances
+ of that unit and reload them instead
2012-03-12 Guillaume Rousse <guillomovitch@gmail.com> 0.24.7
* drop dead code from add-syslog
diff --git a/add-service b/add-service
index ac1d29b..7e00cce 100755
--- a/add-service
+++ b/add-service
@@ -260,8 +260,23 @@ else
if [ x$init = xsystemd ]; then
# Package install may have changed the unit file, so reload the daemon
# before trying to restart anything
- /bin/systemctl --system daemon-reload
- /bin/systemctl --quiet try-restart $units
+ if [ x$reloaded = xno ]; then
+ /bin/systemctl --system daemon-reload
+ fi
+ # There may be template units, so attempt to find all instances and
+ # restart them.
+ for unit in $units; do
+ if [[ "$unit" =~ "@.service" ]]; then
+ instances=$(/bin/systemctl -a --full list-units | grep -E "${unit%@.service}@[^ ]+.service" | awk '{ print $1 }')
+ if [ -n "$instances" ]; then
+ for iunit in $instances; do
+ /bin/systemctl --quiet try-restart $iunit
+ done
+ fi
+ else
+ /bin/systemctl --quiet try-restart $unit
+ fi
+ done
elif [ -f /etc/rc.d/init.d/$srv ]; then
script=$(check_sysvinit_service 3 $srv);
if [ -f "$script" ]; then