use OpenSRF::System;
my $config = shift || die "bootstrap config required\n";
+my $lockfile = shift || "/tmp/generate_fines-LOCK";
+
+if (-e $lockfile) {
+ open(F,$lockfile);
+ my $pid = <F>;
+ close F;
+
+ open(F,'/bin/ps axo pid|');
+ while ( my $p = <F>) {
+ chomp($p);
+ if ($p =~ s/\s*(\d+)$/$1/o && $p == $pid) {
+ die "I seem to be running already at pid $pid. If not, try again\n";
+ }
+ }
+ close F;
+}
+
+open(F, ">$lockfile");
+print F $$;
+close F;
OpenSRF::System->bootstrap_client( config_file => $config );
while (!$r->complete) { $r->recv };
+unlink $lockfile;
#!/usr/bin/perl
# ---------------------------------------------------------------------
-# Generic databse object dumper.
-# ./object_dumper.pl <bootstrap_config> <type>, <type>, ...
-# ./object_dumper.pl /openils/conf/bootstrap.conf permission.grp_tree
+# Usage:
+# hold_targeter.pl <config_file> <lock_file>
# ---------------------------------------------------------------------
use strict;
use OpenSRF::System;
my $config = shift || die "bootstrap config required\n";
+my $lockfile = shift || "/tmp/hold_targeter-LOCK";
+
+if (-e $lockfile) {
+ open(F,$lockfile);
+ my $pid = <F>;
+ close F;
+
+ open(F,'/bin/ps axo pid|');
+ while ( my $p = <F>) {
+ chomp($p);
+ if ($p =~ s/\s*(\d+)$/$1/o && $p == $pid) {
+ die "I seem to be running already at pid $pid. If not, try again\n";
+ }
+ }
+ close F;
+}
+
+open(F, ">$lockfile");
+print F $$;
+close F;
OpenSRF::System->bootstrap_client( config_file => $config );
while (!$r->complete) { $r->recv };
+unlink $lockfile;
+