[freeside-commits] freeside/FS/bin freeside-cdrd,1.1,1.2
Ivan,,,
ivan at wavetail.420.am
Sat Nov 1 15:13:00 PDT 2008
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail.420.am:/tmp/cvs-serv22578/FS/bin
Modified Files:
freeside-cdrd
Log Message:
have freeside-cdrd disable itself if there's no appropriate package definition, RT#4184
Index: freeside-cdrd
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-cdrd,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- freeside-cdrd 29 Oct 2008 08:03:08 -0000 1.1
+++ freeside-cdrd 1 Nov 2008 22:12:58 -0000 1.2
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
-use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
+use FS::Daemon ':all'; #daemonize1 drop_root daemonize2 myexit logfile sig*
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch ); #qsearchs);
#use FS::cdr;
@@ -20,6 +20,9 @@
daemonize2();
+die "not running; no voip_cdr package defs w/ bill_every_call and customer pkgs"
+ unless _shouldrun();
+
#--
my $addl_from =
@@ -66,7 +69,7 @@
$found = 1;
- my $work_cust_pkg = $cust_pkg;
+ #my $work_cust_pkg = $cust_pkg;
my $cust_main = $cust_pkg->cust_main;
@@ -81,13 +84,35 @@
}
- die "exiting" if sigterm() || sigint();
+ myexit() if sigterm() || sigint();
sleep 5; # unless $found;
}
#--
+sub _shouldrun {
+
+ my $extra_sql =
+ ' AND 0 < ( SELECT COUNT(*) FROM cust_pkg
+ WHERE cust_pkg.pkgpart = part_pkg.pkgpart
+ AND ( cust_pkg.cancel IS NULL OR cust_pkg.cancel = 0 )
+ )
+ ';
+
+ my @part_pkg =
+ grep $_->option('bill_every_call', 'hush'),
+ qsearch({
+ 'table' => 'part_pkg',
+ 'hashref' => { 'plan' => 'voip_cdr' },
+ 'extra_sql' => $extra_sql,
+ })
+ ;
+
+ scalar(@part_pkg);
+
+}
+
sub usage {
die "Usage:\n\n freeside-prepaidd user\n";
}
More information about the freeside-commits
mailing list