ldap/admin/src/scripts/template-bak2db.in | 13 ++---
ldap/admin/src/scripts/template-db2bak.in | 14 ++---
ldap/admin/src/scripts/template-db2ldif.in | 2
ldap/admin/src/scripts/template-ldif2db.in | 35 ++++++++++++--
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 12 ++--
ldap/servers/slapd/main.c | 67 ++++++++++++++++++---------
6 files changed, 94 insertions(+), 49 deletions(-)
New commits:
commit da07b507859ae994b4a1828f6815b99e0d301645
Author: Noriko Hosoi <nhosoi(a)totoro.usersys.redhat.com>
Date: Thu Oct 11 14:36:05 2012 -0700
Trac Ticket #451 - Allow db2ldif to be quiet
https://fedorahosted.org/389/ticket/451
Description: Export utility db2ldif and import utility ldif2db are
always verbose. This patch is adding an option '-q' to suppress
the outputs.
This patch modifies db2bak and bak2db which already supports '-q',
as well. The scripts used to interpret '-q'. If it was not set,
a verbose debug option '-d 524288' was passed to ns-slapd. Instead,
this patch directly passes '-q' to ns-slapd and let it handle it
in the C code.
diff --git a/ldap/admin/src/scripts/template-bak2db.in
b/ldap/admin/src/scripts/template-bak2db.in
index b081839..013a9f1 100755
--- a/ldap/admin/src/scripts/template-bak2db.in
+++ b/ldap/admin/src/scripts/template-bak2db.in
@@ -44,13 +44,6 @@ do
d) dlevel=$OPTARG;;
esac
done
-if [ $quiet -eq 0 ]
-then
- if [ $dlevel -ne 524288 ]
- then
- dlevel=`expr $dlevel + 524288`
- fi
-fi
if [ 1 = `expr $archivedir : "\/"` ]
then
@@ -61,4 +54,8 @@ else
fi
cd {{SERVERBIN-DIR}}
-./ns-slapd archive2db -D {{CONFIG-DIR}} -a $archivedir $benameopt -d $dlevel
+if [ $quiet -eq 0 ]; then
+ ./ns-slapd archive2db -D {{CONFIG-DIR}} -a $archivedir $benameopt -d $dlevel
+else
+ ./ns-slapd archive2db -D {{CONFIG-DIR}} -a $archivedir $benameopt -d $dlevel -q
+fi
diff --git a/ldap/admin/src/scripts/template-db2bak.in
b/ldap/admin/src/scripts/template-db2bak.in
index d89f6ee..85aac0f 100755
--- a/ldap/admin/src/scripts/template-db2bak.in
+++ b/ldap/admin/src/scripts/template-db2bak.in
@@ -46,14 +46,10 @@ then
esac
done
fi
-# If not quiet, set LDAP_DEBUG_BACKLDBM to debug level
-if [ $quiet -eq 0 ]
-then
- if [ $dlevel -ne 524288 ]
- then
- dlevel=`expr $dlevel + 524288`
- fi
-fi
echo "Back up directory: $bak_dir"
-./ns-slapd db2archive -D {{CONFIG-DIR}} -a $bak_dir -d $dlevel
+if [ $quiet -eq 0 ]; then
+ ./ns-slapd db2archive -D {{CONFIG-DIR}} -a $bak_dir -d $dlevel
+else
+ ./ns-slapd db2archive -D {{CONFIG-DIR}} -a $bak_dir -d $dlevel -q
+fi
diff --git a/ldap/admin/src/scripts/template-db2ldif.in
b/ldap/admin/src/scripts/template-db2ldif.in
index 2989b77..d3a12be 100755
--- a/ldap/admin/src/scripts/template-db2ldif.in
+++ b/ldap/admin/src/scripts/template-db2ldif.in
@@ -69,7 +69,7 @@ if [ "$#" -lt 2 ];
then
echo "Usage: db2ldif {-n backend_instance}* | {-s includesuffix}*"
echo " [{-x excludesuffix}*] [-a outputfile]"
- echo " [-N] [-r] [-C] [-u] [-U] [-m] [-M] [-1]"
+ echo " [-N] [-r] [-C] [-u] [-U] [-m] [-M] [-1] [-q]"
echo "Note: either \"-n backend_instance\" or \"-s
includesuffix\" is required."
exit 1
fi
diff --git a/ldap/admin/src/scripts/template-ldif2db.in
b/ldap/admin/src/scripts/template-ldif2db.in
index 8f92acf..ceb0157 100755
--- a/ldap/admin/src/scripts/template-ldif2db.in
+++ b/ldap/admin/src/scripts/template-ldif2db.in
@@ -19,15 +19,40 @@ export LD_LIBRARY_PATH
SHLIB_PATH=$LD_LIBRARY_PATH
export SHLIB_PATH
+usage()
+{
+ echo "Usage: ldif2db -n backend_instance | {-s includesuffix}* [{-x
excludesuffix}*]"
+ echo " {-i ldiffile}* [-O] [-q]"
+ echo "Note: either \"-n backend_instance\" or \"-s
includesuffix\" and \"-i ldiffile\" are required."
+}
+
+handleopts()
+{
+ while [ "$1" != "" ]
+ do
+ if [ "$1" = "-q" ]; then
+ return 1
+ elif [ "$1" = "-h" ]; then
+ usage
+ exit 1
+ fi
+ shift
+ done
+ return 0
+}
+
cd {{SERVERBIN-DIR}}
if [ $# -lt 4 ]
then
- echo "Usage: ldif2db -n backend_instance | {-s includesuffix}* [{-x
excludesuffix}*]"
- echo " {-i ldiffile}* [-O]"
- echo "Note: either \"-n backend_instance\" or \"-s
includesuffix\" and \"-i ldiffile\" are required."
- exit 1
+ usage
+ exit 1
fi
-echo importing data ...
+handleopts $@
+quiet=$?
+
+if [ $quiet -eq 0 ]; then
+ echo importing data ...
+fi
./ns-slapd ldif2db -D {{CONFIG-DIR}} "$@" 2>&1
exit $?
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index e50b930..82806db 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -259,7 +259,7 @@ entryrdn_index_entry(backend *be,
rc = LDAP_INVALID_DN_SYNTAX;
goto bail;
} else if (rc > 0) {
- slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
+ slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"entryrdn_index_entry: %s does not belong to "
"the db\n", slapi_sdn_get_dn(sdn));
rc = DB_NOTFOUND;
@@ -393,7 +393,7 @@ entryrdn_index_read_ext(backend *be,
rc = LDAP_INVALID_DN_SYNTAX;
goto bail;
} else if (rc > 0) {
- slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
+ slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"entryrdn_index_read: %s does not belong to the db\n",
slapi_sdn_get_dn(sdn));
rc = DB_NOTFOUND;
@@ -551,7 +551,7 @@ entryrdn_rename_subtree(backend *be,
rc = LDAP_INVALID_DN_SYNTAX;
goto bail;
} else if (rc > 0) {
- slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
+ slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"entryrdn_rename_subtree: %s does not belong to "
"the db\n", slapi_sdn_get_dn(oldsdn));
rc = DB_NOTFOUND;
@@ -1020,7 +1020,7 @@ entryrdn_get_subordinates(backend *be,
"\"%s\" to Slapi_RDN\n",
slapi_sdn_get_dn(sdn));
rc = LDAP_INVALID_DN_SYNTAX;
} else if (rc > 0) {
- slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
+ slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"entryrdn_get_subordinates: %s does not belong to
"
"the db\n", slapi_sdn_get_dn(sdn));
rc = DB_NOTFOUND;
@@ -2516,7 +2516,7 @@ _entryrdn_insert_key(backend *be,
} /* if (TMPID == tmpid) */
rc = 0;
} /* if (DB_KEYEXIST == rc) */
- slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
+ slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"_entryrdn_insert_key: Suffix %s added: %d\n",
nrdn, rc);
goto bail; /* succeeded or failed, it's done */
@@ -2589,7 +2589,7 @@ _entryrdn_insert_key(backend *be,
adddata.flags = DB_DBT_USERMEM;
rc = _entryrdn_put_data(cursor, &key, &adddata, RDN_INDEX_SELF,
db_txn);
- slapi_log_error(SLAPI_LOG_BACKLDBM, ENTRYRDN_TAG,
+ slapi_log_error(SLAPI_LOG_TRACE, ENTRYRDN_TAG,
"_entryrdn_insert_key: Suffix %s added: %d\n",
slapi_rdn_get_rdn(tmpsrdn), rc);
#ifdef FIX_TXN_DEADLOCKS
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index cf4e2e3..f438fce 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -414,20 +414,20 @@ usage( char *name, char *extraname )
case SLAPD_EXEMODE_DB2LDIF:
usagestr = "usage: %s %s%s-D configdir [-n backend-instance-name] [-d debuglevel]
"
"[-N] [-a outputfile] [-r] [-C] [{-s includesuffix}*] "
- "[{-x excludesuffix}*] [-u] [-U] [-m] [-M] [-E]\n"
+ "[{-x excludesuffix}*] [-u] [-U] [-m] [-M] [-E] [-q]\n"
"Note: either \"-n backend_instance_name\" or \"-s
includesuffix\" is required.\n";
break;
case SLAPD_EXEMODE_LDIF2DB:
usagestr = "usage: %s %s%s-D configdir [-d debuglevel] "
"[-n backend_instance_name] [-O] [-g uniqueid_type] [--namespaceid
uniqueID]"
- "[{-s includesuffix}*] [{-x excludesuffix}*] [-E] {-i ldif-file}*\n"
+ "[{-s includesuffix}*] [{-x excludesuffix}*] [-E] [-q] {-i ldif-file}*\n"
"Note: either \"-n backend_instance_name\" or \"-s
includesuffix\" is required.\n";
break;
case SLAPD_EXEMODE_DB2ARCHIVE:
- usagestr = "usage: %s %s%s-D configdir [-d debuglevel] -a archivedir\n";
+ usagestr = "usage: %s %s%s-D configdir [-q] [-d debuglevel] -a archivedir\n";
break;
case SLAPD_EXEMODE_ARCHIVE2DB:
- usagestr = "usage: %s %s%s-D configdir [-d debuglevel] -a archivedir\n";
+ usagestr = "usage: %s %s%s-D configdir [-q] [-d debuglevel] -a archivedir\n";
break;
case SLAPD_EXEMODE_DB2INDEX:
usagestr = "usage: %s %s%s-D configdir -n backend-instance-name "
@@ -490,6 +490,7 @@ static char *ldif2db_namespaceid = NULL;
int importexport_encrypt = 0;
static int upgradedb_flags = 0;
static int upgradednformat_dryrun = 0;
+static int is_quiet = 0;
/* taken from idsktune */
#if defined(__sun)
@@ -740,7 +741,7 @@ main( int argc, char **argv)
/* display debugging level if it is anything other than the default */
if ( 0 != ( slapd_ldap_debug & ~LDAP_DEBUG_ANY )) {
- slapd_debug_level_log( slapd_ldap_debug );
+ slapd_debug_level_log( slapd_ldap_debug );
}
#ifndef LDAP_DONT_USE_SMARTHEAP
@@ -1354,7 +1355,7 @@ process_command_line(int argc, char **argv, char *myname,
*
*/
- char *opts_db2ldif = "vd:D:ENa:rs:x:CSut:n:UmMo1";
+ char *opts_db2ldif = "vd:D:ENa:rs:x:CSut:n:UmMo1q";
struct opt_ext long_options_db2ldif[] = {
{"version",ArgNone,'v'},
{"debug",ArgRequired,'d'},
@@ -1373,9 +1374,10 @@ process_command_line(int argc, char **argv, char *myname,
{"oneOutputFile",ArgNone,'o'},
{"multipleOutputFile",ArgNone,'M'},
{"noVersionNum",ArgNone,'1'},
+ {"quiet",ArgNone,'q'},
{0,0,0}};
- char *opts_ldif2db = "vd:i:g:G:n:s:x:NOCc:St:D:E";
+ char *opts_ldif2db = "vd:i:g:G:n:s:x:NOCc:St:D:Eq";
struct opt_ext long_options_ldif2db[] = {
{"version",ArgNone,'v'},
{"debug",ArgRequired,'d'},
@@ -1392,9 +1394,10 @@ process_command_line(int argc, char **argv, char *myname,
{"nostate",ArgNone,'Z'},
{"configDir",ArgRequired,'D'},
{"encrypt",ArgOptional,'E'},
+ {"quiet",ArgNone,'q'},
{0,0,0}};
- char *opts_archive2db = "vd:i:a:n:SD:";
+ char *opts_archive2db = "vd:i:a:n:SD:q";
struct opt_ext long_options_archive2db[] = {
{"version",ArgNone,'v'},
{"debug",ArgRequired,'d'},
@@ -1403,10 +1406,11 @@ process_command_line(int argc, char **argv, char *myname,
{"backEndInstName",ArgRequired,'n'},
{"allowMultipleProcesses",ArgNone,'S'},
{"configDir",ArgRequired,'D'},
+ {"quiet",ArgNone,'q'},
{0,0,0}};
- char *opts_db2archive = "vd:i:a:SD:";
+ char *opts_db2archive = "vd:i:a:SD:q";
struct opt_ext long_options_db2archive[] = {
{"version",ArgNone,'v'},
{"debug",ArgRequired,'d'},
@@ -1414,6 +1418,7 @@ process_command_line(int argc, char **argv, char *myname,
{"archive",ArgRequired,'a'},
{"allowMultipleProcesses",ArgNone,'S'},
{"configDir",ArgRequired,'D'},
+ {"quiet",ArgNone,'q'},
{0,0,0}};
char *opts_db2index = "vd:a:t:T:SD:n:s:x:";
@@ -1913,6 +1918,9 @@ process_command_line(int argc, char **argv, char *myname,
ldif_printkey |= EXPORT_NOVERSION;
break;
+ case 'q': /* quiet option for db2ldif, ldif2db, db2bak, bak2db */
+ is_quiet = 1;
+ break;
default:
usage( myname, *extraname );
exit( 1 );
@@ -2224,7 +2232,12 @@ slapd_exemode_ldif2db()
plugin->plg_name, 0, 0);
return 1;
}
-
+ if (!is_quiet) {
+ slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;
+ }
+ if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
+ g_set_detached(1);
+ }
memset( &pb, '\0', sizeof(pb) );
pb.pb_backend = NULL;
pb.pb_plugin = plugin;
@@ -2352,6 +2365,12 @@ slapd_exemode_db2ldif(int argc, char** argv)
return 1;
}
+ if (!is_quiet) {
+ slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;
+ }
+ if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
+ g_set_detached(1);
+ }
memset( &pb, '\0', sizeof(pb) );
pb.pb_backend = NULL;
pb.pb_plugin = plugin;
@@ -2411,13 +2430,15 @@ slapd_exemode_db2ldif(int argc, char** argv)
}
}
- fprintf(stderr, "ldiffile: %s\n", my_ldiffile);
+ if (!is_quiet) {
+ fprintf(stderr, "ldiffile: %s\n", my_ldiffile);
+ }
/* just send the filename to the backend and let
* the backend open it (so they can do special
* stuff for 64-bit fs)
*/
pb.pb_ldif_file = my_ldiffile;
- pb.pb_ldif_printkey = ldif_printkey;
+ pb.pb_ldif_printkey = ldif_printkey;
}
return_value = (plugin->plg_db2ldif)( &pb );
@@ -2583,10 +2604,10 @@ slapd_exemode_db2archive()
/* Make sure we aren't going to run slapd in
* a mode that is going to conflict with other
- * slapd processes that are currently running
- */
- if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica,
- skip_db_protect_check) == -1 ) {
+ * slapd processes that are currently running
+ */
+ if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica,
+ skip_db_protect_check) == -1 ) {
LDAPDebug( LDAP_DEBUG_ANY,
"Shutting down due to possible conflicts with other slapd
processes\n",
0, 0, 0 );
@@ -2596,6 +2617,9 @@ slapd_exemode_db2archive()
LDAPDebug(LDAP_DEBUG_ANY, "Initialization Failed 0 %d\n",return_value,0,0);
return 1;
}
+ if (!is_quiet) {
+ slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;
+ }
if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
g_set_detached(1);
}
@@ -2636,10 +2660,10 @@ slapd_exemode_archive2db()
/* Make sure we aren't going to run slapd in
* a mode that is going to conflict with other
- * slapd processes that are currently running
- */
- if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica,
- skip_db_protect_check) == -1 ) {
+ * slapd processes that are currently running
+ */
+ if ( add_new_slapd_process(slapd_exemode, db2ldif_dump_replica,
+ skip_db_protect_check) == -1 ) {
LDAPDebug( LDAP_DEBUG_ANY,
"Shutting down due to possible conflicts with other slapd
processes\n",
0, 0, 0 );
@@ -2650,6 +2674,9 @@ slapd_exemode_archive2db()
return 1;
}
+ if (!is_quiet) {
+ slapd_ldap_debug |= LDAP_DEBUG_BACKLDBM;
+ }
if (!(slapd_ldap_debug & LDAP_DEBUG_BACKLDBM)) {
g_set_detached(1);
}