aboutsummaryrefslogtreecommitdiffstats
path: root/migrate-service
diff options
context:
space:
mode:
authorDexter Morgan <dmorgan@mageia.org>2011-10-27 22:47:46 +0000
committerDexter Morgan <dmorgan@mageia.org>2011-10-27 22:47:46 +0000
commitc64fa938609c6bee9dd02adc1a37df89a9ebd116 (patch)
tree20da84dbd8cc32fb518e4bf777359664dba63a88 /migrate-service
parentb1c56622b1c4a3e390de269e8c28af133f2472c9 (diff)
downloadrpm-helper-c64fa938609c6bee9dd02adc1a37df89a9ebd116.tar
rpm-helper-c64fa938609c6bee9dd02adc1a37df89a9ebd116.tar.gz
rpm-helper-c64fa938609c6bee9dd02adc1a37df89a9ebd116.tar.bz2
rpm-helper-c64fa938609c6bee9dd02adc1a37df89a9ebd116.tar.xz
rpm-helper-c64fa938609c6bee9dd02adc1a37df89a9ebd116.zip
Add systemd support ( mdv )
Diffstat (limited to 'migrate-service')
-rw-r--r--migrate-service53
1 files changed, 53 insertions, 0 deletions
diff --git a/migrate-service b/migrate-service
new file mode 100644
index 0000000..de08435
--- /dev/null
+++ b/migrate-service
@@ -0,0 +1,53 @@
+#!/bin/sh
+#---------------------------------------------------------------
+# Project : Mandriva Linux
+# Module : rpm-helper
+# File : migrate-service
+# Version : $Id$
+# Authors : Andrey Borzenkov
+# Created On : Sat Mar 12 18:37:00 2011
+# Purpose : helper script for rpm scriptlets to migrate
+# from SysV script to systemd unit.
+#---------------------------------------------------------------
+
+if [ $# -lt 3 ]; then
+ echo "usage: $0 {pre|post} <service name> <unit name> ..." 1>&2
+ exit 1
+fi
+
+phase=$1 # pre/post
+srv=$2 # name of the SysV script
+shift 2 # systemd units
+
+if [ $phase = pre ]; then
+ # create flag that service was active and stop it
+ # As we are booted under systemd, we can just as well ask it ...
+ /bin/rm -f /tmp/systemd-migrate-active-$srv
+ if /bin/mountpoint -q /sys/fs/cgroup/systemd; then
+ active=$(/bin/systemctl show --no-pager -p ActiveState $srv.service 2> /dev/null)
+ if [ "${active#ActiveState=}" = active ]; then
+ /bin/touch /tmp/systemd-migrate-active-$srv
+ /bin/systemctl stop $srv.service
+ fi
+ fi
+
+ # enable units if service was active in run-levels 3 or 5.
+ # This loosely corresponds to systemctl is-enabled. We assume, that
+ # units do include correct [Install] entries.
+ if /sbin/chkconfig --no-redirect --level=3 $srv || \
+ /sbin/chkconfig --no-redirect --level=5 $srv; then
+ /bin/systemctl --no-reload --quiet enable "$@" || :
+ fi
+else
+ # Reload daemon after old package was removed
+ # Restart new units if old SysV script was started.
+ if /bin/mountpoint -q /sys/fs/cgroup/systemd; then
+ /bin/systemctl daemon-reload
+ if [ -f /tmp/systemd-migrate-active-$srv ]; then
+ /bin/systemctl start "$@"
+ fi
+ fi
+ /bin/rm -f /tmp/systemd-migrate-active-$srv
+fi
+
+# migrate-service ends here