3 # $Id: freeside-adduser,v 1.11 2006-06-30 14:30:26 ivan Exp $
6 use vars qw($opt_h $opt_b $opt_c $opt_g);
10 my $FREESIDE_CONF = "/usr/local/etc/freeside";
13 die &usage if $opt_c && ! $opt_h;
14 my $user = shift or die &usage;
16 #if ( -e "$FREESIDE_CONF/mapsecrets" ) {
17 # open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
18 # or die "can't open $FREESIDE_CONF/mapsecrets: $!";
19 # while (<MAPSECRETS>) {
20 # /^(\S+) / or die "unparsable line in mapsecrets: $_";
21 # die "user $user already exists\n" if $user eq $1;
27 my @args = ( 'htpasswd' );
28 push @args, '-b' if $opt_b;
29 push @args, '-c' if $opt_c;
30 push @args, $opt_h, $user;
31 push @args, shift if $opt_b;
32 system(@args) == 0 or die "htpasswd failed: $?";
35 #my $secretfile = $opt_s || 'secrets';
37 #open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets")
38 # and flock(MAPSECRETS,LOCK_EX)
39 # or die "can't open $FREESIDE_CONF/mapsecrets: $!";
40 #print MAPSECRETS "$user $secretfile\n";
41 #close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!";
45 use FS::UID qw(adminsuidsetup);
48 use FS::access_usergroup;
50 $FS::CurrentUser::upgrade_hack = 1;
51 #adminsuidsetup $rootuser;
54 my $access_user = new FS::access_user {
56 '_password' => 'notyet',
57 'first' => 'Firstname', # $opt_f ||
58 'last' => 'Lastname', # $opt_l ||
60 my $au_error = $access_user->insert;
61 die $au_error if $au_error;
65 my $access_usergroup = new FS::access_usergroup {
66 'usernum' => $access_user->usernum,
69 my $aug_error = $access_usergroup->insert;
70 die $aug_error if $aug_error;
77 die "Usage:\n\n freeside-adduser [ -h htpasswd_file [ -c ] [ -b ] ] [ -g groupnum ] username"
82 freeside-adduser - Command line interface to add (freeside) users.
86 freeside-adduser [ -h htpasswd_file [ -c ] ] -g 1 username
90 Adds a user to the Freeside billing system. This is for adding users (internal
91 sales/tech folks) to the web interface, not for adding customer accounts.
93 -h: Also call htpasswd for this user with the given filename
95 -c: Passed to htpasswd(1)
97 -b: same as htpasswd(1), probably insecure, not recommended
103 L<htpasswd>(1), base Freeside documentation