aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2012-04-03 00:17:17 +0000
committerColin Guthrie <colin@mageia.org>2012-04-03 00:17:17 +0000
commit3eb2b77e7158673b5a6d807985c82686cf982d43 (patch)
treec411d621286422c553b7049025b320efffb9140d
parenta12c6b32f7cbb2e400c60000a0d736dd8d8e598f (diff)
downloadrpm-helper-3eb2b77e7158673b5a6d807985c82686cf982d43.tar
rpm-helper-3eb2b77e7158673b5a6d807985c82686cf982d43.tar.gz
rpm-helper-3eb2b77e7158673b5a6d807985c82686cf982d43.tar.bz2
rpm-helper-3eb2b77e7158673b5a6d807985c82686cf982d43.tar.xz
rpm-helper-3eb2b77e7158673b5a6d807985c82686cf982d43.zip
add-service: attempt to migrate template systemd units (foo@.service) somewhat gracefully.
-rw-r--r--NEWS3
-rwxr-xr-xadd-service31
2 files changed, 25 insertions, 9 deletions
diff --git a/NEWS b/NEWS
index 17d19f6..5be5fd2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
* always reload systemd unit cache before attempting to restart units
* change the order we search systemd unitdirs to match upstream
+ * 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
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 755403a..ac1d29b 100755
--- a/add-service
+++ b/add-service
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#---------------------------------------------------------------
# Project : Mandriva Linux
# Module : rpm-helper
@@ -177,6 +177,7 @@ if [ $num = 1 ]; then
add_service
else
# Upgrade mode.
+ reloaded=no
# Handle migration to systemd.
# If a previously installed package only had a sysvinit script, but an
@@ -224,15 +225,27 @@ else
fi
if [ -n "$enable_targets" ]; then
- for enable_target in $enable_targets; do
- wantsdir=$USERUNITDIR/${enable_target}.wants
- mkdir -p $wantsdir
- for unit in $full_path_units; do
- if [ ! -f $wantsdir/$(basename $unit) ]; then
- echo 1>&2 "Migrating sysvinit service '$srv' to systemd native unit '$(basename $unit)' for target '${enable_target}'"
- ln -s $unit $wantsdir/$(basename $unit)
+ for unit in $full_path_units; do
+ bn_unit="$(basename $unit)"
+ if [[ "$bn_unit" =~ "@.service" ]]; then
+ # We cannot simply link template units
+ if [ x$init = xsystemd -a x$reloaded = xno ]; then
+ /bin/systemctl --system daemon-reload
+ reloaded=yes
fi
- done
+ echo 1>&2 "Migrating sysvinit service '$srv' to systemd native template unit '$bn_unit'"
+ /bin/systemctl enable $bn_unit
+ else
+ for enable_target in $enable_targets; do
+ wantsdir=$USERUNITDIR/${enable_target}.wants
+ mkdir -p $wantsdir
+ if [ ! -f $wantsdir/$bn_unit ]; then
+ echo 1>&2 "Migrating sysvinit service '$srv' to systemd native unit '$bn_unit' for target '${enable_target}'"
+ ln -s $unit $wantsdir/$bn_unit
+ reloaded=no
+ fi
+ done
+ fi
done
fi