diff options
author | jeff <jeff> | 2007-07-12 13:36:27 +0000 |
---|---|---|
committer | jeff <jeff> | 2007-07-12 13:36:27 +0000 |
commit | cd907554f4c08175c379e204e28e26483acf957a (patch) | |
tree | f07a03443fcb8e1673ba24af0ef729e440f3ed4c /FS/bin/freeside-setup | |
parent | 161172b3162b1495e3d8d0f7425a8b699ffab9fe (diff) |
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)
Diffstat (limited to 'FS/bin/freeside-setup')
-rwxr-xr-x | FS/bin/freeside-setup | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup index ed737b395..188a1867a 100755 --- a/FS/bin/freeside-setup +++ b/FS/bin/freeside-setup @@ -9,9 +9,10 @@ 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(); @@ -117,11 +118,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); |