aboutsummaryrefslogtreecommitdiffstats
path: root/add-service
diff options
context:
space:
mode:
Diffstat (limited to 'add-service')
-rwxr-xr-xadd-service20
1 files changed, 12 insertions, 8 deletions
diff --git a/add-service b/add-service
index c05ad5c..e7255e6 100755
--- a/add-service
+++ b/add-service
@@ -19,16 +19,20 @@ pkg=$1 # name of the package
num=$2 # number of packages installed
srv=$3 # name of the service
+systemd=no
+[ -x /bin/systemctl -a -r /lib/systemd/system/${srv}.service ] && systemd=yes
+
add_chkconfig_service() {
srv=$1
- /sbin/chkconfig --add $srv
- # support for systemd
- if [ -x /bin/systemctl ]; then
- /bin/systemctl enable ${srv}.service > /dev/null 2>&1
+ # support for systemd. chkconfig will do daemon-reload for us
+ if [ $systemd = yes ]; then
+ /bin/systemctl --quiet --no-reload enable ${srv}.service
fi
+ /sbin/chkconfig --add $srv
+
if [ -r /etc/sysconfig/system ]; then
. /etc/sysconfig/system
fi
@@ -75,17 +79,17 @@ else
# Upgrade mode
# if the service is activated, add it again to be able to handle
- # changes in start/stop levels
+ # 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: $*"
fi
if [ -f "$1" ]; then
- /sbin/chkconfig --add $srv
- if [ -x /bin/systemctl ]; then
- /bin/systemctl --enable ${srv}.service
+ if [ $systemd = yes ]; then
+ /bin/systemctl --quiet --no-reload enable ${srv}.service
fi
+ /sbin/chkconfig --add $srv
fi
# restart the service if already running