aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Borzenkov <arvidjaar@mandriva.org>2011-03-08 15:15:26 +0000
committerAndrey Borzenkov <arvidjaar@mandriva.org>2011-03-08 15:15:26 +0000
commit74eee552b4d032320f824289650b93cd3157d5ec (patch)
treeb0749f3f0ff89326b51558e806ae3f4fbbb62987
parent75a7dd657c4b9cc46b1f5647eda290d447ef398d (diff)
downloadrpm-helper-74eee552b4d032320f824289650b93cd3157d5ec.tar
rpm-helper-74eee552b4d032320f824289650b93cd3157d5ec.tar.gz
rpm-helper-74eee552b4d032320f824289650b93cd3157d5ec.tar.bz2
rpm-helper-74eee552b4d032320f824289650b93cd3157d5ec.tar.xz
rpm-helper-74eee552b4d032320f824289650b93cd3157d5ec.zip
also re-enable systemd unit in update if it was enabled
-rwxr-xr-xadd-service34
-rwxr-xr-xdel-service3
2 files changed, 21 insertions, 16 deletions
diff --git a/add-service b/add-service
index 9e25c37..46a98ac 100755
--- a/add-service
+++ b/add-service
@@ -26,6 +26,7 @@ options=--quiet
[ -x /bin/systemctl -a -r /lib/systemd/system/${srv}.service ] && systemd=yes
[ -r /etc/rc.d/init.d/${srv} ] && sysv=yes
[ $sysv = yes ] && options="$options --no-reload"
+unit=${srv}.service
add_chkconfig_service() {
srv=$1
@@ -33,7 +34,7 @@ add_chkconfig_service() {
# support for systemd. chkconfig will do daemon-reload for us
if [ $systemd = yes ]; then
- /bin/systemctl $options enable ${srv}.service
+ /bin/systemctl $options enable ${unit}
fi
if [ $sysv = yes ]; then
/sbin/chkconfig --add $srv
@@ -82,26 +83,29 @@ if [ $num = 1 ]; then
# First install mode
add_service
else
- # Upgrade mode. Only really makes sense for SysV scripts
- [ $sysv = yes ] || exit 0
+ # Upgrade mode.
# if the service is activated, add it again to be able to handle
- # changes in start/stop levels and enable systemd unit as well
- set -- /etc/rc3.d/S??$srv
- if [ $# -gt 1 ]; then
- echo 1>&2 "add-service: Error: $srv appears multiple times: $*"
+ # changes in start/stop levels or systemd WantedBy lines
+
+ if [ $systemd = yes ] && /bin/systemctl is-enabled ${unit}; then
+ /bin/systemctl --quiet enable ${unit}
fi
- if [ -f "$1" ]; then
- if [ $systemd = yes ]; then
- /bin/systemctl $options enable ${srv}.service
+ if [ $sysv = yes ]; then
+ set -- /etc/rc3.d/S??$srv
+ if [ $# -gt 1 ]; then
+ echo 1>&2 "add-service: Error: $srv appears multiple times: $*"
fi
- /sbin/chkconfig --add $srv
- fi
- # restart the service if already running
- if [ -f /var/lock/subsys/$srv ]; then
- /sbin/service $srv restart > /dev/null || :
+ if [ -f "$1" ]; then
+ /sbin/chkconfig --add $srv
+ fi
+
+ # restart the service if already running
+ if [ -f /var/lock/subsys/$srv ]; then
+ /sbin/service $srv restart > /dev/null || :
+ fi
fi
fi
diff --git a/del-service b/del-service
index 881bb99..c95f992 100755
--- a/del-service
+++ b/del-service
@@ -26,6 +26,7 @@ options=--quiet
[ -x /bin/systemctl -a -r /lib/systemd/system/${srv}.service ] && systemd=yes
[ -r /etc/rc.d/init.d/${srv} ] && sysv=yes
[ $sysv = yes ] && options="$options --no-reload"
+unit=${srv}.service
if [ $num = 0 ]; then
# Will be redirected to systemd if needed
@@ -35,7 +36,7 @@ if [ $num = 0 ]; then
# support for systemd. chkconfig will do daemon-reload for us
if [ $systemd = yes ]; then
- /bin/systemctl $options disable ${srv}.service
+ /bin/systemctl $options disable ${unit}
fi
if [ $sysv = yes ]; then
/sbin/chkconfig --del $srv