| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- #!/usr/bin/perl
- ################################################################################
- # $Id: check.pl 2823 2007-04-07 08:37:43Z warion $
- # $Date: 2007-04-07 03:37:43 -0500 (Sat, 07 Apr 2007) $
- # $Revision: 2823 $
- ################################################################################
- # #
- # LICENSE #
- # #
- # This program is free software; you can redistribute it and/or #
- # modify it under the terms of the GNU General Public License (GPL) #
- # as published by the Free Software Foundation; either version 2 #
- # of the License, or (at your option) any later version. #
- # #
- # This program is distributed in the hope that it will be useful, #
- # but WITHOUT ANY WARRANTY; without even the implied warranty of #
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
- # GNU General Public License for more details. #
- # #
- # To read the license please visit http://www.gnu.org/copyleft/gpl.html #
- # #
- # #
- ################################################################################
- # #
- # check.pl is a simple script to check Perl-Module-Requirements. #
- # #
- ################################################################################
- use strict;
- ################################################################################
- # Internal Vars
- my ($VERSION, $DIR, $PROG, $EXTENSION, $USAGE);
- #-------------------------------------------------------------------------------
- # Main
- #-------------------------------------------------------------------------------
- # init some vars
- $VERSION =
- do { my @r = (q$Revision: 2823 $ =~ /\d+/g); sprintf "%d"."%02d" x $#r, @r };
- ($DIR=$0) =~ s/([^\/\\]*)$//;
- ($PROG=$1) =~ s/\.([^\.]*)$//;
- $EXTENSION=$1;
- # check args
- my $argCount = scalar(@ARGV);
- if ($argCount != 1) {
- printUsage();
- exit;
- }
- # ops
- if ($argCount == 1) {
- SWITCH: {
- $_ = shift @ARGV;
- /all/ && do { # --- all ---
- checkAll();
- exit;
- };
- /fluxd/ && do { # --- fluxd ---
- checkFluxd();
- exit;
- };
- /nzbperl/ && do { # --- nzbperl ---
- checkNzbperl();
- exit;
- };
- /ttools/ && do { # --- ttools ---
- checkTtools();
- exit;
- };
- /.*(version|-v).*/ && do { # --- version ---
- printVersion();
- exit;
- };
- /.*(help|-h).*/ && do { # --- help ---
- printUsage();
- exit;
- };
- printUsage();
- exit;
- }
- }
- # exit
- exit;
- #===============================================================================
- # Subs
- #===============================================================================
- #------------------------------------------------------------------------------#
- # Sub: checkAll #
- # Arguments: Null #
- # Returns: info on system requirements #
- #------------------------------------------------------------------------------#
- sub checkAll {
- # print
- print "checking all requirements...\n";
- # 1. fluxd
- checkFluxd();
- # 2. nzbperl
- checkNzbperl();
- # 3. ttools
- checkTtools();
- # done
- print "done checking all requirements.\n";
- }
- #------------------------------------------------------------------------------#
- # Sub: checkFluxd #
- # Arguments: Null #
- # Returns: info on system requirements #
- #------------------------------------------------------------------------------#
- sub checkFluxd {
- # print
- print "checking fluxd requirements...\n";
- my $errors = 0;
- my $warnings = 0;
- my @errorMessages = ();
- my @warningMessages = ();
- # 1. CORE-Perl-modules
- print "1. CORE-Perl-modules\n";
- my @mods = (
- 'IO::Select',
- 'IO::Socket::UNIX',
- 'IO::Socket::INET',
- 'POSIX'
- );
- foreach my $mod (@mods) {
- if (eval "require $mod") {
- print " - OK : ".$mod."\n";
- next;
- } else {
- $errors++;
- push(@errorMessages, "Loading of CORE-Perl-module ".$mod." failed.\n");
- print " - FAILED : ".$mod."\n";
- }
- }
- # 2. FluxDB-Perl-modules
- print "2. Database-Perl-modules\n";
- if (eval "require DBI") {
- print " - OK : DBI\n";
- } else {
- $warnings++;
- push(@warningMessages, "Loading of FluxDB-Perl-module DBI failed. fluxd cannot work in DBI/DBD-mode but only in PHP-mode.\n");
- print " - FAILED : DBI\n";
- }
- my $dbdwarnings = 0;
- @mods = (
- 'DBD::mysql',
- 'DBD::SQLite',
- 'DBD::Pg'
- );
- foreach my $mod (@mods) {
- if (eval "require $mod") {
- print " - OK : ".$mod."\n";
- next;
- } else {
- $dbdwarnings++;
- print " - FAILED : ".$mod."\n";
- }
- }
- if ($dbdwarnings == 3) {
- $warnings++;
- push(@warningMessages, "No DBD-Module could be loaded. fluxd cannot work in DBI/DBD-mode but only in PHP-mode.\n");
- }
- # 3. Result
- print "3. Result : ".(($errors == 0) ? "PASSED" : "FAILED")."\n";
- # failures
- if ($errors > 0) {
- print "Errors:\n";
- foreach my $msg (@errorMessages) {
- print $msg;
- }
- }
- # warnings
- if ($warnings > 0) {
- print "Warnings:\n";
- foreach my $msg (@warningMessages) {
- print $msg;
- }
- }
- # done
- print "done checking fluxd requirements.\n";
- }
- #------------------------------------------------------------------------------#
- # Sub: checkNzbperl #
- # Arguments: Null #
- # Returns: info on system requirements #
- #------------------------------------------------------------------------------#
- sub checkNzbperl {
- # print
- print "checking nzbperl requirements...\n";
- my $errors = 0;
- my $warnings = 0;
- my @errorMessages = ();
- my @warningMessages = ();
- # 1. CORE-Perl-modules
- print "1. CORE-Perl-modules\n";
- my @mods = (
- 'IO::File',
- 'IO::Select',
- 'IO::Socket::INET',
- 'File::Basename',
- 'Getopt::Long',
- 'Time::HiRes',
- 'Cwd',
- 'XML::Simple',
- 'XML::DOM'
- );
- foreach my $mod (@mods) {
- if (eval "require $mod") {
- print " - OK : ".$mod."\n";
- next;
- } else {
- $errors++;
- push(@errorMessages, "Loading of CORE-Perl-module ".$mod." failed.\n");
- print " - FAILED : ".$mod."\n";
- }
- }
- # 2. Perl-Threads
- my $threadproblems = 0;
- print "2. Perl-Threads\n";
- eval "use threads;";
- if ($@) {
- $warnings++;
- print " - FAILED : threads\n";
- $threadproblems++;
- } else {
- print " - OK : threads\n";
- }
- @mods = ('Thread::Queue');
- foreach my $mod (@mods) {
- if (eval "require $mod") {
- print " - OK : ".$mod."\n";
- next;
- } else {
- $warnings++;
- $threadproblems++;
- print " - FAILED : ".$mod."\n";
- }
- }
- if ($threadproblems != 0) {
- $warnings++;
- push(@warningMessages, "Could not use Perl thread modules.\n");
- }
- # 3. Result
- print "3. Result : ".(($errors == 0) ? "PASSED" : "FAILED")."\n";
- # failures
- if ($errors > 0) {
- print "Errors:\n";
- foreach my $msg (@errorMessages) {
- print $msg;
- }
- }
- # warnings
- if ($warnings > 0) {
- print "Warnings:\n";
- foreach my $msg (@warningMessages) {
- print $msg;
- }
- }
- # done
- print "done checking nzbperl requirements.\n";
- }
- #------------------------------------------------------------------------------#
- # Sub: checkTtools #
- # Arguments: Null #
- # Returns: info on system requirements #
- #------------------------------------------------------------------------------#
- sub checkTtools {
- # print
- print "checking ttools requirements...\n";
- my $errors = 0;
- my $warnings = 0;
- my @errorMessages = ();
- my @warningMessages = ();
- # 1. CORE-Perl-modules
- print "1. CORE-Perl-modules\n";
- my @mods = ('Digest::SHA1', 'LWP::UserAgent');
- foreach my $mod (@mods) {
- if (eval "require $mod") {
- print " - OK : ".$mod."\n";
- next;
- } else {
- $errors++;
- push(@errorMessages, "Loading of CORE-Perl-module ".$mod." failed.\n");
- print " - FAILED : ".$mod."\n";
- }
- }
- # 2. Result
- print "2. Result : ".(($errors == 0) ? "PASSED" : "FAILED")."\n";
- # failures
- if ($errors > 0) {
- print "Errors:\n";
- foreach my $msg (@errorMessages) {
- print $msg;
- }
- }
- # warnings
- if ($warnings > 0) {
- print "Warnings:\n";
- foreach my $msg (@warningMessages) {
- print $msg;
- }
- }
- # done
- print "done checking ttools requirements.\n";
- }
- #------------------------------------------------------------------------------#
- # Sub: printVersion #
- # Arguments: Null #
- # Returns: Null #
- #------------------------------------------------------------------------------#
- sub printVersion {
- print $PROG.".".$EXTENSION." Version ".$VERSION."\n";
- }
- #------------------------------------------------------------------------------#
- # Sub: printUsage #
- # Parameters: null #
- # Return: null #
- #------------------------------------------------------------------------------#
- sub printUsage {
- print <<"USAGE";
- $PROG.$EXTENSION (Revision $VERSION)
- Usage: $PROG.$EXTENSION type
- type may be : all/fluxd/nzbperl/ttools
- Examples:
- $PROG.$EXTENSION fluxd
- $PROG.$EXTENSION all
- USAGE
- }
- # EOF
|