#!/usr/bin/perl -w # -*- Mode: perl; indent-tabs-mode: nil -*- # # The contents of this file are subject to the Mozilla Public # License Version 1.1 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at http://www.mozilla.org/MPL/ # # Software distributed under the License is distributed on an "AS # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or # implied. See the License for the specific language governing # rights and limitations under the License. # # The Original Code is mozilla.org code. # # The Initial Developer of the Original Code is Holger # Schurig. Portions created by Holger Schurig are # Copyright (C) 1999 Holger Schurig. All # Rights Reserved. # # Contributor(s): Holger Schurig # Terry Weissman # Dan Mosedale # Dave Miller # Zach Lipton # Jacob Steenhagen # Bradley Baetz # Tobias Burnus # Shane H. W. Travis # Gervase Markham # Erik Stambaugh # Dave Lawrence # Max Kanat-Alexander # Joel Peshkin # Lance Larsh # A. Karl Kornel # Marc Schumann # This file has detailed POD docs, do "perldoc checksetup.pl" to see them. ###################################################################### # Initialization ###################################################################### use strict; use 5.008001; 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); ###################################################################### # Live Code ###################################################################### # 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 if $switch{'version'}; # Check required --MODULES-- my $module_results = check_requirements(!$silent); Bugzilla::Install::Requirements::print_module_instructions( $module_results, !$silent); exit if !$module_results->{pass}; # Break out if checking the modules is all we have been asked to do. exit 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::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