X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Ftextradius.pm;h=07de875638f4107570ff6a78b10bf2459890d965;hb=9aee669886202be7035e6c6049fc71bc99dd3013;hp=691753f25550ce0ef7f6db548b98fed36aa54fb5;hpb=6f8f8741b105fdc1fc005536e6ee0acbd5783793;p=freeside.git
diff --git a/FS/FS/part_export/textradius.pm b/FS/FS/part_export/textradius.pm
index 691753f25..07de87563 100644
--- a/FS/FS/part_export/textradius.pm
+++ b/FS/FS/part_export/textradius.pm
@@ -1,13 +1,37 @@
package FS::part_export::textradius;
-use vars qw(@ISA $prefix);
+use vars qw(@ISA %info $prefix);
use Fcntl qw(:flock);
+use Tie::IxHash;
use FS::UID qw(datasrc);
use FS::part_export;
@ISA = qw(FS::part_export);
-$prefix = "/usr/local/etc/freeside/export.";
+tie my %options, 'Tie::IxHash',
+ 'user' => { label=>'Remote username', default=>'root' },
+ 'users' => { label=>'users file location', default=>'/etc/raddb/users' },
+;
+
+%info = (
+ 'svc' => 'svc_acct',
+ 'desc' =>
+ 'Real-time export to a text /etc/raddb/users file (Livingston, Cistron)',
+ 'options' => \%options,
+ 'default_svc_class' => 'Internet',
+ 'notes' => <<'END'
+This will edit a text RADIUS users file in place on a remote server.
+Requires installation of
+RADIUS::UserFile
+from CPAN. If using RADIUS::UserFile 1.01, make sure to apply
+this patch. Also
+make sure rsync is installed on the
+remote machine, and SSH is setup for unattended
+operation.
+END
+);
+
+$prefix = "%%%FREESIDE_CONF%%%/export.";
sub rebless { shift; }
@@ -43,7 +67,7 @@ sub textradius_queue {
'job' => "FS::part_export::textradius::textradius_$method",
};
$queue->insert(
- $self->option('user'),
+ $self->option('user')||'root',
$self->machine,
$self->option('users'),
@_,
@@ -55,7 +79,7 @@ sub textradius_insert { #subroutine, not method
#silly arg processing
my($att, @check);
- push @check, $att while ($att=shift @attributes) ne '-';
+ push @check, $att while @attributes && ($att=shift @attributes) ne '-';
my %check = @check;
my %reply = @attributes;
@@ -126,7 +150,13 @@ sub textradius_download {
$rsync->exec( {
src => "$user\@$host:$users",
dest => $dest,
- } );
+ } ); # true/false return value from exec is not working, alas
+ if ( $rsync->err ) {
+ die "error downloading $user\@$host:$users : ".
+ 'exit status: '. $rsync->status. ', '.
+ 'STDERR: '. join(" / ", $rsync->err). ', '.
+ 'STDOUT: '. join(" / ", $rsync->out);
+ }
$dest;
}
@@ -145,10 +175,18 @@ sub textradius_upload {
$rsync->exec( {
src => "$dir/users",
dest => "$user\@$host:$users",
- } );
+ } ); # true/false return value from exec is not working, alas
+ if ( $rsync->err ) {
+ die "error uploading to $user\@$host:$users : ".
+ 'exit status: '. $rsync->status. ', '.
+ 'STDERR: '. join(" / ", $rsync->err). ', '.
+ 'STDOUT: '. join(" / ", $rsync->out);
+ }
flock(LOCK,LOCK_UN);
close LOCK;
}
+1;
+