#!/usr/bin/perl -w # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. # This file has detailed POD docs, do "perldoc checksetup.pl" to see them. ###################################################################### # Initialization ###################################################################### use strict; use 5.10.1; use File::Basename; use Getopt::Long qw(:config bundling); use Pod::Usage; use Safe; BEGIN { chdir dirname($0); } use lib qw(. lib); use Bugzilla::Constants; use Bugzilla::Install::Requirements; use Bugzilla::Install::Util qw(install_string get_version_and_os init_console success); ###################################################################### # Live Code ###################################################################### # Do not run checksetup.pl from the web browser. Bugzilla::Install::Util::no_checksetup_from_cgi() if $ENV{'SERVER_SOFTWARE'}; # When we're running at the command line, we need to pick the right # language before ever displaying any string. init_console(); my %switch; GetOptions(\%switch, 'help|h|?', 'check-modules', 'no-templates|t', 'verbose|v|no-silent', 'make-admin=s', 'reset-password=s', 'version|V'); # Print the help message if that switch was selected. pod2usage({-verbose => 1, -exitval => 1}) if $switch{'help'}; # Read in the "answers" file if it exists, for running in # non-interactive mode. my $answers_file = $ARGV[0]; my $silent = $answers_file && !$switch{'verbose'}; print(install_string('header', get_version_and_os()) . "\n") unless $silent; exit 0 if $switch{'version'}; # Check required --MODULES-- my $module_results = check_requirements(!$silent); Bugzilla::Install::Requirements::print_module_instructions( $module_results, !$silent); exit 1 if !$module_results->{pass}; # Break out if checking the modules is all we have been asked to do. exit 0 if $switch{'check-modules'}; ########################################################################### # Load Bugzilla Modules ########################################################################### # It's never safe to "use" a Bugzilla module in checksetup. If a module # prerequisite is missing, and you "use" a module that requires it, # then instead of our nice normal checksetup message, the user would # get a cryptic perl error about the missing module. require Bugzilla; require Bugzilla::User; require Bugzilla::Util; import Bugzilla::Util qw(get_text); require Bugzilla::Config; import Bugzilla::Config qw(:admin); require Bugzilla::Install::Localconfig; import Bugzilla::Install::Localconfig qw(update_localconfig); require Bugzilla::Install::Filesystem; import Bugzilla::Install::Filesystem qw(update_filesystem create_htaccess fix_all_file_permissions); require Bugzilla::Install::DB; require Bugzilla::DB; require Bugzilla::Template; require Bugzilla::Field; require Bugzilla::Install; Bugzilla->installation_mode(INSTALLATION_MODE_NON_INTERACTIVE) if $answers_file; Bugzilla->installation_answers($answers_file); ########################################################################### # Check and update --LOCAL-- configuration ########################################################################### print "Reading " . bz_locations()->{'localconfig'} . "...\n" unless $silent; update_localconfig({ output => !$silent }); my $lc_hash = Bugzilla->localconfig; ########################################################################### # Check --DATABASE-- setup ########################################################################### # At this point, localconfig is defined and is readable. So we know # everything we need to create the DB. We have to create it early, # because some data required to populate data/params is stored in the DB. Bugzilla::DB::bz_check_requirements(!$silent); Bugzilla::DB::bz_create_database() if $lc_hash->{'db_check'}; # now get a handle to the database: my $dbh = Bugzilla->dbh; # Create the tables, and do any database-specific schema changes. $dbh->bz_setup_database(); # Populate the tables that hold the values for the