[freeside-commits] freeside/FS/bin freeside-init-config, 1.2, 1.3 freeside-setup, 1.61, 1.62 freeside-upgrade, 1.9, 1.10
Jeff Finucane,420,,
jeff at wavetail.420.am
Thu Jul 12 06:36:29 PDT 2007
- Previous message: [freeside-commits] freeside/FS/FS Conf.pm, 1.198, 1.199 Conf_compat17.pm, NONE, 1.1 Misc.pm, 1.22, 1.23 Record.pm, 1.140, 1.141 UID.pm, 1.34, 1.35 cust_bill.pm, 1.172, 1.173 cust_main.pm, 1.291, 1.292 svc_acct.pm, 1.232, 1.233
- Next message: [freeside-commits] freeside/httemplate/misc download-batch.cgi, 1.24, 1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/bin
In directory wavetail:/tmp/cvs-serv14318/FS/bin
Modified Files:
freeside-init-config freeside-setup freeside-upgrade
Log Message:
refactor freeside-init-config to module code, compare results of old/new code, have freeside-upgrade complain and revert to old code/config on failure (#1477)
Index: freeside-setup
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-setup,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- freeside-setup 27 Feb 2007 21:24:45 -0000 1.61
+++ freeside-setup 12 Jul 2007 13:36:26 -0000 1.62
@@ -9,9 +9,10 @@
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();
@@ -117,11 +118,24 @@
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);
Index: freeside-upgrade
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-upgrade,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- freeside-upgrade 4 Apr 2007 20:04:12 -0000 1.9
+++ freeside-upgrade 12 Jul 2007 13:36:26 -0000 1.10
@@ -9,6 +9,8 @@
use FS::CurrentUser;
use FS::Schema qw( dbdef dbdef_dist reload_dbdef );
use FS::Misc::prune qw(prune_applications);
+use FS::Conf;
+use FS::Record qw(qsearch);
die "Not running uid freeside!" unless checkeuid();
@@ -56,11 +58,24 @@
$dbh->disconnect or die $dbh->errstr;
+delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
+$FS::UID::AutoCommit = 1;
+$FS::UID::callback_hack = 1;
+$dbh = adminsuidsetup($user);
+$FS::UID::callback_hack = 0;
unless ( $DRY_RUN ) {
- my $init_config = "freeside-init-config -u $user ";
- $init_config .= "%%%FREESIDE_CONF%%%/conf.". datasrc;
- system "$init_config" ;
+ my $dir = "%%%FREESIDE_CONF%%%/conf.". datasrc;
+ if (!scalar(qsearch('conf', {}))) {
+ my $error = FS::Conf::init_config($dir);
+ if ($error) {
+ warn "CONFIGURATION UPGRADE FAILED\n";
+ $dbh->rollback or die $dbh->errstr;
+ die $error;
+ }
+ }
}
+$dbh->commit or die $dbh->errstr;
+$dbh->disconnect or die $dbh->errstr;
###
Index: freeside-init-config
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/bin/freeside-init-config,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- freeside-init-config 5 Apr 2007 00:01:46 -0000 1.2
+++ freeside-init-config 12 Jul 2007 13:36:26 -0000 1.3
@@ -3,10 +3,10 @@
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);
+use FS::Conf;
die "Not running uid freeside!" unless checkeuid();
@@ -15,51 +15,19 @@
my $dir = shift or die &usage;
$FS::CurrentUser::upgrade_hack = 1;
+$FS::UID::AutoCommit = 0;
+$FS::UID::callback_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);
-
+ my $error = FS::Conf::init_config($dir);
+ if ($error) {
+ warn "CONFIGURATION INITIALIZATION FAILED\n";
+ dbh->rollback or die dbh->errstr;
+ die $error if $error;
}
-
}
warn "Freeside database initialized - committing transaction\n" if $opt_v;
@@ -69,21 +37,6 @@
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 [ -v ] [ -f ] directory\n"
# [ -u user ] for devel/multi-db installs
- Previous message: [freeside-commits] freeside/FS/FS Conf.pm, 1.198, 1.199 Conf_compat17.pm, NONE, 1.1 Misc.pm, 1.22, 1.23 Record.pm, 1.140, 1.141 UID.pm, 1.34, 1.35 cust_bill.pm, 1.172, 1.173 cust_main.pm, 1.291, 1.292 svc_acct.pm, 1.232, 1.233
- Next message: [freeside-commits] freeside/httemplate/misc download-batch.cgi, 1.24, 1.25
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list