aboutsummaryrefslogtreecommitdiffstats
path: root/add-service
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 /add-service
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.
Diffstat (limited to 'add-service')
-rwxr-xr-xadd-service31
1 files changed, 22 insertions, 9 deletions
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