diff options
Diffstat (limited to 'FS/bin/freeside-init-config')
-rwxr-xr-x | FS/bin/freeside-init-config | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/FS/bin/freeside-init-config b/FS/bin/freeside-init-config new file mode 100755 index 000000000..fe4729c40 --- /dev/null +++ b/FS/bin/freeside-init-config @@ -0,0 +1,45 @@ +#!/usr/bin/perl -Tw + +use strict; +use vars qw($opt_u $opt_f $opt_v); +use Getopt::Std; +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(); + +getopts("u:vf"); +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; + +if (!scalar(qsearch('conf', {})) || $opt_f) { + 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; + +dbh->commit or die dbh->errstr; +dbh->disconnect or die dbh->errstr; + +warn "Configuration initialization committed successfully\n" if $opt_v; + +sub usage { + die "Usage:\n freeside-init-config [ -v ] [ -f ] directory\n" + # [ -u user ] for devel/multi-db installs +} + +1; |