Want more features on Pastebin? Sign Up, it's FREE!
Guest

Zamfoo update script

By: a guest on Jun 16th, 2013  |  syntax: Perl  |  size: 4.14 KB  |  views: 2,227  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2. #use strict; #kevin
  3. use MIME::Base64;
  4. use Socket;
  5. use Digest::MD5 qw(md5 md5_hex md5_base64);
  6. use LWP::UserAgent;
  7. use CGI;
  8. use URI::Escape;
  9. my $q = new CGI;
  10. print $q->header();
  11.  
  12. print "starting script \n";
  13.  
  14. $command = "clear";
  15. system($command);
  16.  
  17. $command = "rm -rf /usr/local/cpanel/whostmgr/docroot/cgi/addon_zamfoo*";
  18. system($command);
  19. $command = "rm -rf /usr/local/cpanel/whostmgr/docroot/cgi/zamfoo";
  20. system($command);
  21. $command = "rm -rf /scripts/postwwwacct";
  22. system($command);
  23. $command = "rm -rf /scripts/prekillacct";
  24. system($command);
  25. $command = "rm -rf /root/cpanel3-skel/migration";
  26. system($command);
  27. $command = "rm -rf /root/cpanel3-skel/.zamfoo";
  28. system($command);
  29.  
  30.  
  31. $command = "rm -rf /zamfoo_reseller";
  32. system($command);
  33.  
  34. print "\n\nDisregard Uninstall Errors\n";
  35. print "Uninstallation Complete\n\n";
  36.  
  37.  
  38. system ("clear");
  39. system("rm -rf /zamfoo_reseller");
  40. system("mkdir /zamfoo_reseller");
  41. system("cd /zamfoo_reseller");
  42. $command = "mkdir /usr/local/cpanel/whostmgr/docroot/cgi/zamfoo";
  43. system ($command);
  44.  
  45. system ("clear");
  46.  
  47.  
  48.  
  49.  
  50.         $command = "perl -v | grep -i 'This is perl'";
  51.         $perlversion = `$command`;
  52.         @perlsplitter = split(" ", $perlversion);
  53.  
  54.         print "perl version: " . $perlsplitter[3] . "\n";
  55.  
  56.         $perlversion = substr($perlsplitter[3],1);
  57.         @perlversionarray = split("\\.", $perlversion);
  58.         print "Perl Full Version: " . $perlversion . "\n";
  59.         print "Perl Major Version: " . $perlversionarray[0] . "\n";
  60.         print "Perl Minor Version: " . $perlversionarray[1] . "\n";
  61.         print "Perl Sub Version: " . $perlversionarray[2] . "\n";
  62.  
  63.         print "Architecture version: " . $perlsplitter[@perlsplitter-1] . "\n";
  64.  
  65.  
  66.  
  67.  
  68. $command = "rm -rf /archtype.cgi";
  69. system ($command);
  70.  
  71. $command = "rm -rf /cp-archtype.cgi";
  72. system ($command);
  73.  
  74.  
  75. $command = "echo \"#!/usr/bin/perl\nprint 'test file';\" >> /archtype.cgi";
  76. system($command);
  77.  
  78. $command = "cd /; perlcc -B -o cp-archtype.cgi archtype.cgi";
  79. $result = system($command);
  80.  
  81. print "compile result: " . $result . "\n";
  82.  
  83.  
  84. $command  = "grep -c i686 /cp-archtype.cgi";
  85. $result = system($command);
  86. if ($result eq "0") {
  87.         $archtype = "i686-linux";
  88. }
  89.  
  90.  
  91. $command  = "grep -c x86_64-linux /cp-archtype.cgi";
  92. $result = system($command);
  93. if ($result eq "0") {
  94.         $archtype = "x86_64-linux";
  95. }
  96.  
  97.  
  98. $command  = "grep -c x86_64-linux-thread-multi /cp-archtype.cgi";
  99. $result = system($command);
  100. if ($result == "0") {
  101.         $archtype = "x86_64-linux-thread-multi";
  102. }
  103.  
  104. $command  = "grep -c i386-linux-thread-multi /cp-archtype.cgi";
  105. $result = system($command);
  106. if ($result == "0") {
  107.         $archtype = "i386-linux-thread-multi";
  108. }
  109.  
  110.  
  111. print "archtype: " . $archtype . "\n";
  112.  
  113.  
  114. $command = "rm -rf /archtype.cgi";
  115. system ($command);
  116.  
  117. $command = "rm -rf /cp-archtype.cgi";
  118. system ($command);
  119.  
  120.  
  121. $command = "rm -rf /zamfoo*";
  122. system($command);
  123.  
  124.  
  125.  
  126.  
  127. $filelocation = "wget \"http://www.zamfoo.com/downloads/perl" . $perlversionarray[0] . "." . $perlversionarray[1] . "/zamfoo/" . $archtype . "/zamfoo_reseller.tar\"";
  128. system($filelocation);                                
  129. print "Obtaining files: $filelocation";
  130. system("mkdir /zamfoo_reseller; mv zamfoo_reseller.tar /zamfoo_reseller/zamfoo_reseller.tar");
  131. print "\nDownloading: Done \n";
  132. system("tar -C /zamfoo_reseller -xvf /zamfoo_reseller/zamfoo_reseller.tar");
  133. print "\nUnpacking: Done \n";
  134. system("chmod 755 /zamfoo_reseller/zamfoo_reseller_update.cgi");
  135. $command = "cp /zamfoo_reseller/zamfoo_reseller_license_key.php /usr/local/cpanel/whostmgr/docroot/cgi/zamfoo/zamfoo_reseller_license_key.php";
  136. system ($command);
  137. $error = system("./zamfoo_reseller/zamfoo_reseller_update.cgi");
  138.  
  139. if ($error eq "2304") {
  140.                 system("cd /usr/bin;mv perl perl-backup;ln -s /usr/local/bin/perl perl;");
  141.                 $error = system("./zamfoo_reseller/zamfoo_reseller_update.cgi");
  142. }
  143.  
  144. if ($error ne "2304" && $error ne "65280" && $error ne "-1") {
  145.                         print "Server Architecture: " . $perlsplitter[@perlsplitter-1] . "\n";
  146.                         system("nano /usr/local/cpanel/whostmgr/docroot/cgi/zamfoo/zamfoo_reseller_license_key.php");
  147.                         exit;
  148. }
  149. else{
  150.         $command = "rm -rf /zamfoo*";
  151.         system($command);
  152.         print "System Error: -" . $error . "-\n\n\n\n";
  153. }
clone this paste RAW Paste Data