aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Borzenkov <arvidjaar@mandriva.org>2011-03-07 20:28:36 +0000
committerAndrey Borzenkov <arvidjaar@mandriva.org>2011-03-07 20:28:36 +0000
commit75a7dd657c4b9cc46b1f5647eda290d447ef398d (patch)
tree67339303775bb14a2632cd03df0eea8910e5fa61
parent7246df347ef8533b35723b1da4c288dece7ff467 (diff)
downloadrpm-helper-75a7dd657c4b9cc46b1f5647eda290d447ef398d.tar
rpm-helper-75a7dd657c4b9cc46b1f5647eda290d447ef398d.tar.gz
rpm-helper-75a7dd657c4b9cc46b1f5647eda290d447ef398d.tar.bz2
rpm-helper-75a7dd657c4b9cc46b1f5647eda290d447ef398d.tar.xz
rpm-helper-75a7dd657c4b9cc46b1f5647eda290d447ef398d.zip
also check for pure systemd configuration without sysv script
-rwxr-xr-xadd-service17
-rwxr-xr-xdel-service12
2 files changed, 22 insertions, 7 deletions
diff --git a/add-service b/add-service
index e7255e6..9e25c37 100755
--- a/add-service
+++ b/add-service
@@ -20,7 +20,12 @@ num=$2 # number of packages installed
srv=$3 # name of the service
systemd=no
+sysv=no
+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"
add_chkconfig_service() {
srv=$1
@@ -28,10 +33,11 @@ add_chkconfig_service() {
# support for systemd. chkconfig will do daemon-reload for us
if [ $systemd = yes ]; then
- /bin/systemctl --quiet --no-reload enable ${srv}.service
+ /bin/systemctl $options enable ${srv}.service
+ fi
+ if [ $sysv = yes ]; then
+ /sbin/chkconfig --add $srv
fi
-
- /sbin/chkconfig --add $srv
if [ -r /etc/sysconfig/system ]; then
. /etc/sysconfig/system
@@ -76,7 +82,8 @@ if [ $num = 1 ]; then
# First install mode
add_service
else
- # Upgrade mode
+ # Upgrade mode. Only really makes sense for SysV scripts
+ [ $sysv = yes ] || exit 0
# if the service is activated, add it again to be able to handle
# changes in start/stop levels and enable systemd unit as well
@@ -87,7 +94,7 @@ else
if [ -f "$1" ]; then
if [ $systemd = yes ]; then
- /bin/systemctl --quiet --no-reload enable ${srv}.service
+ /bin/systemctl $options enable ${srv}.service
fi
/sbin/chkconfig --add $srv
fi
diff --git a/del-service b/del-service
index 096d717..881bb99 100755
--- a/del-service
+++ b/del-service
@@ -20,18 +20,26 @@ num=$2 # number of packages installed
srv=$3 # name of the service
systemd=no
+sysv=no
+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"
if [ $num = 0 ]; then
+ # Will be redirected to systemd if needed
if [ -z "$DURING_INSTALL" ]; then
/sbin/service $srv stop > /dev/null || :
fi
# support for systemd. chkconfig will do daemon-reload for us
if [ $systemd = yes ]; then
- /bin/systemctl --quiet --no-reload disable ${srv}.service
+ /bin/systemctl $options disable ${srv}.service
+ fi
+ if [ $sysv = yes ]; then
+ /sbin/chkconfig --del $srv
fi
- /sbin/chkconfig --del $srv
fi
# del-service ends here