diff options
Diffstat (limited to 'FS/bin/freeside-sqlradius-reset')
-rwxr-xr-x | FS/bin/freeside-sqlradius-reset | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset deleted file mode 100755 index 2ac5012d4..000000000 --- a/FS/bin/freeside-sqlradius-reset +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -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 $machine = shift or die &usage; - -my @exports = (); -if ( @ARGV ) { - foreach my $exportnum ( @ARGV ) { - foreach my $exporttype (qw( sqlradius sqlradius_withdomain )) { - push @exports, qsearch('part_export', { exportnum => $exportnum, - exporttype => $exporttype, } ); - } - } - } else { - @exports = qsearch('part_export', { exporttype=>'sqlradius' } ); - push @exports, qsearch('part_export', { exporttype=>'sqlradius_withdomain' } ); -} - -foreach my $export ( @exports ) { - my $icradius_dbh = DBI->connect( - map { $export->option($_) } qw( datasrc username password ) - ) or die $DBI::errstr; - for my $table (qw( radcheck radreply usergroup )) { - my $sth = $icradius_dbh->prepare("DELETE FROM $table"); - $sth->execute or die "Can't reset $table table: ". $sth->errstr; - } - $icradius_dbh->disconnect; -} - -foreach my $export ( @exports ) { - - #my @svcparts = map { $_->svcpart } $export->export_svc; - - my @svc_acct = - map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } - map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } - grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) } - $export->export_svc; - - foreach my $svc_acct ( @svc_acct ) { - - $svc_acct->check; #set any fixed usergroup so it'll export even if all - #svc_acct records don't have the group yet - - #false laziness with FS::svc_acct::insert (like it matters) - my $error = $export->export_insert($svc_acct); - die $error if $error; - - } -} - -sub usage { - die "Usage:\n\n freeside-sqlradius-reset user [ exportnum, ... ]\n"; -} - -=head1 NAME - -freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS SQL tables - -=head1 SYNOPSIS - - freeside-sqlradius-reset username [ EXPORTNUM, ... ] - -=head1 DESCRIPTION - -Deletes the radcheck, radreply and usergroup tables and repopulates them from -the Freeside database, for the specified exports, or, if no exports are -specified, for all sqlradius and sqlradius_withdomain exports. - -B<username> is a username added by freeside-adduser. - -=head1 SEE ALSO - -L<freeside-reexport>, L<FS::part_export>, L<FS::part_export::sqlradius> - -=cut - - - |