diff options
author | ivan <ivan> | 2002-04-13 13:36:26 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-04-13 13:36:26 +0000 |
commit | 327df8aefdcf96c9c83805570abf4cc242cf46b9 (patch) | |
tree | b9b06b34a52abff0a7976a42613ccfbe98f6de14 /FS/bin/freeside-sqlradius-reset | |
parent | 8d77be096e5f1cec2d64182d1f95d13a1744a6d5 (diff) |
- documentation updates
- move Critical Path export to new-style export
- bin/sqlradius_reset gets a manpage and becomes FS/bin/freeside-sqlradius-reset
Diffstat (limited to 'FS/bin/freeside-sqlradius-reset')
-rwxr-xr-x | FS/bin/freeside-sqlradius-reset | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset new file mode 100755 index 000000000..132be754a --- /dev/null +++ b/FS/bin/freeside-sqlradius-reset @@ -0,0 +1,73 @@ +#!/usr/bin/perl -Tw + +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 = qsearch('part_export', { 'exporttype' => 'sqlradius' } ); + +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; + } +} + +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 ) { + + #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 sqlradius_reset user machine\n"; + die "Usage:\n\n sqlradius_reset user\n"; +} + +=head1 NAME + +freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS SQL tables + +=head1 SYNOPSIS + + freeside-sqlradius-reset username + +=head1 DESCRIPTION + +Deletes the radcheck, radreply and usergroup tables and repopulates them from +the Freeside database, for all sqlradius exports. + +B<username> is a username added by freeside-adduser. + +=head1 SEE ALSO + +<FS::part_export>, L<FS::part_export::sqlradius> + +=cut + + + |