From a5e6e012576b432bd295611bb30c62ad6f68e818 Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@redhat.com>
Date: Thu, 21 Mar 2013 12:04:45 -0600
Subject: [PATCH 2/3] Ticket #47302 - get rid of sbindir start/stop/restart slapd scripts

https://fedorahosted.org/389/ticket/47302
Reviewed by: ???
Branch: master
Fix Description:
do not need sbindir -slapd scripts since we already had -dirsrv scripts -
start-dirsrv etc. - that already take an instance argument, although not
with -Z
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: Yes, if we have already documented sbindir start-slapd etc.
---
 Makefile.am                                      |    9 +---
 Makefile.in                                      |   11 +----
 ldap/admin/src/scripts/restart-slapd.in          |   50 ----------------------
 ldap/admin/src/scripts/start-slapd.in            |   50 ----------------------
 ldap/admin/src/scripts/stop-slapd.in             |   50 ----------------------
 ldap/admin/src/scripts/template-restart-slapd.in |    6 +--
 ldap/admin/src/scripts/template-start-slapd.in   |    7 +--
 ldap/admin/src/scripts/template-stop-slapd.in    |    6 +--
 8 files changed, 12 insertions(+), 177 deletions(-)
 delete mode 100644 ldap/admin/src/scripts/restart-slapd.in
 delete mode 100755 ldap/admin/src/scripts/start-slapd.in
 delete mode 100755 ldap/admin/src/scripts/stop-slapd.in

diff --git a/Makefile.am b/Makefile.am
index f25af58..6bff8e4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -122,9 +122,8 @@ CLEANFILES =  dberrstrs.h ns-slapd.properties \
 	ldap/admin/src/scripts/db2index ldap/admin/src/scripts/db2ldif \
 	ldap/admin/src/scripts/dn2rdn ldap/admin/src/scripts/ldif2db \
 	ldap/admin/src/scripts/ldif2ldap ldap/admin/src/scripts/monitor \
-	ldap/admin/src/scripts/restart-slapd ldap/admin/src/scripts/restoreconfig \
-	ldap/admin/src/scripts/saveconfig ldap/admin/src/scripts/start-slapd \
-	ldap/admin/src/scripts/stop-slapd ldap/admin/src/scripts/suffix2instance \
+	ldap/admin/src/scripts/restoreconfig ldap/admin/src/scripts/saveconfig  \
+	ldap/admin/src/scripts/suffix2instance \
 	ldap/admin/src/scripts/upgradednformat ldap/admin/src/scripts/vlvindex \
 	ldap/admin/src/scripts/bak2db.pl ldap/admin/src/scripts/db2bak.pl \
 	ldap/admin/src/scripts/db2index.pl ldap/admin/src/scripts/db2ldif.pl \
@@ -345,11 +344,8 @@ sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \
 	ldap/admin/src/scripts/ldif2db \
 	ldap/admin/src/scripts/ldif2ldap \
 	ldap/admin/src/scripts/monitor \
-	ldap/admin/src/scripts/restart-slapd \
 	ldap/admin/src/scripts/restoreconfig \
 	ldap/admin/src/scripts/saveconfig \
-	ldap/admin/src/scripts/start-slapd \
-	ldap/admin/src/scripts/stop-slapd \
 	ldap/admin/src/scripts/suffix2instance \
 	ldap/admin/src/scripts/upgradednformat \
 	ldap/admin/src/scripts/vlvindex \
@@ -510,7 +506,6 @@ dist_man_MANS = man/man1/dbscan.1 \
         man/man8/dbverify.8 man/man8/verify-db.pl.8 \
         man/man8/dn2rdn.8 man/man8/ldif2ldap.8 \
         man/man8/restoreconfig.8 man/man8/saveconfig.8 \
-        man/man8/start-slapd.8 man/man8/stop-slapd.8 man/man8/restart-slapd.8 \
         man/man8/suffix2instance.8 man/man8/monitor.8 \
         man/man8/upgradednformat.8 man/man8/vlvindex.8 \
         man/man8/cleanallruv.pl.8 man/man8/schema-reload.pl.8 \
diff --git a/Makefile.in b/Makefile.in
index c53b822..73c337a 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1412,9 +1412,8 @@ CLEANFILES = dberrstrs.h ns-slapd.properties \
 	ldap/admin/src/scripts/db2index ldap/admin/src/scripts/db2ldif \
 	ldap/admin/src/scripts/dn2rdn ldap/admin/src/scripts/ldif2db \
 	ldap/admin/src/scripts/ldif2ldap ldap/admin/src/scripts/monitor \
-	ldap/admin/src/scripts/restart-slapd ldap/admin/src/scripts/restoreconfig \
-	ldap/admin/src/scripts/saveconfig ldap/admin/src/scripts/start-slapd \
-	ldap/admin/src/scripts/stop-slapd ldap/admin/src/scripts/suffix2instance \
+	ldap/admin/src/scripts/restoreconfig ldap/admin/src/scripts/saveconfig  \
+	ldap/admin/src/scripts/suffix2instance \
 	ldap/admin/src/scripts/upgradednformat ldap/admin/src/scripts/vlvindex \
 	ldap/admin/src/scripts/bak2db.pl ldap/admin/src/scripts/db2bak.pl \
 	ldap/admin/src/scripts/db2index.pl ldap/admin/src/scripts/db2ldif.pl \
@@ -1573,11 +1572,8 @@ sbin_SCRIPTS = ldap/admin/src/scripts/setup-ds.pl \
 	ldap/admin/src/scripts/ldif2db \
 	ldap/admin/src/scripts/ldif2ldap \
 	ldap/admin/src/scripts/monitor \
-	ldap/admin/src/scripts/restart-slapd \
 	ldap/admin/src/scripts/restoreconfig \
 	ldap/admin/src/scripts/saveconfig \
-	ldap/admin/src/scripts/start-slapd \
-	ldap/admin/src/scripts/stop-slapd \
 	ldap/admin/src/scripts/suffix2instance \
 	ldap/admin/src/scripts/upgradednformat \
 	ldap/admin/src/scripts/vlvindex \
@@ -1735,7 +1731,6 @@ dist_man_MANS = man/man1/dbscan.1 \
         man/man8/dbverify.8 man/man8/verify-db.pl.8 \
         man/man8/dn2rdn.8 man/man8/ldif2ldap.8 \
         man/man8/restoreconfig.8 man/man8/saveconfig.8 \
-        man/man8/start-slapd.8 man/man8/stop-slapd.8 man/man8/restart-slapd.8 \
         man/man8/suffix2instance.8 man/man8/monitor.8 \
         man/man8/upgradednformat.8 man/man8/vlvindex.8 \
         man/man8/cleanallruv.pl.8 man/man8/schema-reload.pl.8 \
@@ -10497,7 +10492,7 @@ distcheck: dist
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
 	esac
-	chmod -R a-w $(distdir); chmod a+w $(distdir)
+	chmod -R a-w $(distdir); chmod u+w $(distdir)
 	mkdir $(distdir)/_build
 	mkdir $(distdir)/_inst
 	chmod a-w $(distdir)
diff --git a/ldap/admin/src/scripts/restart-slapd.in b/ldap/admin/src/scripts/restart-slapd.in
deleted file mode 100644
index 8a64e59..0000000
--- a/ldap/admin/src/scripts/restart-slapd.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-source @datadir@/dirsrv/data/DSSharedLib
-
-# Script that restarts the ns-slapd server.
-# Exit status can be:
-#       0: Server restarted successfully
-#       1: Server could not be started
-#       2: Server started successfully (was not running)
-#       3: Server could not be stopped
-
-usage ()
-{
-    echo "Usage: restart-slapd [-Z serverID]"
-}
-
-while getopts "Z:SvVhi:d:w:" flag
-do
-    case $flag in
-        Z) servid=$OPTARG;;
-        d) args=$args" -d $OPTARG";;
-        v) args=$args" -v";;
-        V) args=$args" -V";;
-        i) args=$args" -i $OPTARG";;
-        w) args=$args" -w $OPTARG";;
-        S) args=$args" -S";; 
-        h) usage
-           exit 0;;
-        ?) usage
-           exit 1;;
-    esac
-done
-
-servid=$(get_server_id "@initconfigdir@" $servid)
-if [ $? == 1 ]
-then
-    usage
-    echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
-    echo "Available instances: $servid"
-    exit 1
-fi
-
-@sbindir@/restart-dirsrv -d @initconfigdir@ $servid $args
-if [ $? == 0 ]
-then
-    echo Sucessfully restarted instance \"$servid\"
-else
-    echo Failed to restart instance \"$servid\"
-fi
-exit $?
diff --git a/ldap/admin/src/scripts/start-slapd.in b/ldap/admin/src/scripts/start-slapd.in
deleted file mode 100755
index f24aae7..0000000
--- a/ldap/admin/src/scripts/start-slapd.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-source @datadir@/dirsrv/data/DSSharedLib
-
-# Script that starts the ns-slapd server.
-# Exit status can be:
-#       0: Server started successfully
-#       1: Server could not be started
-#       2: Server already running
-
-usage ()
-{
-    echo "Usage: start-slapd [-Z serverID]"
-}
-
-while getopts "Z:SvVhi:d:w:" flag
-do
-    case $flag in
-        Z) servid=$OPTARG;;
-        d) args=$args" -d $OPTARG";;
-        v) args=$args" -v";;
-        V) args=$args" -V";;
-        i) args=$args" -i $OPTARG";;
-        w) args=$args" -w $OPTARG";;
-        S) args=$args" -S";;
-        h) usage
-           exit 0;;
-        ?) usage
-           exit 1;;
-    esac
-done
-
-servid=$(get_server_id "@initconfigdir@" $servid)
-if [ $? == 1 ]
-then
-    usage
-    echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
-    echo "Available instances: $servid"
-    exit 1
-fi
-
-@sbindir@/start-dirsrv -d @initconfigdir@ $servid $args
-if [ $? == 0 ]
-then
-    echo Sucessfully started instance \"$servid\"
-else
-    echo Failed to start instance \"$servid\"
-fi
-
-exit $?
diff --git a/ldap/admin/src/scripts/stop-slapd.in b/ldap/admin/src/scripts/stop-slapd.in
deleted file mode 100755
index 94d9858..0000000
--- a/ldap/admin/src/scripts/stop-slapd.in
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/sh
-
-source @datadir@/dirsrv/data/DSSharedLib
-
-# Script that stops the ns-slapd server.
-# Exit status can be:
-#       0: Server stopped successfully
-#       1: Server could not be stopped
-#       2: Server was not running
-
-usage ()
-{
-    echo "Usage: stop-slapd [-Z serverID]"
-}
-
-while getopts "Z:SvVhi:d:w:" flag
-do
-    case $flag in
-        Z) servid=$OPTARG;;
-        d) args=$args" -d $OPTARG";;
-        v) args=$args" -v";;
-        V) args=$args" -V";;
-        i) args=$args" -i $OPTARG";;
-        w) args=$args" -w $OPTARG";;
-        S) args=$args" -S";;
-        h) usage
-           exit 0;;
-        ?) usage
-           exit 1;;
-    esac
-done
-
-servid=$(get_server_id "@initconfigdir@" $servid)
-if [ $? == 1 ]
-then
-    usage
-    echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
-    echo "Available instances: $servid"
-    exit 1
-fi
-
-@sbindir@/stop-dirsrv -d @initconfigdir@ $servid $args
-if [ $? == 0 ]
-then
-    echo Sucessfully stopped instance \"$servid\"
-else
-    echo Failed to stop instance \"$servid\"
-fi
-
-exit $?
diff --git a/ldap/admin/src/scripts/template-restart-slapd.in b/ldap/admin/src/scripts/template-restart-slapd.in
index d169432..7933806 100644
--- a/ldap/admin/src/scripts/template-restart-slapd.in
+++ b/ldap/admin/src/scripts/template-restart-slapd.in
@@ -1,5 +1,3 @@
 #!/bin/sh
-
-cd {{SERVERBIN-DIR}}
-./restart-slapd "$@" -Z {{SERV-ID}}
-exit $?
\ No newline at end of file
+# DEPRECATED - use @sbindir@/restart-dirsrv instead
+exec @sbindir@/restart-dirsrv -d {{INITCONFIG-DIR}} {{SERV-ID}} "$@"
diff --git a/ldap/admin/src/scripts/template-start-slapd.in b/ldap/admin/src/scripts/template-start-slapd.in
index c5a9ca9..be59404 100755
--- a/ldap/admin/src/scripts/template-start-slapd.in
+++ b/ldap/admin/src/scripts/template-start-slapd.in
@@ -1,5 +1,4 @@
 #!/bin/sh
-
-cd {{SERVERBIN-DIR}}
-./start-slapd "$@" -Z {{SERV-ID}}
-exit $?
+# DEPRECATED - use @sbindir@/start-dirsrv instead
+INSTANCE={{SERV-ID}}
+exec @sbindir@/start-dirsrv -d {{INITCONFIG-DIR}} $INSTANCE "$@"
diff --git a/ldap/admin/src/scripts/template-stop-slapd.in b/ldap/admin/src/scripts/template-stop-slapd.in
index 7e1820a..3bf358d 100755
--- a/ldap/admin/src/scripts/template-stop-slapd.in
+++ b/ldap/admin/src/scripts/template-stop-slapd.in
@@ -1,5 +1,3 @@
 #!/bin/sh
-
-cd {{SERVERBIN-DIR}}
-./stop-slapd "$@" -Z {{SERV-ID}}
-exit $?
+# DEPRECATED - use @sbindir@/stop-dirsrv instead
+exec @sbindir@/stop-dirsrv -d {{INITCONFIG-DIR}} {{SERV-ID}} "$@"
-- 
1.7.1

