X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-sqlradius-reset;h=225de15be2b10c5559d7f605f539657b435f8df7;hp=8ecd39d9578f33f76f19adef0d6d98205b1ef581;hb=01776c9e52c63662403dcb19155ffe3bc8a035ee;hpb=addc359b0c1b1771d6ccc3de372f3a584e677c94 diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset index 8ecd39d95..225de15be 100755 --- a/FS/bin/freeside-sqlradius-reset +++ b/FS/bin/freeside-sqlradius-reset @@ -3,6 +3,7 @@ use strict; use vars qw( $opt_n ); use Getopt::Std; +use FS::DBI; use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearch qsearchs); use FS::part_export; @@ -31,11 +32,14 @@ if ( @ARGV ) { unless ( $opt_n ) { foreach my $export ( @exports ) { - my $icradius_dbh = DBI->connect( + my $icradius_dbh = FS::DBI->connect( map { $export->option($_) } qw( datasrc username password ) - ) or die $DBI::errstr; + ) or die $FS::DBI::errstr; my $usergroup = $export->option('usergroup') || 'usergroup'; - for my $table (qw( radcheck radreply ), $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; } @@ -47,6 +51,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; @@ -85,6 +92,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 {