From a2b0b3e8500b08a5cf017c85693d9649853f8569 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 16 Feb 2006 21:43:02 +0000 Subject: automate more of the initial data adding... --- FS/bin/freeside-setup | 73 ++++++--------------------------------------------- 1 file changed, 8 insertions(+), 65 deletions(-) (limited to 'FS/bin/freeside-setup') diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index a16e51749..bff2bcc63 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -4,23 +4,20 @@ BEGIN { $FS::Schema::setup_hack = 1; } use strict; -use vars qw($opt_s); +use vars qw($opt_s $opt_d $opt_v); use Getopt::Std; -use Locale::Country; -use Locale::SubCountry; use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Schema qw( dbdef_dist reload_dbdef ); use FS::Record; -use FS::cust_main_county; #use FS::raddb; -use FS::part_bill_event; +use FS::Setup qw(create_initial_data); die "Not running uid freeside!" unless checkeuid(); #my %attrib2db = # map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; -getopts("s"); +getopts("svd:"); my $user = shift or die &usage; getsecrets($user); @@ -94,6 +91,7 @@ my $dbh = adminsuidsetup $user; $|=1; foreach my $statement ( $dbdef->sql($dbh) ) { + warn $statement if $statement =~ /TABLE cdr/; $dbh->do( $statement ) or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement"; } @@ -104,69 +102,14 @@ dbdef_create($dbh, $dbdef_file); delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload reload_dbdef($dbdef_file); -#cust_main_county -foreach my $country ( sort map uc($_), all_country_codes ) { +create_initial_data('domain' => $opt_d); - my $subcountry = eval { new Locale::SubCountry($country) }; - my @states = $subcountry ? $subcountry->all_codes : undef; - - if ( !scalar(@states) || ( scalar(@states) == 1 && !defined($states[0]) ) ) { - - my $cust_main_county = new FS::cust_main_county({ - 'tax' => 0, - 'country' => $country, - }); - my $error = $cust_main_county->insert; - die $error if $error; - - } else { - - if ( $states[0] =~ /^(\d+|\w)$/ ) { - @states = map $subcountry->full_name($_), @states - } - - foreach my $state ( @states ) { - - my $cust_main_county = new FS::cust_main_county({ - 'state' => $state, - 'tax' => 0, - 'country' => $country, - }); - my $error = $cust_main_county->insert; - die $error if $error; - - } - - } -} - -#billing events -foreach my $aref ( - #[ 'COMP', 'Comp invoice', '$cust_bill->comp();', 30, 'comp' ], - [ 'CARD', 'Batch card', '$cust_bill->batch_card();', 40, 'batch-card' ], - [ 'BILL', 'Send invoice', '$cust_bill->send();', 50, 'send' ], - [ 'DCRD', 'Send invoice', '$cust_bill->send();', 50, 'send' ], - [ 'DCHK', 'Send invoice', '$cust_bill->send();', 50, 'send' ], -) { - - my $part_bill_event = new FS::part_bill_event({ - 'payby' => $aref->[0], - 'event' => $aref->[1], - 'eventcode' => $aref->[2], - 'seconds' => 0, - 'weight' => $aref->[3], - 'plan' => $aref->[4], - }); - my($error); - $error=$part_bill_event->insert; - die $error if $error; - -} +warn "Freeside database initialized - commiting transaction\n" if $opt_v; $dbh->commit or die $dbh->errstr; $dbh->disconnect or die $dbh->errstr; -#print "Freeside database initialized sucessfully\n"; +warn "Database initialization committed sucessfully\n" if $opt_v; sub dbdef_create { # reverse engineer the schema from the DB and save to file my( $dbh, $file ) = @_; @@ -175,7 +118,7 @@ sub dbdef_create { # reverse engineer the schema from the DB and save to file } sub usage { - die "Usage:\n freeside-setup user\n"; + die "Usage:\n freeside-setup -d domain.name [ -v ] user\n"; } 1; -- cgit v1.2.1 From b9f9a5dc444a66ca138073a0e5229d85569e51b4 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 25 Mar 2006 02:23:26 +0000 Subject: successfully correct the spelling of sucessful --- FS/bin/freeside-setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'FS/bin/freeside-setup') diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index bff2bcc63..9f87f10b7 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -109,7 +109,7 @@ warn "Freeside database initialized - commiting transaction\n" if $opt_v; $dbh->commit or die $dbh->errstr; $dbh->disconnect or die $dbh->errstr; -warn "Database initialization committed sucessfully\n" if $opt_v; +warn "Database initialization committed successfully\n" if $opt_v; sub dbdef_create { # reverse engineer the schema from the DB and save to file my( $dbh, $file ) = @_; -- cgit v1.2.1 From e5742a8ccfca16427631a45fc8895d6fc1a493dd Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 12 Jul 2006 23:33:56 +0000 Subject: add acl bootstrapping - should be installable again now --- FS/bin/freeside-setup | 2 ++ 1 file changed, 2 insertions(+) (limited to 'FS/bin/freeside-setup') diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index 9f87f10b7..138011430 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -7,6 +7,7 @@ use strict; use vars qw($opt_s $opt_d $opt_v); use Getopt::Std; use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); +use FS::CurrentUser; use FS::Schema qw( dbdef_dist reload_dbdef ); use FS::Record; #use FS::raddb; @@ -85,6 +86,7 @@ $dbdef->save($dbdef_file); # create 'em ### +$FS::CurrentUser::upgrade_hack = 1; my $dbh = adminsuidsetup $user; #create tables -- cgit v1.2.1 From 9bc0e873966642f415795525f8a2a57381afb080 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 14 Jul 2006 00:32:12 +0000 Subject: should be able to freeside-setup without a username now --- FS/bin/freeside-setup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'FS/bin/freeside-setup') diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index 138011430..2ba717cb3 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -19,8 +19,8 @@ die "Not running uid freeside!" unless checkeuid(); # map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; getopts("svd:"); -my $user = shift or die &usage; -getsecrets($user); +#my $user = shift or die &usage; +getsecrets(); #$user); #needs to match FS::Record my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; @@ -87,7 +87,7 @@ $dbdef->save($dbdef_file); ### $FS::CurrentUser::upgrade_hack = 1; -my $dbh = adminsuidsetup $user; +my $dbh = adminsuidsetup; #$user; #create tables $|=1; -- cgit v1.2.1 From 31b3104093a59887fd0ec7fc86ef3249de233265 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Sep 2006 01:08:20 +0000 Subject: new world ACLs --- FS/bin/freeside-setup | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'FS/bin/freeside-setup') diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index 2ba717cb3..a51dfd7a0 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -4,7 +4,7 @@ BEGIN { $FS::Schema::setup_hack = 1; } use strict; -use vars qw($opt_s $opt_d $opt_v); +use vars qw($opt_u $opt_d $opt_v); use Getopt::Std; use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::CurrentUser; @@ -18,9 +18,10 @@ die "Not running uid freeside!" unless checkeuid(); #my %attrib2db = # map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; -getopts("svd:"); +getopts("u:vd:"); #my $user = shift or die &usage; -getsecrets(); #$user); + +getsecrets($opt_u); #$user); #needs to match FS::Record my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; @@ -87,7 +88,7 @@ $dbdef->save($dbdef_file); ### $FS::CurrentUser::upgrade_hack = 1; -my $dbh = adminsuidsetup; #$user; +my $dbh = adminsuidsetup $opt_u; #$user; #create tables $|=1; @@ -120,7 +121,8 @@ sub dbdef_create { # reverse engineer the schema from the DB and save to file } sub usage { - die "Usage:\n freeside-setup -d domain.name [ -v ] user\n"; + die "Usage:\n freeside-setup -d domain.name [ -v ]\n" + # [ -u user ] for devel/multi-db installs } 1; -- cgit v1.2.1 From 7422aa77086326ba1e6032150ce5704d1003ea6f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 14 Dec 2006 09:27:26 +0000 Subject: make the config directory configurable --- FS/bin/freeside-setup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'FS/bin/freeside-setup') diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index a51dfd7a0..ddc210f50 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -24,7 +24,7 @@ getopts("u:vd:"); getsecrets($opt_u); #$user); #needs to match FS::Record -my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; +my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc; ### @@ -127,3 +127,4 @@ sub usage { 1; + -- cgit v1.2.1