X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=bin%2Fsvc_acct.import;h=691798b0991237f6b9dfef1dfd3472b48e293a7e;hp=c22cb0d152d89f42749222dfd451f02cec8813b8;hb=88e029c6fab66a6596153b0f3d1f86e110f149ed;hpb=beea3b3e0c801ceeb05eee672957d318930a9a2d diff --git a/bin/svc_acct.import b/bin/svc_acct.import index c22cb0d15..691798b09 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.4 1999-03-24 00:43:38 ivan Exp $ +# $Id: svc_acct.import,v 1.10 2000-06-28 12:32:30 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,22 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.4 1999-03-24 00:43:38 ivan +# Revision 1.10 2000-06-28 12:32:30 ivan +# allow RADIUS lines with "Auth-Type = Local" too +# +# Revision 1.8 2000/02/03 05:16:52 ivan +# beginning of DNS and Apache support +# +# Revision 1.7 1999/07/08 02:32:26 ivan +# import fix, noticed by Ben Leibig and Joel Griffiths +# +# Revision 1.6 1999/07/08 01:49:00 ivan +# updates to avoid -w warnings from Joel Griffiths +# +# Revision 1.5 1999/03/25 08:42:19 ivan +# import stuff uses Term::Query and spits out (some kinds of) nonsensical input +# +# Revision 1.4 1999/03/24 00:43:38 ivan # die if no relevant services # # Revision 1.3 1998/12/10 07:23:16 ivan @@ -30,6 +45,7 @@ use strict; use vars qw(%part_svc); use Date::Parse; +use Term::Query qw(query); use FS::SSH qw(iscp); use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch); @@ -74,8 +90,7 @@ my($oisdn_svcpart)=&getpart; print "\n\n", &menu_svc, "\n", <svc, sort keys %part_svc ). "\n"; } sub getpart { - print "Enter part number, or 0 for none: "; - &getvalue; + $^W=0; # Term::Query isn't -w-safe + my $return = query "Enter part number:", 'irk', [ keys %part_svc ]; + $^W=1; + $return; } sub getvalue { - my($x)=scalar(); - chop $x; - $x; + my $prompt = shift; + $^W=0; # Term::Query isn't -w-safe + my $return = query $prompt, ''; + $^W=1; + $return; } print "\n\n"; @@ -132,12 +148,13 @@ my(%upassword,%ip,%allparam); my(%param,$username); while () { chop; - next if /^$/; + next if /^\s*$/; + next if /^\s*#/; if ( /^\S/ ) { - /^(\w+)\s+Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ + /^(\w+)\s+(Auth-Type\s+=\s+Local,\s+)Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ or die "1Unexpected line in users.import: $_"; my($password,$expiration); - ($username,$password,$expiration)=(lc($1),$2,$4); + ($username,$password,$expiration)=(lc($1),$3,$5); $password = '' if $password eq 'UNIX'; $upassword{$username}=$password; undef %param; @@ -147,8 +164,12 @@ while () { while () { chop; if ( /^\s*$/ ) { - $ip{$username}=$param{'radius_Framed_IP_Address'}||'0e0'; - delete $param{'radius_Framed_IP_Address'}; + if ( defined $param{'radius_Framed_IP_Address'} ) { + $ip{$username} = $param{'radius_Framed_IP_Address'}; + delete $param{'radius_Framed_IP_Address'}; + } else { + $ip{$username} = '0e0'; + } $allparam{$username}={ %param }; last; } elsif ( /^\s+([\w\-]+)\s=\s"?([\w\.\-\s]+)"?,?\s*$/ ) { @@ -161,8 +182,12 @@ while () { } } #? incase there isn't a terminating blank line ? -$ip{$username}=$param{'radius_Framed_IP_Address'}||'0e0'; -delete $param{'radius_Framed_IP_Address'}; +if ( defined $param{'radius_Framed_IP_Address'} ) { + $ip{$username} = $param{'radius_Framed_IP_Address'}; + delete $param{'radius_Framed_IP_Address'}; +} else { + $ip{$username} = '0e0'; +} $allparam{$username}={ %param }; my(%password); @@ -193,7 +218,7 @@ while () { $svcpart = $shell_svcpart; } - my($svc_acct) = create FS::svc_acct ({ + my($svc_acct) = new FS::svc_acct ({ 'svcpart' => $svcpart, 'username' => $username, 'password' => $password, @@ -227,7 +252,7 @@ foreach $username ( keys %upassword ) { die "Illegal Port-Limit in users!\n"; } - my($svc_acct) = create FS::svc_acct ({ + my($svc_acct) = new FS::svc_acct ({ 'svcpart' => $svcpart, 'username' => $username, 'password' => $password, @@ -245,6 +270,6 @@ foreach $username ( keys %upassword ) { # sub usage { - die "Usage:\n\n svc_acct.export user\n"; + die "Usage:\n\n svc_acct.import user\n"; }