4 use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
5 use FS::UID qw(adminsuidsetup);
6 use FS::Record qw(qsearch); # qsearchs);
9 my $user = shift or die &usage;
11 #daemonize1('freeside-sprepaidd', $user); #keep unique pid files w/multi installs
12 daemonize1('freeside-prepaidd');
16 adminsuidsetup($user);
18 logfile( "/usr/local/etc/freeside/prepaidd-log.". $FS::UID::datasrc );
26 foreach my $cust_pkg (
28 'select' => 'cust_pkg.*, part_pkg.plan',
29 'table' => 'cust_pkg',
30 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )',
31 #'hashref' => { 'plan' => 'prepaid' },#should check part_pkg::is_prepaid
32 #'extra_sql' => "AND bill < ". time.
34 'extra_sql' => "WHERE plan = 'prepaid' AND bill < ". time.
35 " AND bill IS NOT NULL".
36 " AND ( susp IS NULL OR susp = 0)".
37 " AND ( cancel IS NULL OR cancel = 0)"
40 my $error = $cust_pkg->suspend;
41 warn "Error suspended package ". $cust_pkg->pkgnum.
42 " for custnum ". $cust_pkg->custnum.
47 die "exiting" if sigterm() || sigint();
55 die "Usage:\n\n freeside-prepaidd user\n";
60 freeside-prepaidd - Real-time daemon for prepaid packages
68 Runs continuously and suspendes any prepaid customer packages which have
69 passed their renewal date (next bill date).