4 use FS::UID qw(adminsuidsetup);
5 use FS::Record qw(qsearch qsearchs);
10 my $user = shift or die &usage;
13 #my $machine = shift or die &usage;
17 foreach my $exportnum ( @ARGV ) {
18 foreach my $exporttype (qw( sqlradius sqlradius_withdomain )) {
19 push @exports, qsearch('part_export', { exportnum => $exportnum,
20 exporttype => $exporttype, } );
24 @exports = qsearch('part_export', { exporttype=>'sqlradius' } );
25 push @exports, qsearch('part_export', { exporttype=>'sqlradius_withdomain' } );
28 foreach my $export ( @exports ) {
29 my $icradius_dbh = DBI->connect(
30 map { $export->option($_) } qw( datasrc username password )
31 ) or die $DBI::errstr;
32 for my $table (qw( radcheck radreply usergroup )) {
33 my $sth = $icradius_dbh->prepare("DELETE FROM $table");
34 $sth->execute or die "Can't reset $table table: ". $sth->errstr;
36 $icradius_dbh->disconnect;
39 foreach my $export ( @exports ) {
41 #my @svcparts = map { $_->svcpart } $export->export_svc;
44 map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
45 map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
46 grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
49 foreach my $svc_acct ( @svc_acct ) {
51 #false laziness with FS::svc_acct::insert (like it matters)
52 my $error = $export->export_insert($svc_acct);
59 die "Usage:\n\n freeside-sqlradius-reset user [ exportnum, ... ]\n";
64 freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS SQL tables
68 freeside-sqlradius-reset username [ EXPORTNUM, ... ]
72 Deletes the radcheck, radreply and usergroup tables and repopulates them from
73 the Freeside database, for the specified exports, or, if no exports are
74 specified, for all sqlradius and sqlradius_withdomain exports.
76 B<username> is a username added by freeside-adduser.
80 L<freeside-reexport>, L<FS::part_export>, L<FS::part_export::sqlradius>