aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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