Index: branches/pap/ippScripts/scripts/addstar_run.pl
===================================================================
--- branches/pap/ippScripts/scripts/addstar_run.pl	(revision 28179)
+++ branches/pap/ippScripts/scripts/addstar_run.pl	(revision 28484)
@@ -36,6 +36,6 @@
     exit($PS_EXIT_CONFIG_ERROR);
 }
-
-my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $image_only, $verbose, $no_update,
+my $minidvodb_path;
+my ( $exp_tag, $add_id, $camera, $outroot, $camroot, $dbname, $reduction, $dvodb, $minidvodb, $minidvodb_name, $minidvodb_group, $image_only, $verbose, $no_update,
      $no_op, $redirect, $save_temps);
 GetOptions(
@@ -48,4 +48,7 @@
     'reduction=s'       => \$reduction, # Reduction class
     'dvodb|w=s'         => \$dvodb,  # output DVO database
+    'minidvodb_name|w=s'=> \$minidvodb_name,  # miniDVO database name
+    'minidvodb_group|w=s' => \$minidvodb_group, # miniDVO database group
+    'minidvodb'         => \$minidvodb,  # use minidvodb?
     'image-only'        => \$image_only,   # Print to stdout
     'verbose'           => \$verbose,   # Print to stdout
@@ -58,5 +61,5 @@
 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
 pod2usage(
-          -msg => "Required options: --exp_tag --add_id --camera --outroot",
+          -msg => "Required options: --exp_tag --add_id --camera --outroot --dvodb --camroot",
           -exitval => 3,
           ) unless
@@ -65,6 +68,9 @@
     defined $outroot and
     defined $camroot and
+    defined $dvodb and
     defined $camera;
-
+if ($minidvodb && !defined($minidvodb_group)) {
+		my_die( "missing minidvodb_group", $add_id, 3 );
+	    }
 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $add_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
 
@@ -98,11 +104,49 @@
 if (defined $dvodb) {
     $dvodbReal = $ipprc->dvo_catdir( $dvodb ); # catdir for DVO
-    $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal );
-}
+    $dvodbReal = $ipprc->convert_filename_absolute( $dvodbReal ) or &my_die("can't get path for dvodb", $add_id, $PS_EXIT_CONFIG_ERROR);
+}
+
+
+
 
 my $dtime_addstar = 0;
 
+if (defined $dvodbReal) {
+	if ($minidvodb) {
+	    
+	    if (!defined($minidvodb_name)) {
+		#take the active one, if it's not defined on the command line
+		#reverts would have this already set, for example.
+		my $command = "addtool -listminidvodbrun ";
+		$command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group;
+		$command .= " -state 'active' -limit 1";
+		$command .= " -dbname $dbname" if defined $dbname;
+		print $command;
+		my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+		    run(command => $command, verbose => $verbose);
+		&my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success;
+		my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
+		    &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR);
+
+		my $components = parse_md_list($metadata) or
+		    &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR);
+		my $comp = $$components[0];
+		$minidvodb_path = $comp->{minidvodb_path};
+		$minidvodb_name = $comp->{minidvodb_name};
+	
+		if (!defined($minidvodb_path)) {
+		    &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR);
+		} 
+		if (!defined($minidvodb_name)) {
+		    &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR);
+		}
+	    }
+	    # tack on the minidvodb part to the db.
+#	    $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/';
+#we don't need this now that I fixed the paths	   
+	    
+	}
 unless ($no_op) {
-    if (defined $dvodbReal) {
+   	    print $dvodbReal;
 
         ## addstar can either save the full set of detections, or just
@@ -120,5 +164,5 @@
         my $command  = "$addstar -update"; # XXX optionally set -update?
         $command .= " -D CAMERA $camdir";
-        $command .= " -D CATDIR $dvodbReal";
+        $command .= " -D CATDIR $minidvodb_path";
         $command .= " $realFile";
         $command .= " -use-name $fpaObjects"; # DVO wants the neb-name as a file reference
@@ -142,6 +186,8 @@
 $fpaCommand .= " -path_base $outroot";
 $fpaCommand .= " -dtime_addstar $dtime_addstar";
+$fpaCommand .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path;
+$fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
 $fpaCommand .= " -dbname $dbname" if defined $dbname;
-
+print $fpaCommand;
 # Add the result into the database
 unless ($no_update) {
@@ -171,6 +217,8 @@
         $command .= " -addprocessedexp";
         $command .= " -fault $exit_code";
+	$command .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path;
         $command .= " -path_base $outroot" if defined $outroot;
         $command .= (" -dtime_addstar " . ((DateTime->now->mjd - $mjd_start) * 86400));
+	$fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;
         $command .= " -dbname $dbname" if defined $dbname;
         system ($command);
