[freeside-commits] freeside/FS/bin freeside-init-config, NONE,
1.1 freeside-setup, 1.59, 1.60 freeside-upgrade, 1.5, 1.6
Jeff Finucane,420,,
jeff at wavetail.420.am
Mon Feb 26 17:48:09 PST 2007
- Previous message: [freeside-commits]
freeside/FS/FS Conf.pm, 1.181, 1.182 UID.pm, 1.32,
1.33 conf.pm, NONE, 1.1 cust_bill.pm, 1.164,
1.165 cust_main.pm, 1.272, 1.273 svc_acct.pm, 1.218, 1.219
- Next message: [freeside-commits] freeside/FS/t conf.t,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail:/tmp/cvs-serv2258/FS/bin
Modified Files:
freeside-setup freeside-upgrade
Added Files:
freeside-init-config
Log Message:
config goes in database
Index: freeside-setup
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-setup,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- freeside-setup 14 Dec 2006 09:27:26 -0000 1.59
+++ freeside-setup 27 Feb 2007 01:48:07 -0000 1.60
@@ -19,12 +19,15 @@
# map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
getopts("u:vd:");
-#my $user = shift or die &usage;
+my $config_dir = shift || 'conf' ;
+$config_dir =~ /^([\w.:=]+)$/
+ or die "unacceptable configuration directory name";
+$config_dir = $1;
-getsecrets($opt_u); #$user);
+getsecrets($opt_u);
#needs to match FS::Record
-my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
+my($dbdef_file) = "/usr/local/etc/newtest/dbdef.". datasrc;
###
@@ -88,7 +91,9 @@
###
$FS::CurrentUser::upgrade_hack = 1;
+$FS::UID::callback_hack = 1;
my $dbh = adminsuidsetup $opt_u; #$user;
+$FS::UID::callback_hack = 0;
#create tables
$|=1;
@@ -105,6 +110,20 @@
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;
+
+$dbh->commit or die $dbh->errstr;
+$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" ;
+
+$dbh = adminsuidsetup $opt_u;
create_initial_data('domain' => $opt_d);
warn "Freeside database initialized - commiting transaction\n" if $opt_v;
@@ -121,7 +140,7 @@
}
sub usage {
- die "Usage:\n freeside-setup -d domain.name [ -v ]\n"
+ die "Usage:\n freeside-setup -d domain.name [ -v ] [ config/dir ]\n"
# [ -u user ] for devel/multi-db installs
}
Index: freeside-upgrade
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-upgrade,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- freeside-upgrade 14 Dec 2006 09:27:26 -0000 1.5
+++ freeside-upgrade 27 Feb 2007 01:48:07 -0000 1.6
@@ -46,6 +46,12 @@
$dbh->disconnect or die $dbh->errstr;
+unless ( $DRY_RUN ) {
+ my $init_config = "freeside-init-config -u $user ";
+ $init_config .= "%%%FREESIDE_CONF%%%/conf.". datasrc;
+ system "$init_config" ;
+}
+
###
sub dbdef_create { # reverse engineer the schema from the DB and save to file
@@ -64,7 +70,7 @@
=head1 SYNOPSIS
- freeside-adduser [ -d ] [ -q | -v ]
+ freeside-upgrade [ -d ] [ -q | -v ]
=head1 DESCRIPTION
--- NEW FILE: freeside-init-config ---
#!/usr/bin/perl -Tw
use strict;
use vars qw($opt_u $opt_f $opt_v);
use Getopt::Std;
use IO::File;
use FS::UID qw(adminsuidsetup checkeuid dbh);
use FS::CurrentUser;
use FS::Record qw(qsearch);
die "Not running uid freeside!" unless checkeuid();
getopts("u:vf");
my $dir = shift or die &usage;
$FS::CurrentUser::upgrade_hack = 1;
adminsuidsetup $opt_u; #$user;
$|=1;
my $conf = new FS::Conf;
if (!scalar(qsearch('conf', {})) || $opt_f) {
foreach my $item ( $conf->config_items() ) {
insert_config_item($item,$dir);
}
# ugly pseudo false laziness with Conf.pm
foreach my $item ( map { my $basename = basename($_);
$basename =~ /^(.*)$/;
$basename = $1;
new FS::ConfItem {
'key' => $basename,
'type' => '',
}
} glob($dir. '/invoice_template_*'),
glob($dir. '/invoice_html_*'),
glob($dir. '/invoice_htmlnotes_*'),
glob($dir. '/invoice_latex_*'),
glob($dir. '/invoice_latexnotes_*')
) {
insert_config_item($item,$dir);
}
foreach my $item ( map { my $basename = basename($_);
$basename =~ /^(.*)$/;
$basename = $1;
new FS::ConfItem {
'key' => $basename,
'type' => 'binary',
}
} glob($dir. '/logo_*.png'),
glob($dir. '/logo_*.eps')
) {
insert_config_item($item,$dir);
}
}
warn "Freeside database initialized - committing transaction\n" if $opt_v;
dbh->commit or die dbh->errstr;
dbh->disconnect or die dbh->errstr;
warn "Configuration initialization committed successfully\n" if $opt_v;
sub insert_config_item {
local $/;
my ($item,$dir) = @_;
my $key = $item->key;
if (-e "$dir/$key") {
warn "Inserting $key\n" if $opt_v;
my $value = readline(new IO::File "$dir/$key");
if ($item->type eq 'binary'){
$conf->set_binary($key, $value);
}else{
$conf->set($key, $value);
}
}
}
sub usage {
die "Usage:\n freeside-init-config directory [ -v ] [ -f ]\n"
# [ -u user ] for devel/multi-db installs
}
1;
- Previous message: [freeside-commits]
freeside/FS/FS Conf.pm, 1.181, 1.182 UID.pm, 1.32,
1.33 conf.pm, NONE, 1.1 cust_bill.pm, 1.164,
1.165 cust_main.pm, 1.272, 1.273 svc_acct.pm, 1.218, 1.219
- Next message: [freeside-commits] freeside/FS/t conf.t,NONE,1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list