Bug 160235 - Add support for /etc/init scripts
Summary: Add support for /etc/init scripts
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: 389
Classification: Retired
Component: Admin
Version: 7.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Rich Megginson
QA Contact: Viktor Ashirov
URL:
Whiteboard:
: 159361 (view as bug list)
Depends On:
Blocks: 152373 159361 240316 FDS1.1.0
TreeView+ depends on / blocked
 
Reported: 2005-06-13 18:46 UTC by Rich Megginson
Modified: 2015-12-07 16:57 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-07 16:57:03 UTC
Embargoed:


Attachments (Terms of Use)
proposed /etc/init.d/ns-slapd file (1.51 KB, text/plain)
2005-06-13 18:54 UTC, Brian Jones
no flags Details
proposed /etc/sysconfig/ns-slapd file. (120 bytes, text/plain)
2005-06-13 18:55 UTC, Brian Jones
no flags Details
diffs (21.80 KB, patch)
2007-02-09 21:35 UTC, Rich Megginson
no flags Details | Diff
proposed new initscript.in (7.40 KB, text/plain)
2007-02-09 21:36 UTC, Rich Megginson
no flags Details
cvs commit log (2.30 KB, text/plain)
2007-02-09 22:34 UTC, Rich Megginson
no flags Details

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...



Note You need to log in before you can comment on or make changes to this bug.