X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-setup;h=ddff81ef9ce69bec38fcf68b5f6de6f5a1c05285;hb=c6ba0fa6271880599ce3d60dcd23de248526f0b8;hp=bce5a0aeb36d48e9877c4b7e2e4ecf95597fd35a;hpb=fbfffdabe931d704aae420984058e61dc4196b01;p=freeside.git diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index bce5a0aeb..ddff81ef9 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -3,15 +3,21 @@ #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 vars qw($opt_u $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::Record qw( qsearch ); #use FS::raddb; use FS::Setup qw(create_initial_data); +use FS::Conf; die "Not running uid freeside!" unless checkeuid(); @@ -19,21 +25,19 @@ die "Not running uid freeside!" unless checkeuid(); # map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; getopts("u:vd:"); -my $config_dir = shift || 'conf' ; -$config_dir =~ /^([\w.:=]+)$/ +my $config_dir = shift || '%%%DIST_CONF%%%' ; +$config_dir =~ /^([\w.:=\/]+)$/ or die "unacceptable configuration directory name"; $config_dir = $1; getsecrets($opt_u); #needs to match FS::Record -my($dbdef_file) = "/usr/local/etc/newtest/dbdef.". datasrc; +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", <save($dbdef_file); @@ -99,7 +103,6 @@ $FS::UID::callback_hack = 0; $|=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"; } @@ -117,11 +120,24 @@ $dbh->disconnect or die $dbh->errstr; warn "Database schema committed successfully\n" if $opt_v; -my $init_config = "freeside-init-config"; -$init_config .= " -v" if $opt_v; -$init_config .= " -u $opt_u" if $opt_u; -$init_config .= " $config_dir"; -system "$init_config" ; +warn "Initializing freeside configuration\n" if $opt_v; +$FS::UID::callback_hack = 1; +$dbh = adminsuidsetup $opt_u; +$FS::UID::callback_hack = 0; +if (!scalar(qsearch('conf', {}))) { + my $error = FS::Conf::init_config($config_dir); + if ($error) { + $dbh->rollback or die $dbh->errstr; + die $error; + } +} + +warn "Freeside configuration initialized - commiting transaction\n" if $opt_v; + +$dbh->commit or die $dbh->errstr; +$dbh->disconnect or die $dbh->errstr; + +warn "Freeside configuration committed successfully\n" if $opt_v; $dbh = adminsuidsetup $opt_u; create_initial_data('domain' => $opt_d);