#!/usr/bin/perl

$version = "0.8b";
eval("use pdump::Sniff;");
$newver = eval("$pdump::Sniff::VERSION");
if ($version eq $newver) {
 $ps++;
}
die "Must have euid = 0 to install this stuff!\n" if $>;
if ($ps) {
 print "This will install pdump\n";
}
else {
 print "This will install pdump::Sniff and pdump.\n";
}
print "Do you want to continue? (y/n)\n";
chomp ($ans = <STDIN>);
unless ($ans =~ /^y/i) {
 die "Exiting...\n";
}
else {
 if (!$ps) {
  print "Decompressing and extracting pdump::Sniff...\n";
  system('tar -zxvf pdump-Sniff-0.8.tar.gz >> install.log');
  chdir('pdump-Sniff-0.8');
  print "Configuring pdump::Sniff...\n";
  system('perl Makefile.PL >> ../install.log');
  print "Making pdump::Sniff...\n";
  system('make >> ../install.log');
  print "Installing pdump::Sniff...\n";
  system('make install >> ../install.log');
  chdir('../');
 }
 print "Where would you like pdump to be installed [/usr/local/bin]: ";
 chomp($place = <STDIN>);
 if (!$place) {
  $place = "/usr/local/bin";
 }
 print "Installing pdump...\n";
 system('cp -f pdump.pl $place/pdump');
 system('ln -sf $place/pdump $place/pdump.pl');
# print "Installing pdump's plugings...\n";
# mkdir('/usr/local/pdump', 755) unless (-e '/usr/local/pdump');
# system('cp -r lib /usr/local/pdump/lib');
# system('cp -r docs /usr/local/pdump/docs');
 print "Installation complete.\n\n";
 print "Read the 'README' file in the current directory for the man page in text format.\n";
 print "The README.html in the docs directory is the same thing as the README, just in\n";
 print "HTML format.  You can find a detailed explanation including examples and\n";
 print "other various information on pdump in the README(.html).\n";
 print "\nRun `pdump` to run pdump in standard mode. I suggest you skim the options\n";
 print "in the README before you try anything or you will be stuck.\n";
 print "\nIf you don't run pdump with any options, it will, by default, run\n";
 print "just as if you were running tcpdump without any options.\n\n";
 print "pdump also requires you to be in the directory which includes the lib directory,\n";
 print "which is the directory you are in right now since the lib dir is a requireed dir.\n";
 print "Good luck,\nSamy Kamkar [CommPort5\@LucidX.com]\n";
 print "\nAlso, if you happen to be interested in chatting about pdump, have questions,\n";
 print "comments, want to develop pdump, etc. just check out pdump's official IRC channel,\n";
 print "#pdump on SUIDnet [irc.LucidX.com]!  Hope to see you there!\n";
}
