summaryrefslogtreecommitdiff
path: root/FS/bin/freeside-sqlradius-reset
diff options
context:
space:
mode:
authorivan <ivan>2007-08-15 23:46:34 +0000
committerivan <ivan>2007-08-15 23:46:34 +0000
commit7b5ee7aa4b9789b230cef4163a06c0dbaa2136e1 (patch)
treeef854be2e48845052c08b9159ffa931231b233b5 /FS/bin/freeside-sqlradius-reset
parent509e925804335b3cec474f25f57dbdbde939c322 (diff)
add -n option to freeside-sqlradius-reset to supress deleting data
Diffstat (limited to 'FS/bin/freeside-sqlradius-reset')
-rwxr-xr-xFS/bin/freeside-sqlradius-reset27
1 files changed, 18 insertions, 9 deletions
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset
index a2da7452e..94fa68a06 100755
--- a/FS/bin/freeside-sqlradius-reset
+++ b/FS/bin/freeside-sqlradius-reset
@@ -1,12 +1,16 @@
#!/usr/bin/perl -w
use strict;
+use vars qw( $opt_n );
+use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::part_export;
use FS::svc_acct;
use FS::cust_svc;
+getopts("n");
+
my $user = shift or die &usage;
adminsuidsetup $user;
@@ -25,15 +29,17 @@ if ( @ARGV ) {
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;
+unless ( $opt_n ) {
+ 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;
}
- $icradius_dbh->disconnect;
}
foreach my $export ( @exports ) {
@@ -75,7 +81,7 @@ freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS S
=head1 SYNOPSIS
- freeside-sqlradius-reset username [ EXPORTNUM, ... ]
+ freeside-sqlradius-reset [ -n ] username [ EXPORTNUM, ... ]
=head1 DESCRIPTION
@@ -85,6 +91,9 @@ specified, for all sqlradius and sqlradius_withdomain exports.
B<username> is a username added by freeside-adduser.
+The B<-n> option, if supplied, supresses the deletion of the existing data in
+the tables.
+
=head1 SEE ALSO
L<freeside-reexport>, L<FS::part_export>, L<FS::part_export::sqlradius>