`make create-config' installs default config (conf dir update)
[freeside.git] / FS / bin / freeside-adduser
1 #!/usr/bin/perl -w
2 #
3 # $Id: freeside-adduser,v 1.3 2001-10-30 13:47:07 ivan Exp $
4
5 use strict;
6 use vars qw($opt_h $opt_c $opt_s);
7 use Getopt::Std;
8
9 my $FREESIDE_CONF = "/usr/local/etc/freeside";
10
11 getopts("ch:s:");
12 die &usage if $opt_c && ! $opt_h;
13 my $user = shift or die &usage;
14
15 my @args = ( 'htpasswd' );
16 push @args, '-c' if $opt_c;
17 push @args, $opt_h, $user;
18 system(@args) == 0 or die "htpasswd failed: $?";
19
20 my $secretfile = $opt_s || 'secrets';
21
22 open(MAPSECRETS,">>$FREESIDE_CONF/mapsecrets")
23   or die "can't open $FREESIDE_CONF/mapsecrets: $!";
24 print MAPSECRETS "$user $secretfile\n";
25 close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!";
26
27 sub usage {
28   die "Usage:\n\n  freeside-adduser [ -h htpasswd_file [ -c ] ] [ -s secretfile ] username"
29 }
30
31 =head1 NAME
32
33 freeside-adduser - Command line interface to add (freeside) users.
34
35 =head1 SYNOPSIS
36
37   freeside-adduser [ -h htpasswd_file [ -c ] ] [ -s secretfile ] username
38
39 =head1 DESCRIPTION
40
41 Adds a user to the Freeside billing system.  This is for adding users (internal
42 sales/tech folks) to the web interface, not for adding customer accounts.
43
44   -h: Also call htpasswd for this user with the given filename
45
46   -c: Passed to htpasswd
47
48   -s: Specify an alternate secret file
49
50 =head1 SEE ALSO
51
52 L<htpasswd>, base Freeside documentation
53
54 =cut
55