#!/usr/bin/perl

print "UID:$<\n";
if ( $< ) {
	print "Please run this script with root.\n";
	exit;
}

$distribution = `ls /etc -F | grep \"release\$\\|version\$\"`;

if ( $distribution =~ /redhat|fedora/m ) {
	print "Your distribution seems to be RedHat/Fedora.\n";
	$redhat = 1;
}
elsif ( $distribution =~ /debian/m ) {
	print "Your distribution seems to be Debian.\n";
	$debian = 1;
}

if ( $redhat ) {
	my $YUM  = 'perl-DBI perl-Date-Simple perl-DateTime perl-Config-Simple perl-Tie-IxHash perl-SVG perl-XML-Atom perl-List-Compare';
	my $CPAN = 'CGI::Carp CGI::Minimal MIME::Base64 Time::HiRes Data::Dumper Time::Simple Encode Text::Ngram File::Find Perl6::Slurp List::Util';
	print "Going to install ( yum )\n";
	print "$YUM\n";
	system( "yum install $YUM" );
	print "Going to install ( CPAN )\n";
	print "$CPAN\n";
	system( "cpan $CPAN" );
}

if ( $debian ) {
	my $APT  = 'libdbi-perl libdate-simple-perl libdatetime-perl libmime-base64-perl libconfig-simple-perl libtime-hires-perl libtie-ixhash-perl libsvg-perl libxml-atom-perl liblist-compare-perl libperl6-slurp-perl';
	my $CPAN = 'CGI::Carp CGI::Minimal Data::Dumper Time::Simple Encode Text::Ngram File::Find List::Util';
	print "Going to install ( aptitude )\n";
	print "$APT\n";
	system( "aptitude install $APT" );
	print "Going to install ( CPAN )\n";
	print "$CPAN\n";
	system( "cpan $CPAN" );
}

