aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2012-04-29 22:26:21 +0000
committerColin Guthrie <colin@mageia.org>2012-04-29 22:26:21 +0000
commit4003173f5ad8362570de1c34b2f77e3c6252f700 (patch)
tree516bb4e345a5b995c12ba6df0234038065a38678
parentaa821624dd22b986d0cb160244b0f1e346262d0f (diff)
downloadrpm-helper-4003173f5ad8362570de1c34b2f77e3c6252f700.tar
rpm-helper-4003173f5ad8362570de1c34b2f77e3c6252f700.tar.gz
rpm-helper-4003173f5ad8362570de1c34b2f77e3c6252f700.tar.bz2
rpm-helper-4003173f5ad8362570de1c34b2f77e3c6252f700.tar.xz
rpm-helper-4003173f5ad8362570de1c34b2f77e3c6252f700.zip
Fix handling of masked and symlinked unit names
-rw-r--r--NEWS3
-rwxr-xr-xadd-service21
2 files changed, 16 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index c020971..48362c2 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+2012-04-29 Colin Guthrie <colin@mageia.org> 0.24.9
+ * fix handling of masked and symlinked unit names
+
2012-04-03 Colin Guthrie <colin@mageia.org> 0.24.8
* always reload systemd unit cache before attempting to restart units
* change the order we search systemd unitdirs to match upstream
diff --git a/add-service b/add-service
index 7e00cce..40e3985 100755
--- a/add-service
+++ b/add-service
@@ -56,21 +56,21 @@ find_unit() {
# and disabling units we must use the official name.
searchunit=
- if [ -f "$USERUNITDIR/$unit" ]; then
+ if [ -e "$USERUNITDIR/$unit" ]; then
if [ -L "$USERUNITDIR/$unit" ]; then
- searchunit=$(/usr/bin/readlink "$USERUNITDIR/$unit")
+ searchunit=$(/usr/bin/readlink -f "$USERUNITDIR/$unit")
else
searchunit="$USERUNITDIR/$unit"
fi
- elif [ -f "$RUNTIMEUNITDIR/$unit" ]; then
+ elif [ -e "$RUNTIMEUNITDIR/$unit" ]; then
if [ -L "$RUNTIMEUNITDIR/$unit" ]; then
- searchunit=$(/usr/bin/readlink "$RUNTIMEUNITDIR/$unit")
+ searchunit=$(/usr/bin/readlink -f "$RUNTIMEUNITDIR/$unit")
else
searchunit="$RUNTIMEUNITDIR/$unit"
fi
- elif [ -f "$SYSTEMUNITDIR/$unit" ]; then
+ elif [ -e "$SYSTEMUNITDIR/$unit" ]; then
if [ -L "$SYSTEMUNITDIR/$unit" ]; then
- searchunit=$(/usr/bin/readlink "$SYSTEMUNITDIR/$unit")
+ searchunit=$(/usr/bin/readlink -f "$SYSTEMUNITDIR/$unit")
else
searchunit="$SYSTEMUNITDIR/$unit"
fi
@@ -174,7 +174,7 @@ check_sysvinit_service() {
}
if [ $num = 1 ]; then
# First install mode
- add_service
+ [ "null" != "$units" ] && add_service
else
# Upgrade mode.
reloaded=no
@@ -187,6 +187,7 @@ else
if [ ! -f "${systemd_migration_dir}/$srv" ]; then
full_path_units=
for unit in $units; do
+ [ "null" = "$unit" ] && continue
# We need a full path for the symlink. Also it's possible
# that $unit contains "foo.service" where foo is actually
# a sysvinit script and thus we'll not have anything native.
@@ -253,6 +254,10 @@ else
# If that is the case, we should still consider it "migrated"
# even when we do not enable anything.
touch "${systemd_migration_dir}/$srv"
+ elif [ "null" = "$units" ]; then
+ # New package masks the unit be we still consider this a migration
+ echo 1>&2 "Migrating sysvinit service '$srv': Masked under systemd."
+ touch "${systemd_migration_dir}/$srv"
fi
fi
fi
@@ -274,7 +279,7 @@ else
done
fi
else
- /bin/systemctl --quiet try-restart $unit
+ [ "null" != "$unit" ] && /bin/systemctl --quiet try-restart $unit
fi
done
elif [ -f /etc/rc.d/init.d/$srv ]; then