5 eval "use Error qw/:try/;";
6 die "Please install Error.pm!\n" if ($@);
7 eval "use UNIVERSAL::require;";
8 die "Please install the UNIVERSAL::Require perl module!\n" if ($@);
9 eval "use Getopt::Long;";
10 die "Please install the Getopt::Long perl module!\n" if ($@);
11 eval "use Net::Domain;";
12 die "Please install the Net::Domain perl module!\n" if ($@);
18 my ($gather, $hostname, $core_config, $tmpdir) =
19 (0, Net::Domain::hostfqdn(), '/openils/conf/opensrf_core.xml', '/tmp/');
23 'hostname=s' => \$hostname,
24 'config_file=s' => \$core_config,
25 'tempdir=s' => \$tmpdir,
28 while (my $mod = <DATA>) {
30 warn "Please install $mod\n" unless ($mod->use);
31 $perloutput .= "Please install $mod\n";
32 print "$mod version ".${$mod."::VERSION"}."\n" unless ($@);
35 use OpenSRF::Transport::SlimJabber::Client;
36 use OpenSRF::Utils::SettingsParser;
37 use OpenSRF::Utils::SettingsClient;
38 use OpenSRF::Utils::Config;
42 (my $conf_dir = $core_config) =~ s#(.*)/.*#$1#;
45 OpenSRF::Utils::Config->load(config_file => $core_config);
46 my $conf = OpenSRF::Utils::Config->current;
47 my $j_username = $conf->bootstrap->username;
48 my $j_password = $conf->bootstrap->passwd;
49 my $j_port = $conf->bootstrap->port;
50 my $j_domain = $conf->bootstrap->domains->[0];
51 my $settings_config = $conf->bootstrap->settings_config;
52 my $logfile = $conf->bootstrap->logfile;
53 (my $log_dir = $logfile) =~ s#(.*)/.*#$1#;
57 my $client = OpenSRF::Transport::SlimJabber::Client->new(
59 username => $j_username,
60 password => $j_password,
68 unless($client->initialize()) {
69 $je = "* Unable to connect to jabber server $j_domain\n";
70 warn "* Unable to connect to jabber server $j_domain\n";
73 $je = "* Error connecting to jabber:\n" . shift() . "\n";
74 warn "* Error connecting to jabber:\n" . shift() . "\n";
77 print "* Jabber successfully connected\n" unless ($je);
78 $output .= ($je) ? $je : "* Jabber successfully connected\n";
80 # parse the opensrf.xml file
81 my $sparser = 'OpenSRF::Utils::SettingsParser';
82 my $res = $sparser->initialize($settings_config);
83 my $sconfig = $sparser->get_server_config($hostname);
84 my $db_config = $sconfig->{apps}->{'open-ils.storage'}->{app_settings}->{databases}->{database};
86 # grab the open-ils.storage database settings
87 my $db_host = $db_config->{host};
88 my $db_user = $db_config->{user};
89 my $db_port = $db_config->{port};
90 my $db_pw = $db_config->{pw};
91 my $db_db = $db_config->{db};
94 # connect to the database
95 my $dsn = "dbi:Pg:dbname=$db_db;host=$db_host;port=$db_port";
98 unless( DBI->connect($dsn, $db_user, $db_pw) ) {
99 $de = "* Unable to connect to database $dsn, user=$db_user, password=$db_pw\n";
100 warn "* Unable to connect to database $dsn, user=$db_user, password=$db_pw\n";
103 $de = "* Unable to connect to database $dsn, user=$db_user, password=$db_pw\n" . shift() . "\n";
104 warn "* Unable to connect to database $dsn, user=$db_user, password=$db_pw\n" . shift() . "\n";
106 print "* Successfully connected to database $dsn\n" unless ($de);
107 $output .= ($de) ? $de : "* Successfully connected to database $dsn\n";
109 $output .= check_libdbd();
112 get_debug_info( $tmpdir, $log_dir, $conf_dir, $perloutput, $output );
118 my @location = `locate libdbdpgsql.so`;
121 my $res = "Found more than one location for libdbdpgsql.so.
122 We have found that system packages don't link against libdbi.so;
123 therefore, we strongly recommend compiling libdbi and libdbi-drivers from source.\n";
127 foreach my $loc (@location) {
128 my @linkage = `ldd $loc`;
129 if (!grep(/libdbi/, @linkage)) {
130 my $res = "libdbi.so was not linked against $loc - you probably need to compile from source.\n";
139 my $temp_dir = shift; # place we can write files
140 my $log = shift; # location of the log directory
141 my $config = shift; # location of the config files
142 my $perl_test = shift; # output from the Perl prereq testing
143 my $config_test = shift; # output from the config file testing
145 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
146 my $oils_time = sprintf("%04d-%02d-%02d_%02dh-%02d-%02d", $year+1900, $mon, $mday, $hour, $min, $sec);
148 # evil approach that requires no other Perl dependencies
150 my $oils_debug_dir = "$temp_dir/oils_$oils_time";
152 # Replace with something Perlish
153 mkdir($oils_debug_dir) or die $!;
155 # Replace with File::Copy
156 system("cp $log/*log $oils_debug_dir");
158 # Passwords will go through in the clear for now
159 system("cp $config/*xml $oils_debug_dir");
162 open(FH, ">", "$oils_debug_dir/perl_test.out") or die $!;
167 open(FH, ">", "$oils_debug_dir/xml_test.out") or die $!;
168 print FH $config_test;
171 # Tar this up - does any system not have tar?
172 system("tar czf oils_$oils_time.tar.gz oils_$oils_time");
174 # Clean up after ourselves, somewhat dangerously
175 system("rm -fr $oils_debug_dir");
177 print "Wrote your debug information to oils_$oils_time.tar.gz.\n";
187 Class::DBI::AbstractSearch
198 DateTime::Format::ISO8601
201 JavaScript::SpiderMonkey