4 use vars qw(%part_svc);
6 use Term::Query qw(query);
8 use FS::UID qw(adminsuidsetup datasrc);
9 use FS::Record qw(qsearch qsearchs);
13 my $user = shift or die &usage;
16 push @FS::svc_acct::shells, qw(/bin/sync /sbin/shutdown /bin/halt /sbin/halt); #others?
18 my($spooldir)="/usr/local/etc/freeside/export.". datasrc;
20 #$FS::svc_acct::nossh_hack = 1;
21 $FS::svc_Common::noexport_hack = 1;
25 %part_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct'});
27 die "No services with svcdb svc_acct!\n" unless %part_svc;
29 print "\n\n", &menu_svc, "\n", <<END;
30 Enter part number to import.
32 my($shell_svcpart)=&getpart;
35 Enter the location and name of your _user_ passwd file, for example
36 "mail.isp.com:/etc/passwd" or "nis.isp.com:/etc/global/passwd"
38 my($loc_passwd)=&getvalue(":");
39 iscp("root\@$loc_passwd", "$spooldir/passwd.import");
42 Enter the location and name of your _user_ shadow file, for example
43 "mail.isp.com:/etc/shadow" or "bsd.isp.com:/etc/master.passwd"
45 my($loc_shadow)=&getvalue(":");
46 iscp("root\@$loc_shadow", "$spooldir/shadow.import");
49 ( join "\n", map "$_: ".$part_svc{$_}->svc, sort keys %part_svc ). "\n";
52 $^W=0; # Term::Query isn't -w-safe
53 my $return = query "Enter part number:", 'irk', [ keys %part_svc ];
59 $^W=0; # Term::Query isn't -w-safe
60 my $return = query $prompt, '';
69 open(PASSWD,"<$spooldir/passwd.import");
70 open(SHADOW,"<$spooldir/shadow.import");
75 my($username,$password)=split(/:/);
76 #$password =~ s/^\!$/\*/;
77 #$password =~ s/\!+/\*SUSPENDED\* /;
78 $password =~ s/^NP$/\*/;
79 $password =~ s/^\*LK\*$/\*/;
80 $password{$username}=$password;
85 my($username,$x,$uid,$gid,$finger,$dir,$shell) = split(/:/);
86 my $password = $password{$username};
88 my $svcpart = $shell_svcpart;
90 #if ( qsearchs('svc_acct', { 'username' => $username } ) ) {
91 # warn "warning: $username already exists; skipping\n";
95 my($svc_acct) = new FS::svc_acct ({
96 'svcpart' => $svcpart,
97 'username' => $username,
98 '_password' => $password,
104 #%{$allparam{$username}},
107 $error=$svc_acct->insert;
109 if ( $error =~ /duplicate/i ) {
110 warn "$username: $error";
112 die "$username: $error";
119 die "Usage:\n\n passwd.import user\n";