home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / FAQ / cgi-bin / discus4_00 / upgrade.pl < prev   
Perl Script  |  2009-11-06  |  10KB  |  248 lines

  1. #!/usr/bin/perl
  2.  
  3. my $discus_version = "4.00";
  4. my $pro_version = -e "./source/fcn-prfl.pl";
  5.  
  6. # UPGRADE SCRIPT FOR DISCUS ON UNIX or WINDOWS PLATFORMS
  7. # Copyright (c) 1998-2002, DiscusWare, LLC, all rights reserved.
  8. # This script may not be redistributed or used except as provided
  9. # in the Discus license agreement.
  10.  
  11. my $platform = "";
  12. my $unix = 0; my $windows = 0;        # Comment this line to disable auto-detect
  13. #my $unix = 1; my $windows = 0;        # Uncomment this line if you have unix
  14. #my $windows = 1; my $unix = 0;        # Uncomment this line if you have Windows
  15.  
  16. if ($unix == 0 && $windows == 0) {
  17.     if ($^O eq "MSWin32") {
  18.         $windows = 1;
  19.         $platform = "WINDOWS";
  20.     } elsif (-e "/etc/passwd") {
  21.         $unix = 1;
  22.         $platform = "UNIX";
  23.     } else {
  24.         $unix = 1;
  25.         $platform = "UNKNOWN PLATFORM";
  26.     }
  27. }
  28. my $q = quotemeta(sprintf("%02d.%02d", $discus_version));
  29.  
  30. # ---------------------------------------------------------------------------------
  31.  
  32. require "./instsubs.pl";
  33.  
  34. # ---------------------------------------------------------------------------------
  35.  
  36. my $DC = {};
  37. if (-e "./discus.conf" && -e "install.txt") {
  38.     my $dc = read_discus_conf();    
  39.     print "\n\n";
  40.     print "-" x 60, "\n";
  41.     print "DISCUS UPGRADE -- DISCUS.CONF FILE DETECTED\n\n";
  42.     print "Setup has detected that you have already created a discus.conf file\n";
  43.     print "within this directory.  This appears to be associated with a Discus\n";
  44.     print "board that can be found at:\n\n";
  45.     print "   $dc->{html_url}\n\n";
  46.     print "Do you want to use this discus.conf file to upgrade?\n\n";    
  47.     print "Your answer (y/n):  ";
  48.     my $yn1 = <STDIN>;
  49.     $DC = $dc if $yn1 =~ /^y/i;
  50. }
  51. if (! $DC->{html_url}) {
  52.     print "\n" x 25;
  53.     print "-" x 60, "\n";
  54.     print "DISCUS UPGRADE -- SUPPLY DISCUS.CONF FILE\n\n";
  55.     print "You can upgrade by supplying the information from the discus.conf\n";
  56.     print "file of the board you are upgrading.  How would you like to supply\n";
  57.     print "this information?\n\n";
  58.     print "1) Typing in the full directory path to the current location of the\n";
  59.     print "   discus.conf file.\n\n";
  60.     print "2) Pasting in the discus.conf file directly into this telnet or\n";
  61.     print "   console session.\n\n";
  62.     print "3) Copying the discus.conf file manually to this directory, and then\n";
  63.     print "   trying this script again.\n\n";
  64.     my $dc = {};
  65.     if (-e "./discus.conf") {
  66.         $dc = read_discus_conf();
  67.         print "4)  Using the discus.conf file that is already within this directory.\n";
  68.         print "    This file appears to correspond to a Discus board found at:\n";
  69.         print "        $dc->{html_url}\n\n";
  70.     }
  71.     my $max = $dc->{html_url} eq "" ? 3 : 4;
  72.     print "Your choice (1-$max):  ";
  73.     my $chc = <STDIN>; chomp $chc;
  74.     exit(0) if $chc < 1 || $chc > $max;    
  75.     print "\n";
  76.     if ($chc == 1) {
  77.         print "Please type the full path where your discus.conf file for your\n";
  78.         print "existing Discus board can be found:\n\n";
  79.         my $path = "";
  80.         until (-f $path) {
  81.             print "\nWARNING: That is an invalid path.  Please try again...\n\n" if $path ne "";
  82.             print "> ";
  83.             my $path_in = <STDIN>;
  84.             $path_in =~ s/\s+$//;
  85.             $path_in =~ s/discus\.conf$//;
  86.             $path_in =~ s/\/$//;
  87.             $path = join('/', $path_in, 'discus.conf');
  88.         }
  89.         $DC = read_discus_conf($path);
  90.     } elsif ($chc == 3) {
  91.         print "Please copy the discus.conf file for the board you wish to upgrade\n";
  92.         print "into this directory.  Then, run this script again, and choose option\n";
  93.         print "4 (use the discus.conf file already in this directory).\n\n";
  94.         exit(0);        
  95.     } elsif ($chc == 2) {
  96.         print "Please copy the contents of your discus.conf file to your clipboard\n";
  97.         print "and then use the paste function of your telnet client or console window\n";
  98.         print "to paste this information here.\n\n";
  99.         print "IMPORTANT:  When you are finished pasting information, hit the ENTER\n";
  100.         print "key (probably twice) until you are given further instructions.\n\n";
  101.         print "Paste your discus.conf data now:\n";
  102.         my $d = {};
  103.         while (<STDIN>) {
  104.             next if ! /\S/ && ! keys %{$d};
  105.             last if ! /\S/;
  106.             if (/^(\w+)=(.*?)\s*$/) {
  107.                 $d->{$1} = $2;
  108.             }
  109.         }
  110.         $DC = $d;        
  111.     } elsif ($chc == 4) {
  112.         $DC = $dc;
  113.     }
  114. }
  115.  
  116. # ---------------------------------------------------------------------------------
  117.  
  118. my $pro_license = $DC->{pro_license};
  119. if ($pro_version == 1 && $pro_license !~ /^(\d)(\d)(\d)(\d)\-(\d)(\d)(\d)(\d)\-(\d)(\d)(\d)(\d)$/) {
  120.     print "\n" x 25;
  121.     print "-" x 60, "\n";
  122.     print "DISCUS PRO LICENSE NUMBER\n\n";
  123.     print "You have chosen to install Discus Pro.  Please enter your Discus\n";
  124.     print "Pro license number here:\n\n";
  125.     until ($pro_license =~ /^(\d)(\d)(\d)(\d)\-(\d)(\d)(\d)(\d)\-(\d)(\d)(\d)(\d)$/ && ($1 + $5) % 10 == $9 && ($2 + $6) % 10 == $10 &&($3 + $7) % 10 == $11 &&($4 + $8) % 10 == $12) {
  126.         print "  Discus Pro License Number:  ";
  127.         $pro_license = <STDIN>;
  128.         $pro_license =~ s/[^\d\-]//g;
  129.         exit(0) if $pro_license eq "";
  130.     }
  131.     $DC->{pro} = 1;
  132.     $DC->{pro_license} = $pro_license;
  133. }
  134.  
  135. # ---------------------------------------------------------------------------------
  136.  
  137. if ($DC->{version} != $discus_version) {
  138.     print "\n" x 25;
  139.     print "-" x 60, "\n";
  140.     print "DISCUS VERSION\n\n";
  141.     print "Your discus.conf file indicates that the current version of your board\n";
  142.     print "(before you apply this upgrade) is: $DC->{version}\n\n";
  143.     print "Is this correct?  (y/N) ";
  144.     my $x = <STDIN>;
  145.     if ($x !~ /^[yY]/) {
  146.         while (1) {
  147.             print "\nEnter your current Discus version in the format #.## --> ";
  148.             my $cvn = <STDIN>; chomp $cvn;
  149.             if ($cvn !~ /^\d\.\d\d$/) {
  150.                 print "That's not in #.## format.  Please try again!\n";
  151.                 next;
  152.             }
  153.             print "Confirm that your current version is: $cvn  (y/N)  ";
  154.             my $yn2 = <STDIN>;
  155.             next if $yn2 !~ /^[yY]/;
  156.             $DC->{version} = $cvn;
  157.             last;
  158.         }
  159.     }
  160. }
  161.  
  162. # ---------------------------------------------------------------------------------
  163.  
  164. print "\n" x 25;
  165. print "-" x 60, "\n";
  166. print "DISCUS UPGRADE -- CONFIRM UPGRADE METHOD\n\n";
  167. print "By default, this upgrade will preserve all of your topics, moderators,\n";
  168. print "users, and messages.  However, it will overwrite any files you may have\n";
  169. print "customized (such as skins and templates).\n\n";
  170. print "Which kind of upgrade do you wish to run?\n\n";
  171. print "1) Full upgrade -- update all templates and skins (recommended)\n";
  172. print "2) Custom upgrade -- let me choose what to overwrite\n\n";
  173. print "Your choice (1-2):  ";
  174. my $chc2 = <STDIN>; chomp $chc2;
  175. exit(0) if $chc2 < 1 || $chc2 > 2;
  176.  
  177. my %d = undef;
  178. $d{'12'} = 0;
  179. if ($chc2 == 2) {
  180.     print "\n" x 25;
  181.     print "-" x 60, "\n";
  182.     print "DISCUS UPGRADE -- CUSTOM UPGRADE METHOD\n\n";
  183.     print "Please choose whether or not you wish to upgrade each of the following\n";
  184.     print "components of your discussion board.  Please note that failure to upgrade\n";
  185.     print "certain components may cause your discussion board to malfunction.\n\n";
  186.     print "(Just hit ENTER to keep the default)\n\n";
  187.     $d{'17'} = upgrade_or_not("Dynamic language files (language.conf, etc.)", "y");
  188.     $d{'18'} = upgrade_or_not("Attachment configuration (attachments.conf)", "y");
  189.     $d{'19'} = upgrade_or_not("Formatting configuration (webtags.conf)", "y");
  190.     $d{'25'} = upgrade_or_not("Character conversion (charconvert.conf)", "y");
  191.     $d{'26'} = upgrade_or_not("HTML conversion (htmlconvert.conf)", "y");
  192.     $d{'24'} = upgrade_or_not("Search engine \"stop words\" (stopwords.conf)", "y");
  193.     $d{'31'} = upgrade_or_not("Default skins", "y");
  194.     $d{'27'} = upgrade_or_not("Administration interface templates", "y");
  195.     $d{'28'} = upgrade_or_not("Mail message templates", "y");
  196.     if ($DC->{pro}) {
  197.         $d{'29'} = upgrade_or_not("Discus Pro templates", "y");
  198.     }
  199.     $d{'30'} = upgrade_or_not("User interface templates", "y");
  200.     $d{'1'} = upgrade_or_not("Static file: board.html", "n");
  201.     $d{'2'} = upgrade_or_not("Static file: board-instructions.html", "n");
  202.     $d{'4'} = upgrade_or_not("Static file: board-formatting.html", "n");
  203.     $d{'5'} = upgrade_or_not("Static file: board-troubleshooting.html", "n");
  204.     $d{'6'} = upgrade_or_not("Static file: board-about.html", "n");
  205.     $d{'7'} = upgrade_or_not("Static file: board-menu.html", "n");
  206.     $d{'9'} = upgrade_or_not("Static files: framesetters (index.html)", "n");
  207.     $d{'8'} = upgrade_or_not("Static files: administration instructions", "y");
  208.     $d{'10'} = upgrade_or_not("Static file: administration framesetter", "y");
  209.     $d{'11'} = upgrade_or_not("Static file: administration warning", "y");
  210.     $d{'13'} = upgrade_or_not("Board clip art", "n");
  211.     $d{'14'} = upgrade_or_not("Board icons", "n");
  212.     $d{'38'} = upgrade_or_not("Javascript source for formatting panel", "n");
  213. }
  214.  
  215. # ---------------------------------------------------------------------------------
  216.  
  217. print "\n" x 25;
  218. print "-" x 60, "\n";
  219. print "DISCUS UPGRADE -- CONFIRM UPGRADE\n\n";
  220. print "Are you sure you want to perform the upgrade of the board at:\n";
  221. print "   $DC->{html_url}\n\n";
  222. my $yn3 = "";
  223. while ($yn3 eq "") {
  224.     print "Your answer (y or n): ";
  225.     $yn3 = <STDIN>;
  226.     $yn3 =~ s/[^yn]//gi;
  227.     exit(0) if $yn3 =~ /^n/i;
  228. }
  229.  
  230. # ---------------------------------------------------------------------------------
  231.  
  232. print "\n" x 25;
  233. print "-" x 60, "\n";
  234. print "DISCUS UPGRADE -- NOW IN PROGRESS\n\n";
  235.  
  236. install_discus(1, \%d, $DC);
  237.  
  238. print "\n" x 25;
  239. print "-" x 60, "\n";
  240. print "DISCUS UPGRADE -- COMPLETE\n\n";
  241. print "Congratulations!  Your discussion board has been successfully\n";
  242. print "upgraded.  Next, log into the administration program as the board\n";
  243. print "administrator (username '$DC->{superuser}').  If additional upgrade\n";
  244. print "tasks are required, you will be informed.\n\n";
  245. print "Press any key to continue...\n";
  246. my $iii = <STDIN>;
  247. exit(0);
  248.