Bug 160235

Summary: Add support for /etc/init scripts
Product: [Retired] 389 Reporter: Rich Megginson <rmeggins>
Component: AdminAssignee: Rich Megginson <rmeggins>
Status: CLOSED CURRENTRELEASE QA Contact: Viktor Ashirov <vashirov>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: jim
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-12-07 16:57:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 152373, 159361, 240316, 427409    
Attachments:
Description Flags
proposed /etc/init.d/ns-slapd file
none
proposed /etc/sysconfig/ns-slapd file.
none
diffs
none
proposed new initscript.in
none
cvs commit log none

Description Rich Megginson 2005-06-13 18:46:54 UTC
These scripts are used with the init process to start up the server at boot time
and also to use the system management scripts to manage the slapd process.

Comment 1 Brian Jones 2005-06-13 18:54:19 UTC
Created attachment 115369 [details]
proposed /etc/init.d/ns-slapd file

This is a fairly standard sysv init script for ns-slapd. Someone wiser than I
can probably clean it up further.

Comment 2 Brian Jones 2005-06-13 18:55:41 UTC
Created attachment 115370 [details]
proposed /etc/sysconfig/ns-slapd file.

Comment 3 Sean Cotter 2005-07-23 00:07:51 UTC
*** Bug 159361 has been marked as a duplicate of this bug. ***

Comment 5 Rich Megginson 2007-01-10 16:43:27 UTC
If we are not going to support full SELinux policy, we need to use runcon to
allow the server to run unconfined while still allowing the rest of the OS to
run with SELinux enforcing:

runcon -t unconfined_t -- ns-slapd .... args ....
See bug 174855 and bug 172467

Also, if we are still going to support the start-admin and start-slapd scripts,
they too will need to use runcon.

Comment 6 Rich Megginson 2007-02-09 21:35:28 UTC
Created attachment 147814 [details]
diffs

Add the new initscript.  The initscript is called $PACKAGE_NAME which by
default is fedora-ds.  This script is created from wrappers/initscript.in,
sed'd by the fixupcmd in Makefile.am during make install.  The way it works is
this: service fedora-ds cmd will execute the cmd on all instances (found in
/etc/fedora-ds by default).  service fedora-ds cmd instance will execute cmd on
only that instance.  So if you have
/etc/fedora-ds/slapd-foo
/etc/fedora-ds/slapd-bar
and you do
service start fedora-ds
it will start up both slapd-foo and slapd-bar.	If you do
service start fedora-ds bar
it will start up only slapd-bar.  If you do
service start fedora-ds biff
you will get an error message.	The initdir is platform specific (e.g.
/etc/rc.d/init.d on linux, /etc/init.d on Solaris, ?? on hpux) so the
definition was added to the platform dependent section of configure.ac.

The init script is explicitly branded, including the filename.	I needed to add
support to the autotool files so that we could change the name of the file. 
Since package_name is defined when you use the AC_INIT macro in configure.ac,
we don't need to define it elsewhere (e.g. #define BRAND_DS).  So I added the
branding and other information to the autotool files, and changed
create_instance to use package_name instead of brand_ds to be consistent. 
Having the package_name defined in much fewer places should make it much easier
to change in the future if necessary.

I also fixed a compiler warning in ldaprot.h.

Comment 7 Rich Megginson 2007-02-09 21:36:03 UTC
Created attachment 147815 [details]
proposed new initscript.in

Comment 8 Nathan Kinder 2007-02-09 22:13:28 UTC
The changes look good.  The init scripts are stored in /sbin/init.d on HP-UX.

Comment 9 Rich Megginson 2007-02-09 22:34:54 UTC
Created attachment 147821 [details]
cvs commit log

Comment 10 Rich Megginson 2007-02-12 20:12:13 UTC
I had to remove some bash-isms that were causing the initscript to fail on RHEL-4.

diff -u -8 -r1.2 -r1.3
--- ldapserver/wrappers/initscript.in   12 Feb 2007 19:39:09 -0000      1.2
+++ ldapserver/wrappers/initscript.in   12 Feb 2007 20:10:21 -0000      1.3
@@ -39,24 +39,24 @@
 umask 077

 pids=$(pidof $exec)

 INSTANCES=""

 for FILE in `/bin/ls -d $instbase/slapd-* 2>/dev/null`; do
     if [ -d "$FILE" ] ; then
-        INSTANCES+=$(echo "$FILE" | sed -e "s|$instbase/slapd-||")
-        INSTANCES+=" "
+        inst=$(echo "$FILE" | sed -e "s|$instbase/slapd-||")
+        INSTANCES="$INSTANCES $inst"
     fi
 done

 if [ -n "$2" ]; then
    for I in $INSTANCES; do
-      if [ "$2" == "$I" ]; then
+      if [ "$2" = "$I" ]; then
          INSTANCES="$2"
       fi
    done
    if [ "$2" != "$INSTANCES" ]; then
       echo -n "$2 is an invalid @package_name@ instance"
       failure; echo
       exit 1
    fi

Checking in initscript.in;
/cvs/dirsec/ldapserver/wrappers/initscript.in,v  <--  initscript.in
new revision: 1.3; previous revision: 1.2
done


Comment 11 Yi Zhang 2007-12-03 23:32:24 UTC
Verification test: PASS
Test machine: cypher.dsdev.sjc.redhat.com (RHEL 5 64bit)

Test steps:

1. install DS on cypher.dsdev.sjc.redhat.com
2. do the following and verify desired result:
[root@neo ~]# /etc/init.d/dirsrv stop
Shutting down dirsrv: 
    neo...                                                 [  OK  ]
[root@neo ~]# /etc/init.d/dirsrv start
Starting dirsrv: 
    neo...                                                 [  OK  ]
[root@neo ~]# /etc/init.d/dirsrv status
dirsrv neo (pid 22019) is running...