Apache-Voodoo

 view release on metacpan or  search on metacpan

bin/voodoo-control  view on Meta::CPAN

	'ignore!',
	'verbose|v:i',
	'dbhost|h:s',
	'dbname|n:s',
	'dbuser|u:s',
	'dbpass|p:s',
	'dbroot|r:s',
);

my %COMMANDS = (
	'install'    => \&install,
	'update'     => \&update,
	'showconfig' => \&showconfig,
	'setconfig'  => \&setconfig,
	'newapp'     => \&newapp,
	'newmodule'  => \&newmodule,
	'probetable' => \&probetable,
	'markupdatesapplied' => \&markupdatesapplied,
);

my $command = shift @ARGV;

if (defined($COMMANDS{$command})) {
	$COMMANDS{$command}->(%options);
}
else {
	show_usage();
}

sub install {
	my %options = @_;

	my $target = shift @ARGV;

	# use these on demand.  This has two benefits.
	# a) We don't spend time using in stuff we don't need.
	# b) This program will still run even if these fail to load because of bad configuration.
	# c) This allows this program to be used to fix the broken configuration.
	load_mod("Apache::Voodoo::Install::Distribution");
	load_mod("Apache::Voodoo::Install::Updater");

	################################################################################
	# make sure this file exists and that the name follows the correct format
	################################################################################
	my $distro = Apache::Voodoo::Install::Distribution->new('distribution' => $target, %options);

	$distro->do_install();

	my $app_name = $distro->app_name();

	my $updater = Apache::Voodoo::Install::Updater->new('app_name' => $app_name, %options);

	if ($distro->existing()) {
		$updater->do_update();
	}
	else {
		$updater->do_new_install();
	}
}

sub update {
	my %options = @_;

	my $app_name = shift @ARGV;
	assert_app_name($app_name);

	load_mod("Apache::Voodoo::Install::Updater");

	my $updater = Apache::Voodoo::Install::Updater->new('app_name' => $app_name, %options);

	$updater->do_update();
	do_post(app_name => $app_name, %options);
}

sub markupdatesapplied {
	my %options = @_;

	my $app_name = shift @ARGV;
	assert_app_name($app_name);

	load_mod("Apache::Voodoo::Install::Updater");

	my $updater = Apache::Voodoo::Install::Updater->new('app_name' => $app_name, %options);

	$updater->mark_updates_applied();
}

sub showconfig {
	load_mod("Apache::Voodoo::Constants");

	my $cnf = Apache::Voodoo::Constants->new();

	print " Apache Prefix Path: ", $cnf->prefix(),"\n";
	print "   App Install Path: ", $cnf->install_path(),"\n";
	print "       Session Path: ", $cnf->session_path(),"\n";
	print "   Config File Path: ", $cnf->conf_path(),"\n";
	print "   Config File Name: ", $cnf->conf_file(),"\n";
	print "   Update File Path: ", $cnf->updates_path(),"\n";
	print " Template File Path: ", $cnf->tmpl_path(),"\n";
	print "   Perl Module Path: ", $cnf->code_path(),"\n";
	print "         Apache UID: ", $cnf->apache_uid(),"\n";
	print "         Apache GID: ", $cnf->apache_gid(),"\n";
	print "Debug DB Connection: ", $cnf->debug_dbd()->[0],"\n";
	print "  Debug DB Username: ", $cnf->debug_dbd()->[1],"\n";
	print "  Debug DB Password: ", $cnf->debug_dbd()->[2],"\n";
	print "     Debug URL Path: ", $cnf->debug_path(),"\n";
	print "\n";
	print "Config settings stored in: ", $INC{'Apache/Voodoo/MyConfig.pm'},"\n";
	exit 0;	
}

sub setconfig {
	my %options = @_;

	my $cnf = {};

	eval "use Apache::Voodoo::MyConfig;";
	unless ($@) {
		# There is one, so we'll use the settings in it as the default
		if (ref($Apache::Voodoo::MyConfig::Config) eq "HASH") {
			$cnf = $Apache::Voodoo::MyConfig::Config;



( run in 0.683 second using v1.01-cache-2.11-cpan-437f7b0c052 )