diff options
| author | ivan <ivan> | 2002-10-18 10:28:42 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2002-10-18 10:28:42 +0000 | 
| commit | 2c6c76e763173fea0ac30a5a6c0e50ad7ace147f (patch) | |
| tree | 4b9bb97f3705aa74945dfa8f8b18535fbf14bdcd | |
| parent | 7c3f2ea06574bbfc946ee24c5ae66b2b0f08abbf (diff) | |
adding
| -rw-r--r-- | FS/MANIFEST | 1 | ||||
| -rw-r--r-- | FS/bin/freeside-radgroup | 76 | 
2 files changed, 77 insertions, 0 deletions
| diff --git a/FS/MANIFEST b/FS/MANIFEST index 99b0f82e8..1489cd0e9 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -14,6 +14,7 @@ bin/freeside-adduser  bin/freeside-setup  bin/freeside-setinvoice  bin/freeside-overdue +bin/freeside-radgroup  bin/freeside-receivables-report  bin/freeside-sqlradius-radacctd  bin/freeside-sqlradius-reset diff --git a/FS/bin/freeside-radgroup b/FS/bin/freeside-radgroup new file mode 100644 index 000000000..e1a819788 --- /dev/null +++ b/FS/bin/freeside-radgroup @@ -0,0 +1,76 @@ +#!/usr/bin/perl -w + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); +use FS::cust_svc; +use FS::svc_acct; + +&untaint_argv;  #what it sounds like  (eww) + +my($user, $action, $groupname, $svcpart) = @ARGV; + +adminsuidsetup $user; + +my @svc_acct = map { $_->svc_x } qsearch('cust_svc', { svcpart => $svcpart } ); + +if ( lc($action) eq 'add' ) { +  foreach my $svc_acct ( @svc_acct ) { +    my @groups = $svc_acct->radius_groups; +    next if grep { $_ eq $groupname } @groups; +    push @groups, $groupname; +    my %hash = $svc_acct->hash; +    $hash{radius_groups} = \@groups; +    my $new = new FS::svc_acct \%hash; +    my $error = $new->replace($svc_acct); +    die $error if $error; +  } +} else { +  die &usage; +} + +# subroutines + +sub untaint_argv { +  foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV +    $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\""; +    $ARGV[$_]=$1; +  } +} + +sub usage { +  die "Usage:\n\n  freeside-radgroup user action groupname svcpart\n"; +} + +=head1 NAME + +freeside-radgroup - Command line utility to manipulate radius groups + +=head1 SYNOPSIS + +  freeside-addgroup user action groupname svcpart  + +=head1 DESCRIPTION + +  B<user> is a freeside user as added with freeside-adduser. + +  B<command> is the action to take.  Available actions are: I<add> + +  B<groupname> is the group to add (or remove, etc.) + +  B<svcpart> specifies which accounts will be updated. + +=head1 EXAMPLES + +freeside-radgroup freesideuser add groupname 3 + +Adds I<groupname> to all accounts with service definition 3. + +=head1 BUGS + +=head1 SEE ALSO + +L<freeside-adduser>, L<FS::svc_acct>, L<FS::part_svc> + +=cut + | 
