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