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