diff options
Diffstat (limited to 'add-service')
-rwxr-xr-x | add-service | 31 |
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 |