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