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
Wrap
Perl Script
|
2009-11-06
|
10KB
|
248 lines
#!/usr/bin/perl
my $discus_version = "4.00";
my $pro_version = -e "./source/fcn-prfl.pl";
# UPGRADE SCRIPT FOR DISCUS ON UNIX or WINDOWS PLATFORMS
# Copyright (c) 1998-2002, DiscusWare, LLC, all rights reserved.
# This script may not be redistributed or used except as provided
# in the Discus license agreement.
my $platform = "";
my $unix = 0; my $windows = 0; # Comment this line to disable auto-detect
#my $unix = 1; my $windows = 0; # Uncomment this line if you have unix
#my $windows = 1; my $unix = 0; # Uncomment this line if you have Windows
if ($unix == 0 && $windows == 0) {
if ($^O eq "MSWin32") {
$windows = 1;
$platform = "WINDOWS";
} elsif (-e "/etc/passwd") {
$unix = 1;
$platform = "UNIX";
} else {
$unix = 1;
$platform = "UNKNOWN PLATFORM";
}
}
my $q = quotemeta(sprintf("%02d.%02d", $discus_version));
# ---------------------------------------------------------------------------------
require "./instsubs.pl";
# ---------------------------------------------------------------------------------
my $DC = {};
if (-e "./discus.conf" && -e "install.txt") {
my $dc = read_discus_conf();
print "\n\n";
print "-" x 60, "\n";
print "DISCUS UPGRADE -- DISCUS.CONF FILE DETECTED\n\n";
print "Setup has detected that you have already created a discus.conf file\n";
print "within this directory. This appears to be associated with a Discus\n";
print "board that can be found at:\n\n";
print " $dc->{html_url}\n\n";
print "Do you want to use this discus.conf file to upgrade?\n\n";
print "Your answer (y/n): ";
my $yn1 = <STDIN>;
$DC = $dc if $yn1 =~ /^y/i;
}
if (! $DC->{html_url}) {
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS UPGRADE -- SUPPLY DISCUS.CONF FILE\n\n";
print "You can upgrade by supplying the information from the discus.conf\n";
print "file of the board you are upgrading. How would you like to supply\n";
print "this information?\n\n";
print "1) Typing in the full directory path to the current location of the\n";
print " discus.conf file.\n\n";
print "2) Pasting in the discus.conf file directly into this telnet or\n";
print " console session.\n\n";
print "3) Copying the discus.conf file manually to this directory, and then\n";
print " trying this script again.\n\n";
my $dc = {};
if (-e "./discus.conf") {
$dc = read_discus_conf();
print "4) Using the discus.conf file that is already within this directory.\n";
print " This file appears to correspond to a Discus board found at:\n";
print " $dc->{html_url}\n\n";
}
my $max = $dc->{html_url} eq "" ? 3 : 4;
print "Your choice (1-$max): ";
my $chc = <STDIN>; chomp $chc;
exit(0) if $chc < 1 || $chc > $max;
print "\n";
if ($chc == 1) {
print "Please type the full path where your discus.conf file for your\n";
print "existing Discus board can be found:\n\n";
my $path = "";
until (-f $path) {
print "\nWARNING: That is an invalid path. Please try again...\n\n" if $path ne "";
print "> ";
my $path_in = <STDIN>;
$path_in =~ s/\s+$//;
$path_in =~ s/discus\.conf$//;
$path_in =~ s/\/$//;
$path = join('/', $path_in, 'discus.conf');
}
$DC = read_discus_conf($path);
} elsif ($chc == 3) {
print "Please copy the discus.conf file for the board you wish to upgrade\n";
print "into this directory. Then, run this script again, and choose option\n";
print "4 (use the discus.conf file already in this directory).\n\n";
exit(0);
} elsif ($chc == 2) {
print "Please copy the contents of your discus.conf file to your clipboard\n";
print "and then use the paste function of your telnet client or console window\n";
print "to paste this information here.\n\n";
print "IMPORTANT: When you are finished pasting information, hit the ENTER\n";
print "key (probably twice) until you are given further instructions.\n\n";
print "Paste your discus.conf data now:\n";
my $d = {};
while (<STDIN>) {
next if ! /\S/ && ! keys %{$d};
last if ! /\S/;
if (/^(\w+)=(.*?)\s*$/) {
$d->{$1} = $2;
}
}
$DC = $d;
} elsif ($chc == 4) {
$DC = $dc;
}
}
# ---------------------------------------------------------------------------------
my $pro_license = $DC->{pro_license};
if ($pro_version == 1 && $pro_license !~ /^(\d)(\d)(\d)(\d)\-(\d)(\d)(\d)(\d)\-(\d)(\d)(\d)(\d)$/) {
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS PRO LICENSE NUMBER\n\n";
print "You have chosen to install Discus Pro. Please enter your Discus\n";
print "Pro license number here:\n\n";
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) {
print " Discus Pro License Number: ";
$pro_license = <STDIN>;
$pro_license =~ s/[^\d\-]//g;
exit(0) if $pro_license eq "";
}
$DC->{pro} = 1;
$DC->{pro_license} = $pro_license;
}
# ---------------------------------------------------------------------------------
if ($DC->{version} != $discus_version) {
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS VERSION\n\n";
print "Your discus.conf file indicates that the current version of your board\n";
print "(before you apply this upgrade) is: $DC->{version}\n\n";
print "Is this correct? (y/N) ";
my $x = <STDIN>;
if ($x !~ /^[yY]/) {
while (1) {
print "\nEnter your current Discus version in the format #.## --> ";
my $cvn = <STDIN>; chomp $cvn;
if ($cvn !~ /^\d\.\d\d$/) {
print "That's not in #.## format. Please try again!\n";
next;
}
print "Confirm that your current version is: $cvn (y/N) ";
my $yn2 = <STDIN>;
next if $yn2 !~ /^[yY]/;
$DC->{version} = $cvn;
last;
}
}
}
# ---------------------------------------------------------------------------------
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS UPGRADE -- CONFIRM UPGRADE METHOD\n\n";
print "By default, this upgrade will preserve all of your topics, moderators,\n";
print "users, and messages. However, it will overwrite any files you may have\n";
print "customized (such as skins and templates).\n\n";
print "Which kind of upgrade do you wish to run?\n\n";
print "1) Full upgrade -- update all templates and skins (recommended)\n";
print "2) Custom upgrade -- let me choose what to overwrite\n\n";
print "Your choice (1-2): ";
my $chc2 = <STDIN>; chomp $chc2;
exit(0) if $chc2 < 1 || $chc2 > 2;
my %d = undef;
$d{'12'} = 0;
if ($chc2 == 2) {
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS UPGRADE -- CUSTOM UPGRADE METHOD\n\n";
print "Please choose whether or not you wish to upgrade each of the following\n";
print "components of your discussion board. Please note that failure to upgrade\n";
print "certain components may cause your discussion board to malfunction.\n\n";
print "(Just hit ENTER to keep the default)\n\n";
$d{'17'} = upgrade_or_not("Dynamic language files (language.conf, etc.)", "y");
$d{'18'} = upgrade_or_not("Attachment configuration (attachments.conf)", "y");
$d{'19'} = upgrade_or_not("Formatting configuration (webtags.conf)", "y");
$d{'25'} = upgrade_or_not("Character conversion (charconvert.conf)", "y");
$d{'26'} = upgrade_or_not("HTML conversion (htmlconvert.conf)", "y");
$d{'24'} = upgrade_or_not("Search engine \"stop words\" (stopwords.conf)", "y");
$d{'31'} = upgrade_or_not("Default skins", "y");
$d{'27'} = upgrade_or_not("Administration interface templates", "y");
$d{'28'} = upgrade_or_not("Mail message templates", "y");
if ($DC->{pro}) {
$d{'29'} = upgrade_or_not("Discus Pro templates", "y");
}
$d{'30'} = upgrade_or_not("User interface templates", "y");
$d{'1'} = upgrade_or_not("Static file: board.html", "n");
$d{'2'} = upgrade_or_not("Static file: board-instructions.html", "n");
$d{'4'} = upgrade_or_not("Static file: board-formatting.html", "n");
$d{'5'} = upgrade_or_not("Static file: board-troubleshooting.html", "n");
$d{'6'} = upgrade_or_not("Static file: board-about.html", "n");
$d{'7'} = upgrade_or_not("Static file: board-menu.html", "n");
$d{'9'} = upgrade_or_not("Static files: framesetters (index.html)", "n");
$d{'8'} = upgrade_or_not("Static files: administration instructions", "y");
$d{'10'} = upgrade_or_not("Static file: administration framesetter", "y");
$d{'11'} = upgrade_or_not("Static file: administration warning", "y");
$d{'13'} = upgrade_or_not("Board clip art", "n");
$d{'14'} = upgrade_or_not("Board icons", "n");
$d{'38'} = upgrade_or_not("Javascript source for formatting panel", "n");
}
# ---------------------------------------------------------------------------------
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS UPGRADE -- CONFIRM UPGRADE\n\n";
print "Are you sure you want to perform the upgrade of the board at:\n";
print " $DC->{html_url}\n\n";
my $yn3 = "";
while ($yn3 eq "") {
print "Your answer (y or n): ";
$yn3 = <STDIN>;
$yn3 =~ s/[^yn]//gi;
exit(0) if $yn3 =~ /^n/i;
}
# ---------------------------------------------------------------------------------
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS UPGRADE -- NOW IN PROGRESS\n\n";
install_discus(1, \%d, $DC);
print "\n" x 25;
print "-" x 60, "\n";
print "DISCUS UPGRADE -- COMPLETE\n\n";
print "Congratulations! Your discussion board has been successfully\n";
print "upgraded. Next, log into the administration program as the board\n";
print "administrator (username '$DC->{superuser}'). If additional upgrade\n";
print "tasks are required, you will be informed.\n\n";
print "Press any key to continue...\n";
my $iii = <STDIN>;
exit(0);