4 use vars qw($opt_s $opt_h $opt_b $opt_c $opt_g $opt_n);
8 my $FREESIDE_CONF = "/usr/local/etc/freeside";
11 die &usage if $opt_c && ! $opt_h;
12 my $user = shift or die &usage;
14 #if ( -e "$FREESIDE_CONF/mapsecrets" ) {
15 # open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
16 # or die "can't open $FREESIDE_CONF/mapsecrets: $!";
17 # while (<MAPSECRETS>) {
18 # /^(\S+) / or die "unparsable line in mapsecrets: $_";
19 # die "user $user already exists\n" if $user eq $1;
25 my @args = ( 'htpasswd' );
26 push @args, '-b' if $opt_b;
27 push @args, '-c' if $opt_c;
28 push @args, $opt_h, $user;
29 push @args, shift if $opt_b;
30 warn join(', ', 'htpasswd', @args)."\n";
31 system(@args) == 0 or die "htpasswd failed: $?";
35 open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets")
36 and flock(MAPSECRETS,LOCK_EX)
37 or die "can't open $FREESIDE_CONF/mapsecrets: $!";
38 print MAPSECRETS "$user $opt_s\n";
39 close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!";
48 use FS::UID qw(adminsuidsetup);
51 use FS::access_usergroup;
53 $FS::CurrentUser::upgrade_hack = 1;
54 #adminsuidsetup $rootuser;
57 my $access_user = new FS::access_user {
59 '_password' => 'notyet',
60 'first' => 'Firstname', # $opt_f ||
61 'last' => 'Lastname', # $opt_l ||
63 my $au_error = $access_user->insert;
64 die $au_error if $au_error;
68 my $access_usergroup = new FS::access_usergroup {
69 'usernum' => $access_user->usernum,
72 my $aug_error = $access_usergroup->insert;
73 die $aug_error if $aug_error;
80 die "Usage:\n\n freeside-adduser [ -h htpasswd_file [ -c ] [ -b ] ] [ -g groupnum ] username [ password ]"
85 freeside-adduser - Command line interface to add (freeside) users.
89 freeside-adduser [ -n ] [ -h htpasswd_file [ -c ] [ -b ] ] [ -g groupnum ] username [ password ]
93 Adds a user to the Freeside billing system. This is for adding users (internal
94 sales/tech folks) to the web interface, not for adding customer accounts.
96 -h: Also call htpasswd for this user with the given filename
98 -c: Passed to htpasswd(1)
100 -b: same as htpasswd(1), probably insecure, not recommended
104 Development/multi-DB options:
106 -s: alternate secrets file
108 -n: no ACL added, for bootstrapping
112 L<htpasswd>(1), base Freeside documentation