#!/usr/bin/perl # use strict; use Getopt::Long; sub usage { die "Usage: checkconfig-local.pl checkconfig-local.pl --needed-debs "; } my $debs_only = 0; usage() unless GetOptions( 'needed-debs' => \$debs_only, ); my @errors; my $err = sub { return unless @_; print STDERR "Problem:\n" . join('', map { " * $_\n" } @_) . "\n"; exit 1; }; ############################################################################ print "[Checking site-local config....]\n" unless $debs_only; ############################################################################ my %modules = ( "Algorithm::NGram" => { 'opt' => "Required for one-click posting." }, "Crypt::SSLeay" => {'deb' => "libcrypt-ssleay-perl", }, "Data::Queue::Persistent" => { 'opt' => "Required for QoTD functionality." }, "Data::UUID" => { 'deb' => 'libdata-uuid-perl' }, "Geo::IP::PurePerl" => { 'opt' => "Provides IP to country mapping for stopping some CC fraud.", }, "GnuPG::Interface" => { 'deb' => 'libgnupg-interface-perl', 'opt' => 'Crypto and signed message authentication.' }, "Text::Diff" => { 'deb' => 'libtext-diff-perl' }, "Text::Autoformat" => { 'deb' => 'libtext-autoformat-perl', 'opt' => "Used by WWW::Wikipedia" }, "Tie::IxHash" => { 'deb' => "libtie-ixhash-perl" }, "version" => { 'deb' => "libversion-perl", }, "WWW::Wikipedia" => { 'opt' => "Used for 'lazysms' feature" }, "Module::Pluggable" => { deb => 'libmodule-pluggable-perl', opt => "Required for SixApart::Search", }, ); my @debs; foreach my $mod (sort keys %modules) { my $rv = eval "use $mod;"; if ($@) { my $dt = $modules{$mod}; unless ($debs_only) { if ($dt->{'opt'}) { print STDERR "Missing optional module $mod: $dt->{'opt'}\n"; } else { push @errors, "Missing perl module: $mod"; } } push @debs, $dt->{'deb'} if $dt->{'deb'}; next; } my $ver_want = $modules{$mod}{ver}; my $ver_got = $mod->VERSION; if ($ver_want && $ver_got && $ver_got < $ver_want) { push @errors, "Out of date module: $mod (need $ver_want, $ver_got installed)"; } } unless (-e "/usr/share/doc/aspell-en" || -e "/usr/local/share/aspell") { push @errors, "Spell check dictionary not installed?" unless $debs_only; push @debs, "aspell-en"; push @debs, "aspell"; } unless (-d "$ENV{'LJHOME'}/temp") { push @errors, "\$LJHOME/temp dir doesn't exist"; } unless (-d "$ENV{'LJHOME'}/var") { push @errors, "\$LJHOME/var dir doesn't exist"; } if (@debs && -e '/etc/debian_version') { if ($debs_only) { print STDERR join(' ', @debs); } else { print STDERR "\n# apt-get install ", join(' ', @debs), "\n\n"; } } $err->(@errors); 1;