|
|
ba46c7 |
From f808062081e1cbfeaf1419ba037aa0aa677a0e44 Mon Sep 17 00:00:00 2001
|
|
|
ba46c7 |
From: Mark Reynolds <mreynolds@redhat.com>
|
|
|
ba46c7 |
Date: Wed, 4 Sep 2013 11:43:22 -0400
|
|
|
ba46c7 |
Subject: [PATCH 3/4] Ticket 47500 - start-dirsrv/restart-dirsrv/stop-disrv do not register with systemd correctly
|
|
|
ba46c7 |
|
|
|
ba46c7 |
Description: If "systemctl" is available on the system, and the user is root, then
|
|
|
ba46c7 |
use systemctl to start & stop the server.
|
|
|
ba46c7 |
|
|
|
ba46c7 |
https://fedorahosted.org/389/ticket/47500
|
|
|
ba46c7 |
|
|
|
ba46c7 |
Reviewed by: richm(Thanks!)
|
|
|
ba46c7 |
(cherry picked from commit ba00d4885b93f8cc8d6eb1460bd0b5019e4d2fc2)
|
|
|
ba46c7 |
(cherry picked from commit 060c05c1d89ee92e17c797aa27d4a87a9f4789de)
|
|
|
ba46c7 |
---
|
|
|
ba46c7 |
ldap/admin/src/scripts/start-dirsrv.in | 18 ++++++++++++++----
|
|
|
ba46c7 |
ldap/admin/src/scripts/stop-dirsrv.in | 29 ++++++++++++++++++++++++++---
|
|
|
ba46c7 |
2 files changed, 40 insertions(+), 7 deletions(-)
|
|
|
ba46c7 |
|
|
|
ba46c7 |
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
|
|
|
ba46c7 |
index a163cef..481797d 100755
|
|
|
ba46c7 |
--- a/ldap/admin/src/scripts/start-dirsrv.in
|
|
|
ba46c7 |
+++ b/ldap/admin/src/scripts/start-dirsrv.in
|
|
|
ba46c7 |
@@ -60,11 +60,21 @@ start_instance() {
|
|
|
ba46c7 |
rm -f $PIDFILE
|
|
|
ba46c7 |
fi
|
|
|
ba46c7 |
fi
|
|
|
ba46c7 |
- cd $SERVERBIN_DIR; ./ns-slapd -D $CONFIG_DIR -i $PIDFILE -w $STARTPIDFILE "$@"
|
|
|
ba46c7 |
- if [ $? -ne 0 ]; then
|
|
|
ba46c7 |
- return 1
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ # Use systemctl if available and running as root,
|
|
|
ba46c7 |
+ # otherwise start the instance the old way.
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
|
|
|
ba46c7 |
+ @bindir@/systemctl start @package_name@@$SERV_ID.service
|
|
|
ba46c7 |
+ if [ $? -ne 0 ]; then
|
|
|
ba46c7 |
+ return 1
|
|
|
ba46c7 |
+ fi
|
|
|
ba46c7 |
+ else
|
|
|
ba46c7 |
+ cd $SERVERBIN_DIR; ./ns-slapd -D $CONFIG_DIR -i $PIDFILE -w $STARTPIDFILE "$@"
|
|
|
ba46c7 |
+ if [ $? -ne 0 ]; then
|
|
|
ba46c7 |
+ return 1
|
|
|
ba46c7 |
+ fi
|
|
|
ba46c7 |
fi
|
|
|
ba46c7 |
-
|
|
|
ba46c7 |
loop_counter=1
|
|
|
ba46c7 |
# wait for 10 seconds for the start pid file to appear
|
|
|
ba46c7 |
max_count=${STARTPID_TIME:-10}
|
|
|
ba46c7 |
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
|
|
|
ba46c7 |
index bc38134..3f02e78 100755
|
|
|
ba46c7 |
--- a/ldap/admin/src/scripts/stop-dirsrv.in
|
|
|
ba46c7 |
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
|
|
|
ba46c7 |
@@ -35,10 +35,33 @@ stop_instance() {
|
|
|
ba46c7 |
fi
|
|
|
ba46c7 |
return 2
|
|
|
ba46c7 |
}
|
|
|
ba46c7 |
- # server is running - kill it
|
|
|
ba46c7 |
- kill $PID
|
|
|
ba46c7 |
- loop_counter=1
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ # use systemctl if running as root
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ # Now, check if systemctl is aware of this running instance
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ @bindir@/systemctl is-active @package_name@@$SERV_ID.service > /dev/null 2>&1
|
|
|
ba46c7 |
+ if [ $? -eq 0 ]; then
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ # systemctl sees the running process, so stop it correctly
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ @bindir@/systemctl stop @package_name@@$SERV_ID.service
|
|
|
ba46c7 |
+ else
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ # Have to kill it since systemctl doesn't think it's running
|
|
|
ba46c7 |
+ #
|
|
|
ba46c7 |
+ kill $PID
|
|
|
ba46c7 |
+ fi
|
|
|
ba46c7 |
+ else
|
|
|
ba46c7 |
+ # server is running - kill it
|
|
|
ba46c7 |
+ kill $PID
|
|
|
ba46c7 |
+ fi
|
|
|
ba46c7 |
+
|
|
|
ba46c7 |
# wait for 10 minutes (600 times 1 second)
|
|
|
ba46c7 |
+ loop_counter=1
|
|
|
ba46c7 |
max_count=600
|
|
|
ba46c7 |
while test $loop_counter -le $max_count; do
|
|
|
ba46c7 |
loop_counter=`expr $loop_counter + 1`
|
|
|
ba46c7 |
--
|
|
|
ba46c7 |
1.7.1
|
|
|
ba46c7 |
|