selftest: Add targetdir and tdbrestore parameters to undump.sh
authorAndrew Bartlett <abartlet@samba.org>
Sat, 16 Jun 2012 01:06:59 +0000 (11:06 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Sat, 16 Jun 2012 01:55:06 +0000 (03:55 +0200)
source4/selftest/provisions/undump.sh

index 07408b7ea6b8419f4de3b9bb6f8cb1a2dcb98d15..7ffea3eff70af927455fcd2a006e213276b1e76b 100755 (executable)
@@ -1,18 +1,35 @@
 #!/bin/sh
 # undump a provision directory
 
-[ "$#" -eq 1 ] || {
-    echo "Usage: undump.sh <DIRECTORY>"
+[ "$#" -gt 0 ] || {
+    echo "Usage: undump.sh <DIRECTORY> [TARGETDIR] [TDBRESTORE]"
     exit 1
 }
+
+TDBRESTORE=tdbrestore
+[ "$#" -lt 3 ] || {
+    TDBRESTORE=$3
+}
+
+
 dirbase="$1"
-for f in $(find $dirbase -name '*.dump'); do
-    dname=$(dirname $f)
+
+TARGETDIR=`pwd`/$dirbase
+
+cd $dirbase
+
+[ "$#" -lt 2 ] || {
+    TARGETDIR=$2
+}
+
+for f in $(find . -name '*.dump'); do
+    dname=$TARGETDIR/$(dirname $f)
+    mkdir -p $dname
     bname=$(basename $f .dump)
     outname=$dname/$bname
     echo "Restoring $outname"
     rm -f $outname
-    bin/tdbrestore $outname < $f || {
+    $TDBRESTORE $outname < $f || {
        echo "Failed to restore $outname"
        exit 1
     }