[Pkg-fedora-ds-maintainers] Bug#772195: 389-ds-base: bashism in /bin/sh script
Rowan Thorpe
rowan at rowanthorpe.com
Wed Dec 10 18:43:40 UTC 2014
I've attached a debian-patch which hopefully addresses all of these
(and one or two which checkbashisms didn't get). Please let me know if
I missed anything.
--
Rowan Thorpe
PGP fingerprint:
BB0A 0787 C0EE BDD8 7F97 3D30 49F2 13A5 265D CCBD
-------------- next part --------------
Description: Fix bashisms and other shell issues
Author: Rowan Thorpe <rowan at rowanthorpe.com>
Forwarded: no
Last-Update: 2014-12-10
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- 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
--- a/ldap/admin/src/scripts/DSSharedLib.in
+++ b/ldap/admin/src/scripts/DSSharedLib.in
@@ -98,13 +98,13 @@
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 @@
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
@@ -143,14 +143,14 @@
' '*)
;;
*)
- if [ "$output" != "" ]
+ if [ -n "$output" ]
then
echo "$output" >> /tmp/DSSharedLib.$pid
output=""
fi
;;
esac
- if [ "$output" != "" ]
+ if [ -n "$output" ]
then
case $LINE in
' '*)
@@ -190,19 +190,19 @@
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
--- a/ldap/admin/src/scripts/bak2db.in
+++ b/ldap/admin/src/scripts/bak2db.in
@@ -58,7 +58,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"
--- a/ldap/admin/src/scripts/db2bak.in
+++ b/ldap/admin/src/scripts/db2bak.in
@@ -57,7 +57,7 @@
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"
@@ -68,7 +68,7 @@
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
--- a/ldap/admin/src/scripts/db2index.in
+++ b/ldap/admin/src/scripts/db2index.in
@@ -59,7 +59,7 @@
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"
--- a/ldap/admin/src/scripts/db2ldif.in
+++ b/ldap/admin/src/scripts/db2ldif.in
@@ -39,7 +39,7 @@
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 @@
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 @@
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 @@
return 0
}
-if [ "$#" -lt 2 ];
+if [ $# -lt 2 ];
then
usage
exit 1
@@ -137,7 +137,7 @@
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"
--- a/ldap/admin/src/scripts/dbverify.in
+++ b/ldap/admin/src/scripts/dbverify.in
@@ -45,7 +45,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"
@@ -56,7 +56,7 @@
. $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
--- a/ldap/admin/src/scripts/dn2rdn.in
+++ b/ldap/admin/src/scripts/dn2rdn.in
@@ -39,7 +39,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"
--- a/ldap/admin/src/scripts/ldif2db.in
+++ b/ldap/admin/src/scripts/ldif2db.in
@@ -82,7 +82,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"
--- a/ldap/admin/src/scripts/ldif2ldap.in
+++ b/ldap/admin/src/scripts/ldif2ldap.in
@@ -40,14 +40,14 @@
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 @@
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 @@
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 @@
#
# 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 @@
#
# 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 @@
#
# 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 @@
#
# 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
--- a/ldap/admin/src/scripts/monitor.in
+++ b/ldap/admin/src/scripts/monitor.in
@@ -41,7 +41,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"
@@ -66,17 +66,17 @@
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 @@
#
# 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 @@
#
# 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 @@
#
# 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 @@
#
# 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
--- a/ldap/admin/src/scripts/restoreconfig.in
+++ b/ldap/admin/src/scripts/restoreconfig.in
@@ -31,7 +31,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"
--- a/ldap/admin/src/scripts/saveconfig.in
+++ b/ldap/admin/src/scripts/saveconfig.in
@@ -31,7 +31,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"
@@ -45,7 +45,7 @@
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
--- a/ldap/admin/src/scripts/start-dirsrv.in
+++ b/ldap/admin/src/scripts/start-dirsrv.in
@@ -44,7 +44,7 @@
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 @@
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 @@
# 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 @@
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 @@
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 @@
echo Starting instance \"$inst\"
start_instance $inst
rv=$?
- if [ "$rv" -ne 0 ]; then
+ if [ $rv -ne 0 ]; then
ret=$rv
fi
done
--- a/ldap/admin/src/scripts/stop-dirsrv.in
+++ b/ldap/admin/src/scripts/stop-dirsrv.in
@@ -28,7 +28,7 @@
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 @@
#
# 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 @@
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 @@
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 @@
echo Stopping instance \"$inst\"
stop_instance $inst
rv=$?
- if [ "$rv" -ne 0 ]; then
+ if [ $rv -ne 0 ]; then
ret=$rv
fi
done
--- a/ldap/admin/src/scripts/suffix2instance.in
+++ b/ldap/admin/src/scripts/suffix2instance.in
@@ -32,14 +32,14 @@
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"
--- a/ldap/admin/src/scripts/upgradedb.in
+++ b/ldap/admin/src/scripts/upgradedb.in
@@ -39,7 +39,7 @@
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"
--- a/ldap/admin/src/scripts/upgradednformat.in
+++ b/ldap/admin/src/scripts/upgradednformat.in
@@ -49,13 +49,13 @@
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"
--- a/ldap/admin/src/scripts/vlvindex.in
+++ b/ldap/admin/src/scripts/vlvindex.in
@@ -45,7 +45,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"
--- 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
--- 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 @@
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
--- a/rpm/rpmverrel.sh
+++ b/rpm/rpmverrel.sh
@@ -6,7 +6,7 @@
# Source VERSION.sh to set the version
# and release environment variables.
-source ./VERSION.sh
+. ./VERSION.sh
if [ "$1" = "version" ]; then
echo $RPM_VERSION
--- a/wrappers/initscript.in
+++ b/wrappers/initscript.in
@@ -32,28 +32,20 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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"
--- a/wrappers/ldap-agent-initscript.in
+++ b/wrappers/ldap-agent-initscript.in
@@ -31,28 +31,20 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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"
More information about the Pkg-fedora-ds-maintainers
mailing list