Bug 160235 - Add support for /etc/init scripts
Add support for /etc/init scripts
Status: CLOSED CURRENTRELEASE
Product: 389
Classification: Community
Component: Admin (Show other bugs)
7.1
All Linux
medium Severity medium
: ---
: ---
Assigned To: Rich Megginson
Viktor Ashirov
:
: 159361 (view as bug list)
Depends On:
Blocks: 152373 159361 240316 FDS1.1.0
  Show dependency treegraph
 
Reported: 2005-06-13 14:46 EDT by Rich Megginson
Modified: 2015-12-07 11:57 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-12-07 11:57:03 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Rich Megginson 2005-06-13 14:46:54 EDT
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 14:54:19 EDT
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 14:55:41 EDT
Created attachment 115370 [details]
proposed /etc/sysconfig/ns-slapd file.
Comment 3 Sean Cotter 2005-07-22 20:07:51 EDT
*** Bug 159361 has been marked as a duplicate of this bug. ***
Comment 5 Rich Megginson 2007-01-10 11:43:27 EST
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 16:35:28 EST
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 16:36:03 EST
Created attachment 147815 [details]
proposed new initscript.in
Comment 8 Nathan Kinder 2007-02-09 17:13:28 EST
The changes look good.  The init scripts are stored in /sbin/init.d on HP-UX.
Comment 9 Rich Megginson 2007-02-09 17:34:54 EST
Created attachment 147821 [details]
cvs commit log
Comment 10 Rich Megginson 2007-02-12 15:12:13 EST
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 18:32:24 EST
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.