aboutsummaryrefslogtreecommitdiffstats
path: root/add-service
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2011-10-30 15:08:02 +0000
committerColin Guthrie <colin@mageia.org>2011-10-30 15:08:02 +0000
commite11609c43474d840d51004ab88fb274dbd9ddeb8 (patch)
treee42ccad268f36890005bc469578ad6e871deff2b /add-service
parent751f55f6a09a18bcb6ffab577256d93824ee29cc (diff)
downloadrpm-helper-e11609c43474d840d51004ab88fb274dbd9ddeb8.tar
rpm-helper-e11609c43474d840d51004ab88fb274dbd9ddeb8.tar.gz
rpm-helper-e11609c43474d840d51004ab88fb274dbd9ddeb8.tar.bz2
rpm-helper-e11609c43474d840d51004ab88fb274dbd9ddeb8.tar.xz
rpm-helper-e11609c43474d840d51004ab88fb274dbd9ddeb8.zip
Change how services are handled in systemd.v0.24.20.24.2
This ensures that services are started/stopped in the most appropriate way depending on what init system is being used. Also when upgrading a service, ensure it is properly restarted even when using systemd (assuming it is currently running). Testing these scripts without actually installing/uninstalling package may result in the sysvinit scripts being deleted so be careful.
Diffstat (limited to 'add-service')
-rwxr-xr-xadd-service38
1 files changed, 18 insertions, 20 deletions
diff --git a/add-service b/add-service
index 4561f12..307f0a4 100755
--- a/add-service
+++ b/add-service
@@ -22,6 +22,13 @@ if [ $# -lt 3 ]; then
exit 1
fi
+# What init system are we currently using?
+if /bin/mountpoint -q /sys/fs/cgroup/systemd; then
+ init=systemd
+else
+ init=sysvinit
+fi
+
pkg=$1 # name of the package
num=$2 # number of packages installed
if [ $do_sysv = yes ]; then
@@ -107,28 +114,19 @@ if [ $num = 1 ]; then
# First install mode
add_service
else
- # Upgrade mode. systemd units are restarted in postun
- [ -n "$srv" ] || exit 0
-
- # if the service is activated, add it again to be able to handle
- # changes in start/stop levels. This does not change enabled/disabled
- # state, so we do not do it for systemd where dependencies are handled
- # automatically.
-
- # Restart only SysV services here only if no additional systemd
- # units are defined or systemd is not active. Otherwise user is expected
- # to add postun script that handles systemd units.
-
- set -- /etc/rc3.d/S??$srv
- if [ $# -gt 1 ]; then
- echo 1>&2 "add-service: Error: $srv appears multiple times: $*"
- fi
+ # Upgrade mode.
+ if [ x$init = xsystemd ]; then
+ /bin/systemctl --quiet try-restart $units
+ else
+ set -- /etc/rc3.d/S??$srv
+ if [ $# -gt 1 ]; then
+ echo 1>&2 "add-service: Error: $srv appears multiple times: $*"
+ fi
- if [ -f "$1" ]; then
- /sbin/chkconfig --add $srv
- fi
+ if [ -f "$1" ]; then
+ /sbin/chkconfig --add $srv
+ fi
- if ! /bin/mountpoint -q /sys/fs/cgroup/systemd; then
# restart the service if already running
if [ -f /var/lock/subsys/$srv ]; then
/sbin/service $srv restart > /dev/null || :