X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-sqlradius-reset;h=b04c640d842c1b5306258f36153d5f12acdc373a;hp=a77bad64f6542f0ee06bdef19ce7aee4b4696895;hb=f822e27a1e00594332ffa487a1c284234c5580a6;hpb=63a268637b2d51a8766412617724b9436439deb6 diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset index a77bad64f..b04c640d8 100755 --- a/FS/bin/freeside-sqlradius-reset +++ b/FS/bin/freeside-sqlradius-reset @@ -19,14 +19,14 @@ adminsuidsetup $user; my @exports = (); if ( @ARGV ) { foreach my $exportnum ( @ARGV ) { - foreach my $exporttype (qw( sqlradius sqlradius_withdomain phone_sqlradius )) { + foreach my $exporttype (qw( sqlradius sqlradius_withdomain phone_sqlradius broadband_sqlradius )) { push @exports, qsearch('part_export', { exportnum => $exportnum, exporttype => $exporttype, } ); } } } else { @exports = qsearch('part_export', { exporttype=>'sqlradius' } ); - push @exports, qsearch('part_export', { exporttype=>'sqlradius_withdomain' } ); + push @exports, qsearch('part_export', { exporttype=>'sqlradius_withdomain' } ); } unless ( $opt_n ) { @@ -34,7 +34,11 @@ unless ( $opt_n ) { my $icradius_dbh = DBI->connect( map { $export->option($_) } qw( datasrc username password ) ) or die $DBI::errstr; - for my $table (qw( radcheck radreply usergroup )) { + my $usergroup = $export->option('usergroup') || 'usergroup'; + my @attr_tables; + @attr_tables = qw( radgroupcheck radgroupreply ) + if $export->option('export_attrs'); + for my $table (qw( radcheck radreply ), $usergroup, @attr_tables) { my $sth = $icradius_dbh->prepare("DELETE FROM $table"); $sth->execute or die "Can't reset $table table: ". $sth->errstr; } @@ -46,6 +50,9 @@ use FS::svc_Common; $FS::svc_Common::overlimit_missing_cust_svc_nonfatal_kludge = 1; $FS::svc_Common::overlimit_missing_cust_svc_nonfatal_kludge = 1; +# this is the same across all exports, for now +my @radius_attrs = qsearch('radius_attr', {}); + foreach my $export ( @exports ) { #my @svcparts = map { $_->svcpart } $export->export_svc; @@ -84,6 +91,13 @@ foreach my $export ( @exports ) { die $error if $error; } + + if ( $export->option('export_attrs') ) { + foreach my $attr (@radius_attrs) { + my $error = $export->export_attr_insert($attr); + die $error if $error; + } + } } sub usage {