andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 6 months ago
Clone

Blame SOURCES/0042-Ticket-47511-bashisms-in-389-ds-base-admin-scripts.patch

a2f18f
From 9075d78f6878907f676fda1062779c921b23ae59 Mon Sep 17 00:00:00 2001
a2f18f
From: Noriko Hosoi <nhosoi@redhat.com>
a2f18f
Date: Mon, 10 Aug 2015 17:04:25 -0700
a2f18f
Subject: [PATCH 42/45] Ticket #47511 - bashisms in 389-ds-base admin scripts
a2f18f
a2f18f
Description by mvocu (Thank you):
a2f18f
The shell scripts in 389-ds-base/ldap/admin/src/scripts use 'source'
a2f18f
to source common scripts; the 'source' keyword is bash-specific (or
a2f18f
c-shell, if memory serves). The interpreter is set to /bin/sh, which
a2f18f
is not guaranteed to be bash (and at least on Debian 7.1 it is dash).
a2f18f
The 'source' keyword can be replaced by '.', which should work.
a2f18f
a2f18f
The patch was provided by tjaalton@ubuntu.com (Thank you, Timo!).
a2f18f
a2f18f
https://fedorahosted.org/389/ticket/47511
a2f18f
a2f18f
Reviewed and tested by nhosoi@redhat.com.
a2f18f
a2f18f
(cherry picked from commit 2ce7a7334bcb89e47c0f5c544144aec37010a5b9)
a2f18f
(cherry picked from commit 49245911410cdd04bc53b00d8973c26defa5a37b)
a2f18f
---
a2f18f
 ldap/admin/src/initconfig.in              |  4 +-
a2f18f
 ldap/admin/src/scripts/DSSharedLib.in     | 92 +++++++++++++++----------------
a2f18f
 ldap/admin/src/scripts/bak2db.in          | 23 ++++----
a2f18f
 ldap/admin/src/scripts/db2bak.in          |  7 +--
a2f18f
 ldap/admin/src/scripts/db2index.in        |  4 +-
a2f18f
 ldap/admin/src/scripts/db2ldif.in         | 22 ++++----
a2f18f
 ldap/admin/src/scripts/dbverify.in        |  6 +-
a2f18f
 ldap/admin/src/scripts/dn2rdn.in          |  4 +-
a2f18f
 ldap/admin/src/scripts/ldif2db.in         |  4 +-
a2f18f
 ldap/admin/src/scripts/ldif2ldap.in       | 46 ++++++++--------
a2f18f
 ldap/admin/src/scripts/monitor.in         | 44 +++++++--------
a2f18f
 ldap/admin/src/scripts/restart-dirsrv.in  |  2 +-
a2f18f
 ldap/admin/src/scripts/restoreconfig.in   |  4 +-
a2f18f
 ldap/admin/src/scripts/saveconfig.in      |  6 +-
a2f18f
 ldap/admin/src/scripts/start-dirsrv.in    | 16 +++---
a2f18f
 ldap/admin/src/scripts/stop-dirsrv.in     | 14 ++---
a2f18f
 ldap/admin/src/scripts/suffix2instance.in |  6 +-
a2f18f
 ldap/admin/src/scripts/upgradedb.in       |  4 +-
a2f18f
 ldap/admin/src/scripts/upgradednformat.in |  6 +-
a2f18f
 ldap/admin/src/scripts/vlvindex.in        |  4 +-
a2f18f
 rpm/389-ds-base-git.sh                    |  2 +-
a2f18f
 rpm/add_patches.sh                        |  4 +-
a2f18f
 rpm/rpmverrel.sh                          |  2 +-
a2f18f
 wrappers/initscript.in                    | 26 +++------
a2f18f
 wrappers/ldap-agent-initscript.in         | 28 ++++------
a2f18f
 25 files changed, 181 insertions(+), 199 deletions(-)
a2f18f
a2f18f
diff --git a/ldap/admin/src/initconfig.in b/ldap/admin/src/initconfig.in
a2f18f
index 134e82c..7afa315 100644
a2f18f
--- a/ldap/admin/src/initconfig.in
a2f18f
+++ b/ldap/admin/src/initconfig.in
a2f18f
@@ -2,11 +2,11 @@
a2f18f
 OS=`uname -s`
a2f18f
 # use the new mt slab memory allocator on Solaris
a2f18f
 # this requires Solaris 9 update 3 or later
a2f18f
-if [ "$OS" = "SunOS" -a -f /usr/lib/libumem.so ] ; then
a2f18f
+if [ "$OS" = "SunOS" ] && [ -f /usr/lib/libumem.so ] ; then
a2f18f
     LD_PRELOAD=/usr/lib/libumem.so
a2f18f
     export LD_PRELOAD
a2f18f
 fi
a2f18f
-if [ "$OS" = "SunOS" -a -f /usr/lib/64/libumem.so ] ; then
a2f18f
+if [ "$OS" = "SunOS" ] && [ -f /usr/lib/64/libumem.so ] ; then
a2f18f
     LD_PRELOAD_64=/usr/lib/64/libumem.so
a2f18f
     export LD_PRELOAD_64
a2f18f
 fi
a2f18f
diff --git a/ldap/admin/src/scripts/DSSharedLib.in b/ldap/admin/src/scripts/DSSharedLib.in
a2f18f
index 3683696..8317c58 100644
a2f18f
--- a/ldap/admin/src/scripts/DSSharedLib.in
a2f18f
+++ b/ldap/admin/src/scripts/DSSharedLib.in
a2f18f
@@ -98,13 +98,13 @@ get_init_file()
a2f18f
     do
a2f18f
         inst_count=`expr $inst_count + 1`
a2f18f
         id=`normalize_server_id $configfile`
a2f18f
-        if [ -n "$servid" -a "$id" = "$servid" ]
a2f18f
+        if [ -n "$servid" ] && [ "$id" = "$servid" ]
a2f18f
         then
a2f18f
             # found it
a2f18f
             echo $configfile
a2f18f
             exit 0
a2f18f
         fi
a2f18f
-        if  [ $first == "yes" ]
a2f18f
+        if  [ $first = "yes" ]
a2f18f
         then
a2f18f
             instances=$id
a2f18f
             first="no"
a2f18f
@@ -114,7 +114,7 @@ get_init_file()
a2f18f
     done
a2f18f
 
a2f18f
     # server id not provided, check if there is only one instance
a2f18f
-    if [ -z "$servid" -a $inst_count -eq 1 ]
a2f18f
+    if [ -z "$servid" ] && [ $inst_count -eq 1 ]
a2f18f
     then
a2f18f
         # return the file
a2f18f
         echo $configfile
a2f18f
@@ -135,48 +135,44 @@ process_dse ()
a2f18f
     configdir=$1
a2f18f
     pid=$2
a2f18f
     file="$configdir/dse.ldif"
a2f18f
-    shopt -s nocasematch
a2f18f
-    OLD_IFC=$IFC
a2f18f
+    OLD_IFS=$IFS
a2f18f
     IFS=""
a2f18f
     while read -r LINE
a2f18f
     do
a2f18f
-        if [[ $LINE !=  \ * ]] && [ "$output" != "" ]
a2f18f
+        case $LINE in
a2f18f
+            ' '*)
a2f18f
+                ;;
a2f18f
+            *)
a2f18f
+                if [ -n "$output" ]
a2f18f
+                then
a2f18f
+                    echo "$output" >> /tmp/DSSharedLib.$pid
a2f18f
+                    output=""
a2f18f
+                fi
a2f18f
+                ;;
a2f18f
+        esac
a2f18f
+        if [ -n "$output" ]
a2f18f
         then
a2f18f
-            echo "$output" >> /tmp/DSSharedLib.$pid
a2f18f
-            output=""
a2f18f
-        fi
a2f18f
-        if [ "$output" != "" ] && [[ $LINE == \ * ]]
a2f18f
-        then
a2f18f
-            # continuation line, strip the space and append it
a2f18f
-            LINE=`echo "$LINE" | sed -e 's/^ //'`
a2f18f
-            output=$output$LINE
a2f18f
-        elif [[ $LINE == nsslapd-port* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-localhost* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-securePort* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-security* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-ldapilisten* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-ldapifilepath* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-rootdn* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-ldapiautobind* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
-        elif [[ $LINE == nsslapd-certdir* ]]
a2f18f
-        then
a2f18f
-            output=$LINE;
a2f18f
+            case $LINE in
a2f18f
+                ' '*)
a2f18f
+                    # continuation line, strip the space and append it
a2f18f
+                    LINE=`echo "$LINE" | sed -e 's/^ //'`
a2f18f
+                    output=$output$LINE
a2f18f
+                    ;;
a2f18f
+            esac
a2f18f
+        else
a2f18f
+            case $LINE in
a2f18f
+                nsslapd-certdir*|\
a2f18f
+                nsslapd-ldapiautobind*|\
a2f18f
+                nsslapd-ldapilisten*|\
a2f18f
+                nsslapd-ldapifilepath*|\
a2f18f
+                nsslapd-localhost*|\
a2f18f
+                nsslapd-port*|\
a2f18f
+                nsslapd-rootdn*|\
a2f18f
+                nsslapd-securePort*|\
a2f18f
+                nsslapd-security*)
a2f18f
+                    output=$LINE
a2f18f
+                    ;;
a2f18f
+            esac
a2f18f
         fi
a2f18f
     
a2f18f
     done < $file
a2f18f
@@ -194,19 +190,19 @@ check_protocol ()
a2f18f
     ldapi=$3
a2f18f
     openldap=$4
a2f18f
        
a2f18f
-    if [ "$protocol" == "LDAPI" ] && [ "$openldap" != "yes" ]; then
a2f18f
+    if [ "$protocol" = "LDAPI" ] && [ "$openldap" != "yes" ]; then
a2f18f
         echo ""
a2f18f
         exit
a2f18f
-    elif [ "$protocol" == "LDAPI" ] && [ "$ldapi" == "off" ]; then
a2f18f
+    elif [ "$protocol" = "LDAPI" ] && [ "$ldapi" = "off" ]; then
a2f18f
         echo ""
a2f18f
         exit
a2f18f
-    elif [ "$protocol" == "STARTTLS" ]; then
a2f18f
-        if [ "$security" == "" ] || [ "$security" == "off" ]; then
a2f18f
+    elif [ "$protocol" = "STARTTLS" ]; then
a2f18f
+        if [ -z "$security" ] || [ "$security" = "off" ]; then
a2f18f
             echo ""
a2f18f
             exit
a2f18f
         fi
a2f18f
-    elif [ "$protocol" == "LDAPS" ]; then
a2f18f
-        if [ "$security" == "" ] || [ "$security" == "off" ]; then
a2f18f
+    elif [ "$protocol" = "LDAPS" ]; then
a2f18f
+        if [ -z "$security" ] || [ "$security" = "off" ]; then
a2f18f
             echo ""
a2f18f
             exit
a2f18f
         fi
a2f18f
@@ -224,4 +220,4 @@ check_protocol ()
a2f18f
     fi
a2f18f
 
a2f18f
     echo "$protocol"
a2f18f
-}
a2f18f
\ No newline at end of file
a2f18f
+}
a2f18f
diff --git a/ldap/admin/src/scripts/bak2db.in b/ldap/admin/src/scripts/bak2db.in
a2f18f
index f0cede4..a2e54cc 100755
a2f18f
--- a/ldap/admin/src/scripts/bak2db.in
a2f18f
+++ b/ldap/admin/src/scripts/bak2db.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -26,15 +26,18 @@ if [ $# -lt 1 ] || [ $# -gt 7 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     exit 1
a2f18f
-elif [[ $1 == -* ]]
a2f18f
-then
a2f18f
-    usage
a2f18f
-    exit 1
a2f18f
-else
a2f18f
-    archivedir=$1
a2f18f
-    shift
a2f18f
 fi
a2f18f
-    
a2f18f
+case $1 in
a2f18f
+    -*)
a2f18f
+        usage
a2f18f
+        exit 1
a2f18f
+        ;;
a2f18f
+    *)
a2f18f
+        archivedir=$1
a2f18f
+        shift
a2f18f
+        ;;
a2f18f
+esac
a2f18f
+
a2f18f
 while getopts "hn:Z:qd:vi:a:SD:" flag
a2f18f
 do
a2f18f
     case $flag in
a2f18f
@@ -55,7 +58,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/db2bak.in b/ldap/admin/src/scripts/db2bak.in
a2f18f
index dacd7b0..1896c19 100755
a2f18f
--- a/ldap/admin/src/scripts/db2bak.in
a2f18f
+++ b/ldap/admin/src/scripts/db2bak.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -26,7 +26,6 @@ then
a2f18f
     usage
a2f18f
     exit 1
a2f18f
 fi
a2f18f
-
a2f18f
 if [ "$#" -gt 0 ]
a2f18f
 then
a2f18f
     if [[ $1 != -* ]]
a2f18f
@@ -56,7 +55,7 @@ done
a2f18f
 
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
@@ -67,7 +66,7 @@ fi
a2f18f
 servid=`normalize_server_id $initfile`
a2f18f
 . $initfile
a2f18f
 
a2f18f
-if [ -z $bak_dir ]
a2f18f
+if [ -z "$bak_dir" ]
a2f18f
 then
a2f18f
     bak_dir=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H_%M_%S`
a2f18f
 fi
a2f18f
diff --git a/ldap/admin/src/scripts/db2index.in b/ldap/admin/src/scripts/db2index.in
a2f18f
index a1321ea..2b76cd1 100755
a2f18f
--- a/ldap/admin/src/scripts/db2index.in
a2f18f
+++ b/ldap/admin/src/scripts/db2index.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -59,7 +59,7 @@ then
a2f18f
 fi
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/db2ldif.in b/ldap/admin/src/scripts/db2ldif.in
a2f18f
index d7e0ff0..fcf73a0 100755
a2f18f
--- a/ldap/admin/src/scripts/db2ldif.in
a2f18f
+++ b/ldap/admin/src/scripts/db2ldif.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -39,7 +39,7 @@ make_ldiffile()
a2f18f
     be=""
a2f18f
     while [ "$1" != "" ]
a2f18f
     do
a2f18f
-        if [ "$1" = "-a" ]; then
a2f18f
+        if [ "x$1" = "x-a" ]; then
a2f18f
             shift
a2f18f
             if [ `expr "$1" : "/.*"` -gt 0 ]; then 
a2f18f
 	            if [ `expr "$1" : "/.*"` -gt 0 ]; then 
a2f18f
@@ -56,17 +56,17 @@ make_ldiffile()
a2f18f
                 shift 
a2f18f
                 return 0 
a2f18f
             fi
a2f18f
-        elif [ "$1" = "-n" ]; then
a2f18f
+        elif [ "x$1" = "x-n" ]; then
a2f18f
             shift
a2f18f
-            if [ "$be" = "" ]; then
a2f18f
+            if [ -z "$be" ]; then
a2f18f
                 be="$1"
a2f18f
             else
a2f18f
                 tmpbe="$be"
a2f18f
                 be="${tmpbe}-$1"
a2f18f
             fi
a2f18f
-        elif [ "$1" = "-s" ]; then
a2f18f
+        elif [ "x$1" = "x-s" ]; then
a2f18f
             shift
a2f18f
-            if [ "$1" != "" ]; then
a2f18f
+            if [ -n "$1" ]; then
a2f18f
                 rdn=`echo $1 | awk -F, '{print $1}'`
a2f18f
                 rdnval=`echo $rdn | awk -F= '{print $2}'`
a2f18f
                 if [ "$be" = "" ]; then
a2f18f
@@ -76,15 +76,15 @@ make_ldiffile()
a2f18f
                     be="${tmpbe}-$rdnval"
a2f18f
                 fi
a2f18f
             fi
a2f18f
-        elif [ "$1" = "-M" ]; then
a2f18f
+        elif [ "x$1" = "x-M" ]; then
a2f18f
             be=""
a2f18f
         fi
a2f18f
-        if [ "$1" != "" ]; then
a2f18f
+        if [ -n "$1" ]; then
a2f18f
             shift
a2f18f
         fi
a2f18f
     done
a2f18f
 
a2f18f
-    if [ "$be" = "" ]; then
a2f18f
+    if [ -z "$be" ]; then
a2f18f
         echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
a2f18f
     else
a2f18f
         echo @localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/ldif/$servid-${be}-`date +%Y_%m_%d_%H%M%S`.ldif
a2f18f
@@ -92,7 +92,7 @@ make_ldiffile()
a2f18f
     return 0
a2f18f
 }
a2f18f
 
a2f18f
-if [ "$#" -lt 2 ];
a2f18f
+if [ $# -lt 2 ];
a2f18f
 then
a2f18f
     usage
a2f18f
     exit 1
a2f18f
@@ -137,7 +137,7 @@ then
a2f18f
 fi
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/dbverify.in b/ldap/admin/src/scripts/dbverify.in
a2f18f
index 461cc16..bbacc17 100755
a2f18f
--- a/ldap/admin/src/scripts/dbverify.in
a2f18f
+++ b/ldap/admin/src/scripts/dbverify.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -47,7 +47,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
@@ -58,7 +58,7 @@ fi
a2f18f
 . $initfile
a2f18f
 
a2f18f
 @sbindir@/ns-slapd dbverify -D $CONFIG_DIR $args
a2f18f
-if [ $display_version == "yes" ]; then
a2f18f
+if [ $display_version = "yes" ]; then
a2f18f
     exit 0
a2f18f
 fi
a2f18f
 if [ $? -eq 0 ]; then
a2f18f
diff --git a/ldap/admin/src/scripts/dn2rdn.in b/ldap/admin/src/scripts/dn2rdn.in
a2f18f
index 32a70c8..616969a 100755
a2f18f
--- a/ldap/admin/src/scripts/dn2rdn.in
a2f18f
+++ b/ldap/admin/src/scripts/dn2rdn.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -39,7 +39,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/ldif2db.in b/ldap/admin/src/scripts/ldif2db.in
a2f18f
index ce15349..a34241a 100755
a2f18f
--- a/ldap/admin/src/scripts/ldif2db.in
a2f18f
+++ b/ldap/admin/src/scripts/ldif2db.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -82,7 +82,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/ldif2ldap.in b/ldap/admin/src/scripts/ldif2ldap.in
a2f18f
index 874b1bb..1e871be 100755
a2f18f
--- a/ldap/admin/src/scripts/ldif2ldap.in
a2f18f
+++ b/ldap/admin/src/scripts/ldif2ldap.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@ldapsdk_libdir@"
a2f18f
 libpath_add "@libdir@"
a2f18f
@@ -40,14 +40,14 @@ do
a2f18f
     esac
a2f18f
 done
a2f18f
 
a2f18f
-if [ "$input_file" == "" ]
a2f18f
+if [ -z "$input_file" ]
a2f18f
 then 
a2f18f
     usage
a2f18f
     exit 1
a2f18f
 fi
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
@@ -67,13 +67,13 @@ ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' )
a2f18f
 ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' )
a2f18f
 certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' )
a2f18f
 autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' )
a2f18f
-if [ "$rootdn" == "" ]; then
a2f18f
+if [ -z "$rootdn" ]; then
a2f18f
     value=$(grep -i 'nsslapd-rootdn' $file)
a2f18f
     rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
a2f18f
 fi
a2f18f
 rm $file
a2f18f
 
a2f18f
-if [ "$ldapiURL" != "" ]; then
a2f18f
+if [ -n "$ldapiURL" ]; then
a2f18f
     ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
a2f18f
     ldapiURL="ldapi://"$ldapiURL
a2f18f
 fi
a2f18f
@@ -86,7 +86,7 @@ then
a2f18f
     export LDAPTLS_CACERTDIR=$certdir
a2f18f
 fi
a2f18f
 
a2f18f
-if [ -z $security ]; then
a2f18f
+if [ -z "$security" ]; then
a2f18f
     security="off"
a2f18f
 fi
a2f18f
 revised_protocol=$(check_protocol $protocol $security $ldapi $openldap)
a2f18f
@@ -99,12 +99,12 @@ protocol=$revised_protocol
a2f18f
 #
a2f18f
 # STARTTLS
a2f18f
 #
a2f18f
-if [ "$security" == "on" ]; then
a2f18f
-    if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
a2f18f
-        if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$security" = "on" ]; then
a2f18f
+    if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then
a2f18f
+        if [ "$error" = "yes" ]; then
a2f18f
             echo "Using the next most secure protocol(STARTTLS)"
a2f18f
         fi
a2f18f
-        if [ "$openldap" == "yes" ]; then
a2f18f
+        if [ "$openldap" = "yes" ]; then
a2f18f
             ldapmodify -x -ZZ -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
a2f18f
         else
a2f18f
             ldapmodify -ZZZ -P $certdir -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
a2f18f
@@ -116,12 +116,12 @@ fi
a2f18f
 #
a2f18f
 # LDAPS
a2f18f
 #
a2f18f
-if [ "$security" == "on" ]; then
a2f18f
-    if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
a2f18f
-        if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$security" = "on" ]; then
a2f18f
+    if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then
a2f18f
+        if [ "$error" = "yes" ]; then
a2f18f
             echo "Using the next most secure protocol(LDAPS)"
a2f18f
         fi
a2f18f
-        if [ "$openldap" == "yes" ]; then
a2f18f
+        if [ "$openldap" = "yes" ]; then
a2f18f
             ldapmodify -x -H "ldaps://$host:$secure_port" -D $rootdn -w $passwd -a -f $input_file
a2f18f
         else
a2f18f
             ldapmodify -Z -P $certdir -p $secure_port -h $host -D $rootdn -w $passwd -a -f $input_file 
a2f18f
@@ -133,21 +133,21 @@ fi
a2f18f
 #
a2f18f
 # LDAPI
a2f18f
 #
a2f18f
-if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
a2f18f
-    if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
a2f18f
-        if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
a2f18f
-            if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then
a2f18f
+    if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then
a2f18f
+        if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
a2f18f
+            if [ "$error" = "yes" ]; then
a2f18f
                 echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
a2f18f
             fi
a2f18f
             ldapmodify -H $ldapiURL -Y EXTERNAL -a -f $input_file 2>/dev/null
a2f18f
         else
a2f18f
-            if [ "$error" == "yes" ]; then 
a2f18f
+            if [ "$error" = "yes" ]; then
a2f18f
                 echo "Using the next most secure protocol(LDAPI)"
a2f18f
             fi
a2f18f
             ldapmodify -x -H $ldapiURL -D $rootdn -w $passwd -a -f $input_file
a2f18f
         fi
a2f18f
         rc=$?
a2f18f
-        if [ $rc != 0 ]
a2f18f
+        if [ $rc -ne 0 ]
a2f18f
         then
a2f18f
             echo "Operation failed (error $rc)"
a2f18f
         fi
a2f18f
@@ -158,11 +158,11 @@ fi
a2f18f
 #
a2f18f
 # LDAP
a2f18f
 #
a2f18f
-if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
a2f18f
-    if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$protocol" = "LDAP" ] || [ -z "$protocol" ]; then
a2f18f
+    if [ "$error" = "yes" ]; then
a2f18f
         echo "Using the next most secure protocol(LDAP)"
a2f18f
     fi
a2f18f
-    if [ "$openldap" == "yes" ]; then
a2f18f
+    if [ "$openldap" = "yes" ]; then
a2f18f
         ldapmodify -x -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
a2f18f
     else
a2f18f
         ldapmodify -p $port -h $host -D $rootdn -w $passwd -a -f $input_file
a2f18f
diff --git a/ldap/admin/src/scripts/monitor.in b/ldap/admin/src/scripts/monitor.in
a2f18f
index 7b2058b..36a2fc9 100755
a2f18f
--- a/ldap/admin/src/scripts/monitor.in
a2f18f
+++ b/ldap/admin/src/scripts/monitor.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@ldapsdk_libdir@"
a2f18f
@@ -41,7 +41,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
@@ -66,17 +66,17 @@ ldapi=$(grep -i 'nsslapd-ldapilisten' $file | awk '{print $2}' )
a2f18f
 ldapiURL=$(grep -i 'nsslapd-ldapifilepath' $file | awk '{print $2}' )
a2f18f
 certdir=$(grep -i 'nsslapd-certdir' $file | awk '{print $2}' )
a2f18f
 autobind=$(grep -i 'nsslapd-ldapiautobind' $file | awk '{print $2}' )
a2f18f
-if [ "$rootdn" == "" ]; then
a2f18f
+if [ -z "$rootdn" ]; then
a2f18f
     value=$(grep -i 'nsslapd-rootdn' $file)
a2f18f
     rootdn=`echo "$value" | sed -e 's/nsslapd-rootdn: //i'`
a2f18f
 fi
a2f18f
 rm $file
a2f18f
 
a2f18f
-if [ "$passwd" != "" ]; then
a2f18f
+if [ -n "$passwd" ]; then
a2f18f
     dn="-D $rootdn"
a2f18f
     passwd="-w$passwd"
a2f18f
 fi
a2f18f
-if [ "$ldapiURL" != "" ]
a2f18f
+if [ -n "$ldapiURL" ]
a2f18f
 then
a2f18f
     ldapiURL=`echo "$ldapiURL" | sed -e 's/\//%2f/g'`
a2f18f
     ldapiURL="ldapi://"$ldapiURL
a2f18f
@@ -103,12 +103,12 @@ protocol=$revised_protocol
a2f18f
 #
a2f18f
 # STARTTLS
a2f18f
 #
a2f18f
-if [ "$security" == "on" ]; then
a2f18f
-    if [ "$protocol" == "STARTTLS" ] || [ "$protocol" == "" ]; then
a2f18f
-        if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$security" = "on" ]; then
a2f18f
+    if [ "$protocol" = "STARTTLS" ] || [ -z "$protocol" ]; then
a2f18f
+        if [ "$error" = "yes" ]; then
a2f18f
             echo "Using the next most secure protocol(STARTTLS)"
a2f18f
         fi
a2f18f
-        if [ "$openldap" == "yes" ]; then
a2f18f
+        if [ "$openldap" = "yes" ]; then
a2f18f
             ldapsearch -x -LLL -ZZ -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
         else
a2f18f
             ldapsearch -ZZZ -P $certdir  -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
@@ -120,12 +120,12 @@ fi
a2f18f
 #
a2f18f
 # LDAPS
a2f18f
 #
a2f18f
-if [ "$security" == "on" ]; then
a2f18f
-    if [ "$protocol" == "LDAPS" ] || [ "$protocol" == "" ]; then
a2f18f
-        if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$security" = "on" ]; then
a2f18f
+    if [ "$protocol" = "LDAPS" ] || [ -z "$protocol" ]; then
a2f18f
+        if [ "$error" = "yes" ]; then
a2f18f
             echo "Using the next most secure protocol(LDAPS)"
a2f18f
         fi
a2f18f
-        if [ "$openldap" == "yes" ]; then
a2f18f
+        if [ "$openldap" = "yes" ]; then
a2f18f
             ldapsearch -x -LLL -H "ldaps://$host:$secure_port" -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
         else 
a2f18f
             ldapsearch -Z -P $certdir -p $secure_port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
@@ -137,15 +137,15 @@ fi
a2f18f
 #
a2f18f
 # LDAPI
a2f18f
 #
a2f18f
-if [ "$ldapi" == "on" ] && [ "$openldap" == "yes" ]; then
a2f18f
-    if [ "$protocol" == "LDAPI" ] || [ "$protocol" == "" ]; then
a2f18f
-        if [ "$(id -u)" == "0" ] && [ "$autobind" == "on" ]; then
a2f18f
-            if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$ldapi" = "on" ] && [ "$openldap" = "yes" ]; then
a2f18f
+    if [ "$protocol" = "LDAPI" ] || [ -z "$protocol" ]; then
a2f18f
+        if [ $(id -u) -eq 0 ] && [ "$autobind" = "on" ]; then
a2f18f
+            if [ "$error" = "yes" ]; then
a2f18f
                 echo "Using the next most secure protocol(LDAPI/AUTOBIND)"
a2f18f
             fi
a2f18f
             ldapsearch -LLL -H "$ldapiURL" -b "$MDN" -s base -Y EXTERNAL "objectClass=*" 2>/dev/null
a2f18f
         else
a2f18f
-            if [ "$error" == "yes" ]; then 
a2f18f
+            if [ "$error" = "yes" ]; then
a2f18f
                 echo "Using the next most secure protocol(LDAPI)"
a2f18f
             fi
a2f18f
             ldapsearch -x -LLL -H "$ldapiURL" -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
@@ -157,14 +157,14 @@ fi
a2f18f
 #
a2f18f
 # LDAP
a2f18f
 #
a2f18f
-if [ "$protocol" == "LDAP" ] || [ "$protocol" == "" ]; then
a2f18f
-    if [ "$error" == "yes" ]; then 
a2f18f
+if [ "$protocol" = "LDAP" ] || [ "$protocol" = "" ]; then
a2f18f
+    if [ "$error" = "yes" ]; then
a2f18f
         echo "Using the next most secure protocol(LDAP)"
a2f18f
     fi
a2f18f
-    if [ "$openldap" == "yes" ]; then
a2f18f
+    if [ "$openldap" = "yes" ]; then
a2f18f
         ldapsearch -x -LLL -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
     else
a2f18f
         ldapsearch -h $host -p $port -b "$MDN" -s base $dn $passwd "objectClass=*"
a2f18f
-    fi   
a2f18f
+    fi
a2f18f
     exit $?
a2f18f
 fi
a2f18f
diff --git a/ldap/admin/src/scripts/restart-dirsrv.in b/ldap/admin/src/scripts/restart-dirsrv.in
a2f18f
index 130e06e..e86a24c 100644
a2f18f
--- a/ldap/admin/src/scripts/restart-dirsrv.in
a2f18f
+++ b/ldap/admin/src/scripts/restart-dirsrv.in
a2f18f
@@ -7,7 +7,7 @@
a2f18f
 #       2: Server started successfully (was not running)
a2f18f
 #       3: Server could not be stopped
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 restart_instance() {
a2f18f
     SERV_ID=$1
a2f18f
diff --git a/ldap/admin/src/scripts/restoreconfig.in b/ldap/admin/src/scripts/restoreconfig.in
a2f18f
index 9bb1acf..56c9e43 100755
a2f18f
--- a/ldap/admin/src/scripts/restoreconfig.in
a2f18f
+++ b/ldap/admin/src/scripts/restoreconfig.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@nss_libdir@"
a2f18f
@@ -31,7 +31,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/saveconfig.in b/ldap/admin/src/scripts/saveconfig.in
a2f18f
index 65d80f3..16e3efc 100755
a2f18f
--- a/ldap/admin/src/scripts/saveconfig.in
a2f18f
+++ b/ldap/admin/src/scripts/saveconfig.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@libdir@"
a2f18f
@@ -31,7 +31,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
@@ -45,7 +45,7 @@ servid=`normalize_server_id $initfile`
a2f18f
 echo saving configuration...
a2f18f
 conf_ldif=@localstatedir@/lib/@PACKAGE_NAME@/slapd-$servid/bak/$servid-`date +%Y_%m_%d_%H%M%S`.ldif
a2f18f
 @sbindir@/ns-slapd db2ldif -N -D $CONFIG_DIR -s "o=NetscapeRoot" -a $conf_ldif -n NetscapeRoot 2>&1
a2f18f
-if [ "$?" -ge 1 ] 
a2f18f
+if [ $? -ge 1 ]
a2f18f
 then
a2f18f
     echo Error occurred while saving configuration
a2f18f
     exit 1
a2f18f
diff --git a/ldap/admin/src/scripts/start-dirsrv.in b/ldap/admin/src/scripts/start-dirsrv.in
a2f18f
index 481797d..458f0e8 100755
a2f18f
--- a/ldap/admin/src/scripts/start-dirsrv.in
a2f18f
+++ b/ldap/admin/src/scripts/start-dirsrv.in
a2f18f
@@ -6,7 +6,7 @@
a2f18f
 #       1: Server could not be started
a2f18f
 #       2: Server already running
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 # Starts a single instance
a2f18f
 start_instance() {
a2f18f
@@ -44,7 +44,7 @@ start_instance() {
a2f18f
     STARTPIDFILE=$RUN_DIR/$PRODUCT_NAME-$SERV_ID.startpid
a2f18f
     if test -f $STARTPIDFILE ; then
a2f18f
         PID=`cat $STARTPIDFILE`
a2f18f
-        if kill -0 $PID > /dev/null 2>&1 ; then
a2f18f
+        if kill -s 0 $PID > /dev/null 2>&1 ; then
a2f18f
             echo There is an ns-slapd process already running: $PID
a2f18f
             return 2;
a2f18f
         else
a2f18f
@@ -53,7 +53,7 @@ start_instance() {
a2f18f
     fi
a2f18f
     if test -f $PIDFILE ; then
a2f18f
         PID=`cat $PIDFILE`
a2f18f
-        if kill -0 $PID > /dev/null 2>&1 ; then
a2f18f
+        if kill -s 0 $PID > /dev/null 2>&1 ; then
a2f18f
             echo There is an ns-slapd running: $PID
a2f18f
             return 2;
a2f18f
         else
a2f18f
@@ -64,7 +64,7 @@ start_instance() {
a2f18f
     # Use systemctl if available and running as root, 
a2f18f
     # otherwise start the instance the old way.
a2f18f
     #
a2f18f
-    if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
a2f18f
+    if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
a2f18f
         @bindir@/systemctl start @package_name@@$SERV_ID.service
a2f18f
         if [ $? -ne 0 ]; then
a2f18f
             return 1
a2f18f
@@ -96,7 +96,7 @@ start_instance() {
a2f18f
     while test $loop_counter -le $max_count; do
a2f18f
         loop_counter=`expr $loop_counter + 1`
a2f18f
         if test ! -f $PIDFILE ; then
a2f18f
-            if kill -0 $PID > /dev/null 2>&1 ; then
a2f18f
+            if kill -s 0 $PID > /dev/null 2>&1 ; then
a2f18f
                 sleep 1
a2f18f
         else
a2f18f
             echo Server failed to start !!! Please check errors log for problems
a2f18f
@@ -123,12 +123,12 @@ do
a2f18f
 done
a2f18f
 shift $(($OPTIND-1))
a2f18f
 
a2f18f
-if [ "$initconfig_dir" = "" ]; then
a2f18f
+if [ -z "$initconfig_dir" ]; then
a2f18f
     initconfig_dir=@initconfigdir@
a2f18f
 fi
a2f18f
 
a2f18f
 found=0
a2f18f
-if [ "$#" -eq 0 ]; then
a2f18f
+if [ $# -eq 0 ]; then
a2f18f
     # We're starting all instances.
a2f18f
     ret=0
a2f18f
     initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
a2f18f
@@ -137,7 +137,7 @@ if [ "$#" -eq 0 ]; then
a2f18f
         echo Starting instance \"$inst\"
a2f18f
         start_instance $inst
a2f18f
         rv=$?
a2f18f
-        if [ "$rv" -ne 0 ]; then
a2f18f
+        if [ $rv -ne 0 ]; then
a2f18f
             ret=$rv
a2f18f
         fi
a2f18f
     done
a2f18f
diff --git a/ldap/admin/src/scripts/stop-dirsrv.in b/ldap/admin/src/scripts/stop-dirsrv.in
a2f18f
index 3f02e78..72e2b85 100755
a2f18f
--- a/ldap/admin/src/scripts/stop-dirsrv.in
a2f18f
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
a2f18f
@@ -6,7 +6,7 @@
a2f18f
 #       1: Server could not be stopped
a2f18f
 #       2: Server was not running
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 stop_instance() {
a2f18f
     SERV_ID=$1
a2f18f
@@ -28,7 +28,7 @@ stop_instance() {
a2f18f
     fi
a2f18f
     PID=`cat $PIDFILE`
a2f18f
     # see if the server is already stopped
a2f18f
-    kill -0 $PID > /dev/null 2>&1 || {
a2f18f
+    kill -s 0 $PID > /dev/null 2>&1 || {
a2f18f
         echo Server not running
a2f18f
         if test -f $PIDFILE ; then
a2f18f
             rm -f $PIDFILE
a2f18f
@@ -39,7 +39,7 @@ stop_instance() {
a2f18f
     #
a2f18f
     # use systemctl if running as root
a2f18f
     #
a2f18f
-    if [ -d "@systemdsystemunitdir@" ] && [ "$(id -u)" == "0" ];then
a2f18f
+    if [ -d "@systemdsystemunitdir@" ] && [ $(id -u) -eq 0 ];then
a2f18f
         # 
a2f18f
         # Now, check if systemctl is aware of this running instance
a2f18f
         #
a2f18f
@@ -65,7 +65,7 @@ stop_instance() {
a2f18f
     max_count=600
a2f18f
     while test $loop_counter -le $max_count; do
a2f18f
         loop_counter=`expr $loop_counter + 1`
a2f18f
-        if kill -0 $PID > /dev/null 2>&1 ; then
a2f18f
+        if kill -s 0 $PID > /dev/null 2>&1 ; then
a2f18f
             sleep 1;
a2f18f
         else
a2f18f
             if test -f $PIDFILE ; then
a2f18f
@@ -88,11 +88,11 @@ do
a2f18f
 done
a2f18f
 shift $(($OPTIND-1))
a2f18f
 
a2f18f
-if [ "$initconfig_dir" = "" ]; then
a2f18f
+if [ -z "$initconfig_dir" ]; then
a2f18f
     initconfig_dir=@initconfigdir@
a2f18f
 fi
a2f18f
 
a2f18f
-if [ "$#" -eq 0 ]; then
a2f18f
+if [ $# -eq 0 ]; then
a2f18f
     # We're stopping all instances.
a2f18f
     ret=0
a2f18f
     initfiles=`get_initconfig_files $initconfig_dir` || { echo No instances found in $initconfig_dir ; exit 1 ; }
a2f18f
@@ -105,7 +105,7 @@ if [ "$#" -eq 0 ]; then
a2f18f
         echo Stopping instance \"$inst\"
a2f18f
         stop_instance $inst
a2f18f
         rv=$?
a2f18f
-        if [ "$rv" -ne 0 ]; then
a2f18f
+        if [ $rv -ne 0 ]; then
a2f18f
             ret=$rv
a2f18f
         fi
a2f18f
     done
a2f18f
diff --git a/ldap/admin/src/scripts/suffix2instance.in b/ldap/admin/src/scripts/suffix2instance.in
a2f18f
index e2f73c3..7774148 100755
a2f18f
--- a/ldap/admin/src/scripts/suffix2instance.in
a2f18f
+++ b/ldap/admin/src/scripts/suffix2instance.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@libdir@"
a2f18f
@@ -32,14 +32,14 @@ do
a2f18f
     esac
a2f18f
 done
a2f18f
 
a2f18f
-if [ "$args" == "" ]
a2f18f
+if [ -z "$args" ]
a2f18f
 then
a2f18f
     usage
a2f18f
     exit 1
a2f18f
 fi
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/upgradedb.in b/ldap/admin/src/scripts/upgradedb.in
a2f18f
index 211bdce..bf600dd 100755
a2f18f
--- a/ldap/admin/src/scripts/upgradedb.in
a2f18f
+++ b/ldap/admin/src/scripts/upgradedb.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@libdir@"
a2f18f
@@ -39,7 +39,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
     echo "Available instances: $initfile"
a2f18f
diff --git a/ldap/admin/src/scripts/upgradednformat.in b/ldap/admin/src/scripts/upgradednformat.in
a2f18f
index e9d8cab..51585ae 100755
a2f18f
--- a/ldap/admin/src/scripts/upgradednformat.in
a2f18f
+++ b/ldap/admin/src/scripts/upgradednformat.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 # upgradednformat -- upgrade DN format to the new style (RFC 4514)
a2f18f
 # Usgae: upgradednformat [-N] -n backend_instance -a db_instance_directory
a2f18f
@@ -49,13 +49,13 @@ do
a2f18f
     esac
a2f18f
 done
a2f18f
 
a2f18f
-if [ "$be" = "" ] || [ "$dir" = "" ]; then
a2f18f
+if [ -z "$be" ] || [ -z "$dir" ]; then
a2f18f
     usage
a2f18f
     exit 1
a2f18f
 fi
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/ldap/admin/src/scripts/vlvindex.in b/ldap/admin/src/scripts/vlvindex.in
a2f18f
index 0b46b27..365e32f 100755
a2f18f
--- a/ldap/admin/src/scripts/vlvindex.in
a2f18f
+++ b/ldap/admin/src/scripts/vlvindex.in
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-source @datadir@/@package_name@/data/DSSharedLib
a2f18f
+. @datadir@/@package_name@/data/DSSharedLib
a2f18f
 
a2f18f
 libpath_add "@libdir@/@package_name@/"
a2f18f
 libpath_add "@libdir@"
a2f18f
@@ -45,7 +45,7 @@ do
a2f18f
 done
a2f18f
 
a2f18f
 initfile=$(get_init_file "@initconfigdir@" $servid)
a2f18f
-if [ $? == 1 ]
a2f18f
+if [ $? -eq 1 ]
a2f18f
 then
a2f18f
     usage
a2f18f
     echo "You must supply a valid server instance identifier.  Use -Z to specify instance name"
a2f18f
diff --git a/rpm/389-ds-base-git.sh b/rpm/389-ds-base-git.sh
a2f18f
index e5aaa8a..1a38da1 100644
a2f18f
--- a/rpm/389-ds-base-git.sh
a2f18f
+++ b/rpm/389-ds-base-git.sh
a2f18f
@@ -1,4 +1,4 @@
a2f18f
-#!/bin/bash
a2f18f
+#!/bin/sh
a2f18f
 
a2f18f
 DATE=`date +%Y%m%d`
a2f18f
 # use a real tag name here
a2f18f
diff --git a/rpm/add_patches.sh b/rpm/add_patches.sh
a2f18f
index 690d0b2..31823d5 100755
a2f18f
--- a/rpm/add_patches.sh
a2f18f
+++ b/rpm/add_patches.sh
a2f18f
@@ -1,6 +1,6 @@
a2f18f
 #!/bin/sh
a2f18f
 
a2f18f
-function usage()
a2f18f
+usage()
a2f18f
 {
a2f18f
     echo "Adds patches to a specfile"
a2f18f
     echo ""
a2f18f
@@ -51,5 +51,5 @@ for p in $patches; do
a2f18f
     sed -i -e "/${prefix}/a Patch${i}: ${p}" -e "/$prepprefix/a %patch${i} -p1" $specfile
a2f18f
     prefix="Patch${i}:"
a2f18f
     prepprefix="%patch${i}"
a2f18f
-    i=$(($i+1))
a2f18f
+    i=`expr $i + 1`
a2f18f
 done
a2f18f
diff --git a/rpm/rpmverrel.sh b/rpm/rpmverrel.sh
a2f18f
index 86b808e..06e97c7 100755
a2f18f
--- a/rpm/rpmverrel.sh
a2f18f
+++ b/rpm/rpmverrel.sh
a2f18f
@@ -6,7 +6,7 @@ srcdir=`pwd`
a2f18f
 
a2f18f
 # Source VERSION.sh to set the version
a2f18f
 # and release environment variables.
a2f18f
-source ./VERSION.sh
a2f18f
+. ./VERSION.sh
a2f18f
 
a2f18f
 if [ "$1" = "version" ]; then
a2f18f
   echo $RPM_VERSION
a2f18f
diff --git a/wrappers/initscript.in b/wrappers/initscript.in
a2f18f
index ad4ea2b..fa79dbd 100644
a2f18f
--- a/wrappers/initscript.in
a2f18f
+++ b/wrappers/initscript.in
a2f18f
@@ -32,28 +32,20 @@ then
a2f18f
     fi
a2f18f
 fi
a2f18f
 
a2f18f
-# figure out which echo we're using
a2f18f
-ECHO_N=`echo -n`
a2f18f
-
a2f18f
-# some shells echo cannot use -n - linux echo by default cannot use \c
a2f18f
 echo_n()
a2f18f
 {
a2f18f
-    if [ "$ECHO_N" = '-n' ] ; then
a2f18f
-        echo "$*\c"
a2f18f
-    else
a2f18f
-        echo -n "$*"
a2f18f
-    fi
a2f18f
+    printf '%s' "$*"
a2f18f
 }
a2f18f
 
a2f18f
 # failure and success are not defined on some platforms
a2f18f
-type failure > /dev/null 2>&1 || {
a2f18f
+which failure > /dev/null 2>&1 || {
a2f18f
 failure()
a2f18f
 {
a2f18f
     echo_n " FAILED"
a2f18f
 }
a2f18f
 }
a2f18f
 
a2f18f
-type success > /dev/null 2>&1 || {
a2f18f
+which success > /dev/null 2>&1 || {
a2f18f
 success()
a2f18f
 {
a2f18f
     echo_n " SUCCESS"
a2f18f
@@ -178,7 +170,7 @@ start() {
a2f18f
             pid=`cat $pidfile`
a2f18f
             instlockfile="@localstatedir@/lock/@package_name@/slapd-$instance/server/$pid"
a2f18f
             name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
a2f18f
-            if kill -0 $pid && [ $name = "ns-slapd" ]; then
a2f18f
+            if kill -s 0 $pid && [ $name = "ns-slapd" ]; then
a2f18f
                 echo_n " already running"
a2f18f
                 success; echo
a2f18f
                 successes=`expr $successes + 1`
a2f18f
@@ -239,7 +231,7 @@ start() {
a2f18f
             while test $loop_counter -le $max_count ; do
a2f18f
                 loop_counter=`expr $loop_counter + 1`
a2f18f
                 if test ! -f $pidfile ; then
a2f18f
-                    if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+                    if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
                         sleep 1
a2f18f
                     else
a2f18f
                         break
a2f18f
@@ -249,7 +241,7 @@ start() {
a2f18f
                     break
a2f18f
                 fi
a2f18f
             done
a2f18f
-            if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
a2f18f
+            if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
a2f18f
                 success; echo
a2f18f
                 successes=`expr $successes + 1`
a2f18f
             else
a2f18f
@@ -278,7 +270,7 @@ stop() {
a2f18f
         if [ -f $pidfile ]; then
a2f18f
             pid=`cat $pidfile`
a2f18f
             server_stopped=0
a2f18f
-            if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+            if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
                 kill $pid
a2f18f
                 if [ $? -eq 0 ]; then
a2f18f
                     server_stopped=1
a2f18f
@@ -297,7 +289,7 @@ stop() {
a2f18f
                 max_count=600
a2f18f
                 while test $loop_counter -le $max_count; do
a2f18f
                     loop_counter=`expr $loop_counter + 1`
a2f18f
-                    if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+                    if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
                         sleep 1
a2f18f
                     else
a2f18f
                         if test -f $pidfile ; then
a2f18f
@@ -339,7 +331,7 @@ status() {
a2f18f
      for instance in $INSTANCES; do
a2f18f
          if [ -f $piddir/slapd-$instance.pid ]; then
a2f18f
              pid=`cat $piddir/slapd-$instance.pid`
a2f18f
-             if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+             if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
                  echo "$prog $instance (pid $pid) is running..."
a2f18f
              else
a2f18f
                 echo "$prog $instance dead but pid file exists"
a2f18f
diff --git a/wrappers/ldap-agent-initscript.in b/wrappers/ldap-agent-initscript.in
a2f18f
index dd8ee97..b7aa4fe 100644
a2f18f
--- a/wrappers/ldap-agent-initscript.in
a2f18f
+++ b/wrappers/ldap-agent-initscript.in
a2f18f
@@ -31,28 +31,20 @@ then
a2f18f
     fi
a2f18f
 fi
a2f18f
 
a2f18f
-# figure out which echo we're using
a2f18f
-ECHO_N=`echo -n`
a2f18f
-
a2f18f
-# some shells echo cannot use -n - linux echo by default cannot use \c
a2f18f
 echo_n()
a2f18f
 {
a2f18f
-    if [ "$ECHO_N" = '-n' ] ; then
a2f18f
-        echo "$*\c"
a2f18f
-    else
a2f18f
-        echo -n "$*"
a2f18f
-    fi
a2f18f
+    printf '%s' "$*"
a2f18f
 }
a2f18f
 
a2f18f
 # failure and success are not defined on some platforms
a2f18f
-type failure > /dev/null 2>&1 || {
a2f18f
+which failure > /dev/null 2>&1 || {
a2f18f
 failure()
a2f18f
 {
a2f18f
     echo_n " FAILED"
a2f18f
 }
a2f18f
 }
a2f18f
 
a2f18f
-type success > /dev/null 2>&1 || {
a2f18f
+which success > /dev/null 2>&1 || {
a2f18f
 success()
a2f18f
 {
a2f18f
     echo_n " SUCCESS"
a2f18f
@@ -92,7 +84,7 @@ start() {
a2f18f
     if [ -f $pidfile ]; then
a2f18f
         pid=`cat $pidfile`
a2f18f
         name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
a2f18f
-        if kill -0 $pid && [ $name = "$processname" ]; then
a2f18f
+        if kill -s 0 $pid && [ $name = "$processname" ]; then
a2f18f
             echo_n " already running"
a2f18f
             success; echo
a2f18f
             subagent_running=1
a2f18f
@@ -121,7 +113,7 @@ start() {
a2f18f
         while test $loop_counter -le $max_count ; do
a2f18f
             loop_counter=`expr $loop_counter + 1`
a2f18f
             if test ! -f $pidfile ; then
a2f18f
-                if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+                if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
                     sleep 1
a2f18f
                 else
a2f18f
                     break
a2f18f
@@ -131,7 +123,7 @@ start() {
a2f18f
                 break
a2f18f
             fi
a2f18f
         done
a2f18f
-        if kill -0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
a2f18f
+        if kill -s 0 $pid > /dev/null 2>&1 && test -f $pidfile ; then
a2f18f
             success; echo
a2f18f
         else
a2f18f
             failure; echo
a2f18f
@@ -147,7 +139,7 @@ stop() {
a2f18f
     if [ -f $pidfile ]; then
a2f18f
         pid=`cat $pidfile`
a2f18f
         subagent_stopped=0
a2f18f
-        if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+        if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
             kill $pid
a2f18f
             if [ $? -eq 0 ]; then
a2f18f
                 subagent_stopped=1
a2f18f
@@ -164,7 +156,7 @@ stop() {
a2f18f
             max_count=10
a2f18f
             while test $loop_counter -le $max_count; do
a2f18f
                 loop_counter=`expr $loop_counter + 1`
a2f18f
-                if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+                if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
                     sleep 1
a2f18f
                 else
a2f18f
                     if test -f $pidfile ; then
a2f18f
@@ -200,7 +192,7 @@ condrestart() {
a2f18f
     if [ -f $pidfile ]; then
a2f18f
         pid=`cat $pidfile`
a2f18f
         name=`ps -p $pid | tail -1 | awk '{ print $4 }'`
a2f18f
-        if kill -0 $pid && [ $name = "$processname" ]; then
a2f18f
+        if kill -s 0 $pid && [ $name = "$processname" ]; then
a2f18f
             restart
a2f18f
         fi
a2f18f
     fi
a2f18f
@@ -210,7 +202,7 @@ status() {
a2f18f
      ret=0
a2f18f
      if [ -f $pidfile ]; then
a2f18f
          pid=`cat $pidfile`
a2f18f
-         if kill -0 $pid > /dev/null 2>&1 ; then
a2f18f
+         if kill -s 0 $pid > /dev/null 2>&1 ; then
a2f18f
              echo "$prog (pid $pid) is running..."
a2f18f
          else
a2f18f
             echo "$prog dead but pid file exists"
a2f18f
-- 
a2f18f
1.9.3
a2f18f