[freeside-commits] freeside/FS/bin freeside-sqlradius-reset, 1.10, 1.11
Ivan,,,
ivan at wavetail.420.am
Wed Aug 15 16:46:36 PDT 2007
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail:/tmp/cvs-serv31304
Modified Files:
freeside-sqlradius-reset
Log Message:
add -n option to freeside-sqlradius-reset to supress deleting data
Index: freeside-sqlradius-reset
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-sqlradius-reset,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- freeside-sqlradius-reset 7 May 2007 06:35:55 -0000 1.10
+++ freeside-sqlradius-reset 15 Aug 2007 23:46:34 -0000 1.11
@@ -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 @@
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 @@
=head1 SYNOPSIS
- freeside-sqlradius-reset username [ EXPORTNUM, ... ]
+ freeside-sqlradius-reset [ -n ] username [ EXPORTNUM, ... ]
=head1 DESCRIPTION
@@ -85,6 +91,9 @@
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>
More information about the freeside-commits
mailing list