diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-07-17 09:04:06 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-07-17 09:04:06 -0700 |
commit | 91dbe4c3834f38d428367d9a1e2c6cf9ea9d84a4 (patch) | |
tree | e4d6a63b75a2e3df13fdd35e24ae98ec8b3567cb /bin | |
parent | 2101a32bdf12abdb2afdb654d6da30975ddd4fc9 (diff) | |
parent | d0fcbc3d04250ec54cb5dea7abcc58d1f45d78b1 (diff) |
Merge branch 'master' of git.freeside.biz:/home/git/freeside
Diffstat (limited to 'bin')
-rw-r--r-- | bin/sqlradius-reexport-group | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/sqlradius-reexport-group b/bin/sqlradius-reexport-group new file mode 100644 index 000000000..70a517c62 --- /dev/null +++ b/bin/sqlradius-reexport-group @@ -0,0 +1,34 @@ +#!/usr/bin/perl + +use FS::UID 'adminsuidsetup'; +use FS::Record qw( qsearch qsearchs ); +use FS::part_export; +use FS::radius_group; + +my ($user, $exportnum, $group) = @ARGV; +die "usage: +sqlradius-reexport-group <username> <exportnum> <group> +" unless $user and $exportnum and $group; + + +my $dbh = adminsuidsetup($user) or die; +$FS::UID::AutoCommit = 0; +my $radius_group; +if ( $group =~ /^\d+$/ ) { + $radius_group = FS::radius_group->by_key($group); +} else { + $radius_group = qsearchs('radius_group',{'groupname' => $group}); +} +die "no radius group $group" unless $radius_group; + +my $export = FS::part_export->by_key($exportnum) + or die "no export with exportnum '$exportnum'"; + +my @attrs = qsearch('radius_attr', {groupnum => $radius_group->groupnum}); +foreach my $attr (@attrs) { + print $attr->attrname."\n"; + my $error = $export->export_attr_insert($attr); + die $error if $error; +} + +$dbh->commit; |