blob: 6b689178de66ebfd5f8f27af07afc40069b5350d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#!/usr/bin/perl -w
use strict;
use vars qw($opt_s $opt_u $opt_p $opt_e);
use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::part_export;
use FS::svc_acct;
use FS::cust_svc;
my $user = shift or die &usage;
adminsuidsetup $user;
my $export_x = shift or die &usage;
my @part_export;
if ( $export_x =~ /^(\d+)$/ ) {
@part_export = qsearchs('part_export', { exportnum=>$1 } )
or die "exportnum $export_x not found\n";
} else {
@part_export = qsearch('part_export', { exporttype=>$export_x } )
or die "no exports of type $export_x found\n";
}
getopts('s:u:p:e:');
my @svc_x = ();
if ( $opt_s ) {
my $cust_svc = qsearchs('cust_svc', { svcnum=>$opt_s } )
or die "svcnum $opt_s not found\n";
push @svc_x, $cust_svc->svc_x;
} elsif ( $opt_u ) {
my $svc_x = qsearchs('svc_acct', { username=>$opt_u } )
or die "username $opt_u not found\n";
push @svc_x, $svc_x;
} elsif ( $opt_p ) {
push @svc_x, map { $_->svc_x } qsearch('cust_svc', { svcpart=>$opt_p } );
die "no services with svcpart $opt_p found\n" unless @svc_x;
}
$opt_e ||= 'insert';
die &usage unless grep { $_ eq $opt_e } qw( insert replace delete suspend unsuspend );
my $method = 'export_' . $opt_e;
foreach my $part_export ( @part_export ) {
foreach my $svc_x ( @svc_x ) {
my $error = $part_export->$method($svc_x,$svc_x);
die $error if $error;
}
}
sub usage {
return "Usage:\n\n freeside-reexport user exportnum|exporttype [ -s svcnum | -u username | -p svcpart ] [ -e insert|replace|delete|suspend|unsuspend ]\n";
}
=head1 NAME
freeside-reexport - Command line tool to re-trigger export jobs for existing services
=head1 SYNOPSIS
freeside-reexport user exportnum|exporttype [ -s svcnum | -u username | -p svcpart ] [ -e insert|replace|delete|suspend|unsuspend ]
=head1 DESCRIPTION
Re-queues the export job for the specified exportnum or exporttype(s) and
specified service (selected by svcnum, username or svcpart). Optionally
specify the phase of export using the -e flag (default is insert.)
=head1 SEE ALSO
L<freeside-sqlradius-reset>, L<FS::part_export>
=cut
|