Hello,
I have a couple of questions about the most awesome OpenLDAP init script
found at
http://ltb-project.org/wiki/download
and
http://ltb-project.org/wiki/documentation/openldap-initscript

( "ltb-project-openldap-initscript-1.9")


1.  Is it pretty standard practice to do a db_recover on OpenLDAP startup?


2.   The value of $dbsufs in its initial call by the backup() function
below  is being initialized as "", then is being evaluated later on, and
failing every time . My $DATA_PATH is not "auto" so $dbsufs is not being
populated.

I added these 2 lines and it works fine:
       get_confvalues "suffix"
        dbsufs=$RETVAL

Either that or hard-code something like:
dbsufs="dc=mycompany,dc=com"

Or I could set my DATA_PATH to "auto".  :)

I guess I just wanted to bring this to the attention of script authors : in
the case where DATA_PATH is not set to auto, the dbsufs variable is not
being populated in backup().



Thank you in advance for suggestions and responses.
-Gare Calhoun






backup() {
# Start message
message "info" "[INFO] Launching OpenLDAP database backup..."

# Backup directory
mkdir -p "$BACKUP_PATH"

if [ "$SLAPD_CONF_DIR" ]
then
SLAPCAT_PARAMS="-F $SLAPD_CONF_DIR"
elif [ "$SLAPD_CONF" ]
then
SLAPCAT_PARAMS="-f $SLAPD_CONF"
fi

# Do backup for all databases
dbdirs="$DATA_PATH"
dbsufs=""

if [ "$DATA_PATH" = "auto" ]
then
get_confvalues "directory"
dbdirs=$RETVAL
get_confvalues "suffix"
dbsufs=$RETVAL

if [ -z "$dbdirs" -o -z "$dbsufs" ]
then
message "alert" "[ALERT] No database directories found"
exit 1
fi
fi

i=1
for dbdir in $dbdirs
do
# Table is not allowed, so we use awk
suf=`echo $dbsufs | awk -v j="$i" 'BEGIN{OFS=" "} {print $j}'`

if [ -z $suf ]; then
message "info" "[INFO] No suffix for $dbdir"
else
sufprint=`echo $suf | sed "s/#20/ /"`
dir=`basename $dbdir`
file="$BACKUP_PATH/$dir-$BACKUP_SUFFIX"

# slapcat
if [ -z "$SU" ]
then
$SLAPCAT_BIN -b "$sufprint" $SLAPCAT_PARAMS -l "$file"
ret=$?
else
$SU "$SLAPCAT_BIN -b \"$sufprint\" $SLAPCAT_PARAMS" > "$file"
ret=$?
chown $SLAPD_USER:$SLAPD_GROUP $file
fi

# alert
if [ $ret -ne 0 ]
then
message "alert" "[ALERT] OpenLDAP database backup failed"
exit 1
fi

# compress
if [ -z $BACKUP_COMPRESS_EXT ]
then
message "info" "[OK] data saved in $file"
else
if [ -z "$SU" ]
then
$BACKUP_COMPRESS_BIN "$file"
else
$SU "$BACKUP_COMPRESS_BIN $file"
fi

# alert
if [ $? -ne 0 ]
then
message "alert" "[ALERT] OpenLDAP database backup compression failed"
exit 1
fi
message "info" "[OK] Data saved in ${file}.$BACKUP_COMPRESS_EXT"
fi
fi

i=`expr $i + 1`
done

}



-- 

. . . . . . . . . . . . . . . . . . . . . . . . . . . .
Gare Calhoun
Antioch University IT Services, Software Developer
_______________________________________________
ltb-users mailing list
[email protected]
http://lists.ltb-project.org/listinfo/ltb-users

Reply via email to