summaryrefslogtreecommitdiff
path: root/FS/bin/freeside-pull-dsl
blob: e6584072edc21928b0a30e27dfb7e345f46bdb42 (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
#!/usr/bin/perl -w

use strict;
use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Conf;
use FS::Record qw(qsearch qsearchs dbh);
use FS::svc_dsl;
use FS::part_export;
use Data::Dumper;

&untaint_argv;	#what it sounds like  (eww)
use vars qw(%opt);

my $user = shift or die &usage;
adminsuidsetup $user;

my @monitored = qsearch('svc_dsl', { 'monitored' => 'Y' } );
foreach my $svc_dsl ( @monitored ) {
    my @exports = $svc_dsl->part_svc->part_export_dsl_pull;
    my $svcnum = $svc_dsl->svcnum;
    warn "either zero or more than one DSL-pulling export attached to svcnum "
	. "$svcnum, skipping" if ( scalar(@exports) != 1 );
    my $export = $exports[0];
    my $error = $export->dsl_pull($svc_dsl); # this will commit to db by default
    warn "Error pulling DSL svcnum $svcnum: $error" unless $error eq '';
}

###
# subroutines
###

sub untaint_argv {
  foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
    #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
    # Date::Parse
    $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
    $ARGV[$_]=$1;
  }
}

sub usage {
  die "Usage:\n  freeside-pull-dsl user \n";
}

###
# documentation
###

=head1 NAME

freeside-pull-dsl - Pull DSL order data from telcos/vendors for all monitored DSL orders to update

=head1 SYNOPSIS

  freeside-pull-dsl user

=head1 DESCRIPTION

user - name of an internal Freeside user

This is still a work in progress - in future may add limiting by exportnum or svcpart or other such stuff.

=head1 BUGS

=head1 SEE ALSO

L<FS::cust_main>, config.html from the base documentation

=cut