projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
RT# 31208 Docs $FS::Record::qsearch_qualify_columns
[freeside.git]
/
FS
/
bin
/
freeside-setup
diff --git
a/FS/bin/freeside-setup
b/FS/bin/freeside-setup
index
7ea1025
..
155c74a
100755
(executable)
--- a/
FS/bin/freeside-setup
+++ b/
FS/bin/freeside-setup
@@
-1,10
+1,15
@@
-#!/usr/bin/perl -
T
w
+#!/usr/bin/perl -w
#to delay loading dbdef until we're ready
BEGIN { $FS::Schema::setup_hack = 1; }
#to delay loading dbdef until we're ready
BEGIN { $FS::Schema::setup_hack = 1; }
+#to allow initial insert
+use FS::part_pkg;
+$FS::part_pkg::setup_hack = 1;
+$FS::part_pkg::setup_hack = 1;
+
use strict;
use strict;
-use vars qw($opt_u $opt_d $opt_v);
+use vars qw($opt_u $opt_d $opt_v
$opt_q
);
use Getopt::Std;
use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
use FS::CurrentUser;
use Getopt::Std;
use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
use FS::CurrentUser;
@@
-19,9
+24,11
@@
die "Not running uid freeside!" unless checkeuid();
#my %attrib2db =
# map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
#my %attrib2db =
# map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
-getopts("u:vd:");
-my $config_dir = shift || 'conf' ;
-$config_dir =~ /^([\w.:=]+)$/
+getopts("u:vqd:");
+$opt_v = 1 unless $opt_q; #verbose by default now
+
+my $config_dir = shift || '%%%DIST_CONF%%%' ;
+$config_dir =~ /^([\w.:=\/]+)$/
or die "unacceptable configuration directory name";
$config_dir = $1;
or die "unacceptable configuration directory name";
$config_dir = $1;
@@
-32,9
+39,7
@@
my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
###
###
-#print "\nEnter the maximum username length: ";
-#my($username_len)=&getvalue;
-my $username_len = 32; #usernamemax config file
+my $username_len = 32;
#print "\n\n", <<END, ":";
#Freeside tracks the RADIUS User-Name, check attribute Password and
#print "\n\n", <<END, ":";
#Freeside tracks the RADIUS User-Name, check attribute Password and
@@
-81,7
+86,9
@@
my $username_len = 32; #usernamemax config file
# create a dbdef object from the old data structure
###
# create a dbdef object from the old data structure
###
-my $dbdef = dbdef_dist;
+warn "Loading schema objects\n" if $opt_v;
+
+my $dbdef = dbdef_dist(datasrc);
#important
$dbdef->save($dbdef_file);
#important
$dbdef->save($dbdef_file);
@@
-91,6
+98,8
@@
$dbdef->save($dbdef_file);
# create 'em
###
# create 'em
###
+warn "Connecting to database\n" if $opt_v;
+
$FS::CurrentUser::upgrade_hack = 1;
$FS::UID::callback_hack = 1;
my $dbh = adminsuidsetup $opt_u; #$user;
$FS::CurrentUser::upgrade_hack = 1;
$FS::UID::callback_hack = 1;
my $dbh = adminsuidsetup $opt_u; #$user;
@@
-99,8
+108,9
@@
$FS::UID::callback_hack = 0;
#create tables
$|=1;
#create tables
$|=1;
+warn "Creating tables and indices\n" if $opt_v;
+
foreach my $statement ( $dbdef->sql($dbh) ) {
foreach my $statement ( $dbdef->sql($dbh) ) {
- warn $statement if $statement =~ /TABLE cdr/;
$dbh->do( $statement )
or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement";
}
$dbh->do( $statement )
or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement";
}
@@
-111,14
+121,12
@@
dbdef_create($dbh, $dbdef_file);
delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
reload_dbdef($dbdef_file);
delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
reload_dbdef($dbdef_file);
-warn "Freeside schema initialized - commiting transaction\n" if $opt_v;
-
+warn "Tables and indices created - commiting transaction\n" if $opt_v;
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
-
warn "Database schema committed successfully\n" if $opt_v;
warn "Database schema committed successfully\n" if $opt_v;
-warn "Initializing
freeside
configuration\n" if $opt_v;
+warn "Initializing configuration\n" if $opt_v;
$FS::UID::callback_hack = 1;
$dbh = adminsuidsetup $opt_u;
$FS::UID::callback_hack = 0;
$FS::UID::callback_hack = 1;
$dbh = adminsuidsetup $opt_u;
$FS::UID::callback_hack = 0;
@@
-130,21
+138,17
@@
if (!scalar(qsearch('conf', {}))) {
}
}
}
}
-warn "Freeside configuration initialized - commiting transaction\n" if $opt_v;
-
+warn "Configuration initialized - commiting transaction\n" if $opt_v;
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
-
-warn "Freeside configuration committed successfully\n" if $opt_v;
+warn "Configuration committed successfully\n" if $opt_v;
$dbh = adminsuidsetup $opt_u;
create_initial_data('domain' => $opt_d);
$dbh = adminsuidsetup $opt_u;
create_initial_data('domain' => $opt_d);
-warn "Freeside database initialized - commiting transaction\n" if $opt_v;
-
+warn "Database initialized - commiting transaction\n" if $opt_v;
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
$dbh->commit or die $dbh->errstr;
$dbh->disconnect or die $dbh->errstr;
-
warn "Database initialization committed successfully\n" if $opt_v;
sub dbdef_create { # reverse engineer the schema from the DB and save to file
warn "Database initialization committed successfully\n" if $opt_v;
sub dbdef_create { # reverse engineer the schema from the DB and save to file
@@
-154,7
+158,7
@@
sub dbdef_create { # reverse engineer the schema from the DB and save to file
}
sub usage {
}
sub usage {
- die "Usage:\n freeside-setup -d domain.name [ -
v
] [ config/dir ]\n"
+ die "Usage:\n freeside-setup -d domain.name [ -
q
] [ config/dir ]\n"
# [ -u user ] for devel/multi-db installs
}
# [ -u user ] for devel/multi-db installs
}