home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.pdx.edu / 2014.02.ftp.ee.pdx.edu.tar / ftp.ee.pdx.edu / oss / cvs-2004 / bahasa / utilities / make_release_ready.pl,v < prev   
Text File  |  2003-10-26  |  38KB  |  1,720 lines

  1. head    1.9;
  2. access;
  3. symbols;
  4. locks; strict;
  5. comment    @# @;
  6.  
  7.  
  8. 1.9
  9. date    2003.10.26.01.53.10;    author bule;    state Exp;
  10. branches;
  11. next    1.8;
  12.  
  13. 1.8
  14. date    2003.10.17.00.39.35;    author bule;    state Exp;
  15. branches;
  16. next    1.7;
  17.  
  18. 1.7
  19. date    2003.10.04.18.22.57;    author bule;    state Exp;
  20. branches;
  21. next    1.6;
  22.  
  23. 1.6
  24. date    2003.09.05.06.42.30;    author bule;    state Exp;
  25. branches;
  26. next    1.5;
  27.  
  28. 1.5
  29. date    2003.08.31.18.48.47;    author bule;    state Exp;
  30. branches;
  31. next    1.4;
  32.  
  33. 1.4
  34. date    2003.08.22.06.07.19;    author bule;    state Exp;
  35. branches;
  36. next    1.3;
  37.  
  38. 1.3
  39. date    2003.08.22.00.46.20;    author bule;    state Exp;
  40. branches;
  41. next    1.2;
  42.  
  43. 1.2
  44. date    2003.08.21.20.20.57;    author bule;    state Exp;
  45. branches;
  46. next    1.1;
  47.  
  48. 1.1
  49. date    2003.08.21.06.18.07;    author bule;    state Exp;
  50. branches;
  51. next    ;
  52.  
  53.  
  54. desc
  55. @@
  56.  
  57.  
  58. 1.9
  59. log
  60. @*** empty log message ***
  61. @
  62. text
  63. @#!/usr/bin/perl -w
  64. #/////////////////////////////////////////////////////////////////////////////
  65. #/////////////////////////////////////////////////////////////////////////////
  66. #/ Project Name: Bahasa Indonesia Dictionary
  67. #/ Directory:    bahasa/utilities
  68. #/ File Name:    make_release_ready.pl 
  69. #/ Author(s):    John L. Whiteman
  70. #/ Created:      August 20, 2003  
  71. #/ Modified:     October 21, 2003
  72. #/ Description:  The purpose of this script is to create a 
  73. #/               public release copy of this project.
  74. #/               I typically do my development on a live 
  75. #/               installation which means I have installation
  76. #/               specific things like passwords, database user,
  77. #/               administrators (other than default), e-mail 
  78. #/               addresses, PHP require paths, and other items 
  79. #/               that are not applicable for fresh installations. 
  80. #/               This script will first make a copy of my live 
  81. #/               system to a release directory of your choice,
  82. #/               then replace various items in the source code
  83. #/               with generic entries required for public release,
  84. #/               fresh installations.
  85. #/ 
  86. #/               If you are not a developer then it's likely that 
  87. #/               you will not be using this script.
  88. #/                
  89. #/               You optionally specify -s followed by source directory 
  90. #/               and -t followed by target release directory to run 
  91. #/               this script in non-interactive mode.
  92. #/ 
  93. #/ Copyright (c) 2003 John L. Whiteman
  94. #/
  95. #/ Permission is herby granted, free of charge, to any person obtaining a 
  96. #/ copy of this software, data, and associated documentation files 
  97. #/ (the "Software"), to deal in the Software without restriction, 
  98. #/ including without limitation the rights to use, copy, modify, merge, 
  99. #/ publish, distribute, sublicense, and/or sell copies of Software, and to
  100. #/ permit persons to whom the Software is furnished to do so, subject to 
  101. #/ the following conditions:
  102. #/
  103. #/ The above copyright notice and this permission notice shall be 
  104. #/ included in all copies or substantial portions of the Software.
  105. #/
  106. #/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  107. #/ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  108. #/ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  109. #/ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  110. #/ ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  111. #/ TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  112. #/////////////////////////////////////////////////////////////////////////////
  113. #/////////////////////////////////////////////////////////////////////////////
  114. use strict;
  115. use Cwd;
  116. use Getopt::Std;
  117. use File::Copy;
  118.  
  119. my (%args) = ();
  120.  
  121. getopts("s:t:", \%args);
  122.  
  123. show_introduction();
  124.  
  125. if (!$args{s} || !$args{t}) {
  126.  
  127.     while(1) {
  128.  
  129.         my ($response) = 
  130.         promptyn("Would you like to continue?");
  131.  
  132.         if (!$response) {
  133.  
  134.             print "\nInstallation script terminated!\n\n";
  135.  
  136.             exit(0);
  137.         }
  138.     
  139.         last;
  140.     }
  141. }
  142.  
  143. my (%DICTIONARY_CFG) = ();
  144. my ($INSTALLATION_DIRECTORY) = ""; 
  145. my ($RELEASE_DIRECTORY) = "";
  146.  
  147. if (!$args{s}) {
  148.  
  149.     $INSTALLATION_DIRECTORY = 
  150.     prompt_installation_directory();
  151.  
  152. } else {
  153.  
  154.     $INSTALLATION_DIRECTORY = 
  155.     prompt_installation_directory($args{s});
  156. }
  157.  
  158. if (!$args{t}) {
  159.  
  160.     while(1) {
  161.  
  162. TRY_AGAIN:
  163.  
  164.         $RELEASE_DIRECTORY =
  165.         prompt(
  166.         "Enter the target release directory: ", 1);
  167.  
  168.         #Remove trailing slash for UNIX systems if exists
  169.         $RELEASE_DIRECTORY =~ s/\/$//;
  170.  
  171.         #Remove trailing slash for Windows systems if exists
  172.         $RELEASE_DIRECTORY =~ s/\\$//; 
  173.  
  174.         if (!-d "$RELEASE_DIRECTORY") {
  175.  
  176.             show_error(
  177.             "Target release directory ${RELEASE_DIRECTORY} " .
  178.             "does not exist.\n" .
  179.             "Manually create this directory or use an " .
  180.             "existing one\n" .
  181.             "before continuing.  I'll wait.", 0); 
  182.  
  183.             my ($response) =
  184.             promptyn("Try again?", 1);
  185.  
  186.             if (!$response) {
  187.  
  188.                 print "Script terminated!\n\n";
  189.         
  190.                 exit(0);
  191.             }
  192.  
  193.         } else {
  194.  
  195.             my ($response) =
  196.             promptyn(
  197.             "Is this target release directory " .
  198.             "${RELEASE_DIRECTORY} " .
  199.             "correct?");
  200.  
  201.             if (!$response) {
  202.  
  203.                 $response =
  204.                 promptyn(
  205.                 "Would you like to try another " .
  206.                 "target release " .
  207.                 "directory?");
  208.  
  209.                 goto TRY_AGAIN if ($response);
  210.  
  211.                 exit(0);
  212.             }
  213.  
  214.             last;
  215.         }
  216.     }
  217.  
  218. } else {
  219.  
  220.     $RELEASE_DIRECTORY = $args{t};
  221.  
  222.     #Remove trailing slash for UNIX systems if exists
  223.     $RELEASE_DIRECTORY =~ s/\/$//;
  224.  
  225.     #Remove trailing slash for Windows systems if exists
  226.     $RELEASE_DIRECTORY =~ s/\\$//; 
  227.  
  228.     if (!-d "$RELEASE_DIRECTORY") {
  229.  
  230.             show_error(
  231.             "Target release directory ${RELEASE_DIRECTORY} " .
  232.             "does not exist.\n" .
  233.             "Manually create this directory or use an " .
  234.             "existing one before continuing", -1); 
  235.     }
  236. }
  237.  
  238.  
  239. my ($SLASH) = "/";
  240.  
  241. $SLASH = "\\"
  242. if ($INSTALLATION_DIRECTORY =~ /\\/);
  243.  
  244. #These are all the required directories and 
  245. #files associated with this project.
  246. #They are followed by default permissions.
  247. #Change these permissions to best suite your needs 
  248. #Add your own files and directories if applicable
  249. #Changing the paths to these files is likely cause
  250. #the project to fail
  251. my (%manifest) = (
  252. "backups" => 0703,
  253. "docs" => 0700,
  254. "mysql" => 0703,
  255. "php" => 0701,
  256. "utilities" => 0700,
  257. "web" => 0700,
  258. "backups${SLASH}empty.sql" => 0600,
  259. "docs${SLASH}installation.txt" => 0600,
  260. "docs${SLASH}readme.txt" => 0600,
  261. "mysql${SLASH}administration.sql" => 0606,
  262. "mysql${SLASH}administrators.sql" => 0606,
  263. "mysql${SLASH}alphabet.sql" => 0606,
  264. "mysql${SLASH}create.sql" => 0604,
  265. "mysql${SLASH}destroy.sql" => 0604,
  266. "mysql${SLASH}dictionary.sql" => 0606,
  267. "mysql${SLASH}hits.sql" => 0606,
  268. "mysql${SLASH}misses.sql" => 0606,
  269. "mysql${SLASH}parts_of_speech.sql" => 0606,
  270. "mysql${SLASH}pronunciations.sql" => 0606,
  271. "mysql${SLASH}requests.sql" => 0606,
  272. "mysql${SLASH}searches.sql" => 0606,
  273. "mysql${SLASH}tasks.sql" => 0606,
  274. "php${SLASH}Dictionary.php" => 0604,
  275. "php${SLASH}Indonesia.php" => 0604,
  276. "php${SLASH}Statistics.php" => 0604,
  277. "php${SLASH}Web.php" => 0604,
  278. "utilities${SLASH}config_app.pl" => 0700,
  279. "utilities${SLASH}config_db.pl" => 0700,
  280. "utilities${SLASH}make_release_ready.pl" => 0700,
  281. "web${SLASH}admin.php" => 0604, 
  282. "web${SLASH}admins.php" => 0604, 
  283. "web${SLASH}backup.php" => 0604, 
  284. "web${SLASH}bahasa.css" => 0604, 
  285. "web${SLASH}bahasa.js" => 0604, 
  286. "web${SLASH}cpwd.php" => 0604, 
  287. "web${SLASH}delete.php" => 0604, 
  288. "web${SLASH}dictionary.php" => 0604, 
  289. "web${SLASH}download.php" => 0604, 
  290. "web${SLASH}editor.php" => 0604, 
  291. "web${SLASH}email.php" => 0604, 
  292. "web${SLASH}help.php" => 0604, 
  293. "web${SLASH}insert.php" => 0604, 
  294. "web${SLASH}ipa.php" => 0604, 
  295. "web${SLASH}login.php" => 0604, 
  296. "web${SLASH}logout.php" => 0604, 
  297. "web${SLASH}misses.php" => 0604, 
  298. "web${SLASH}offline.php" => 0604, 
  299. "web${SLASH}online.php" => 0604, 
  300. "web${SLASH}pos.php" => 0604, 
  301. "web${SLASH}pronunciations.php" => 0604, 
  302. "web${SLASH}reference.php" => 0604, 
  303. "web${SLASH}request.php" => 0604, 
  304. "web${SLASH}requests.php" => 0604, 
  305. "web${SLASH}search.php" => 0604, 
  306. "web${SLASH}sql.php" => 0604, 
  307. "web${SLASH}statistics.php" => 0604,
  308. "web${SLASH}tasks.php" => 0604,
  309. "web${SLASH}update.php" => 0604,
  310. "web${SLASH}upload.php" => 0604
  311. );
  312.  
  313. my (%class_files) = (
  314.  
  315. "php${SLASH}Indonesia.php" =>
  316. "php${SLASH}Dictionary.php",
  317.  
  318. "php${SLASH}Statistics.php" =>
  319. "php${SLASH}Dictionary.php");
  320.  
  321. my (%web_files) = (
  322.  
  323. "web${SLASH}admin.php" => 
  324. "php${SLASH}Indonesia.php",
  325.  
  326. "web${SLASH}admins.php" => 
  327. "php${SLASH}Indonesia.php",
  328.  
  329. "web${SLASH}backup.php" => 
  330. "php${SLASH}Indonesia.php",
  331.  
  332. "web${SLASH}cpwd.php" =>
  333. "php${SLASH}Indonesia.php",
  334.  
  335. "web${SLASH}delete.php" =>
  336. "php${SLASH}Indonesia.php",
  337.  
  338. "web${SLASH}download.php" =>
  339. "php${SLASH}Indonesia.php",
  340.  
  341. "web${SLASH}dictionary.php" =>
  342. "php${SLASH}Indonesia.php",
  343.  
  344. "web${SLASH}editor.php" =>
  345. "php${SLASH}Indonesia.php",
  346.  
  347. "web${SLASH}email.php" =>
  348. "php${SLASH}Indonesia.php",
  349.  
  350. "web${SLASH}help.php" =>
  351. "php${SLASH}Indonesia.php",
  352.  
  353. "web${SLASH}insert.php" =>
  354. "php${SLASH}Indonesia.php",
  355.  
  356. "web${SLASH}ipa.php" =>
  357. "php${SLASH}Indonesia.php",
  358.  
  359. "web${SLASH}login.php" =>
  360. "php${SLASH}Indonesia.php",
  361.  
  362. "web${SLASH}logout.php" =>
  363. "php${SLASH}Indonesia.php",
  364.  
  365. "web${SLASH}misses.php" =>
  366. "php${SLASH}Indonesia.php",
  367.  
  368. "web${SLASH}offline.php" =>
  369. "php${SLASH}Indonesia.php",
  370.  
  371. "web${SLASH}online.php" =>
  372. "php${SLASH}Indonesia.php",
  373.  
  374. "web${SLASH}pos.php" =>
  375. "php${SLASH}Indonesia.php",
  376.  
  377. "web${SLASH}pronunciations.php" =>
  378. "php${SLASH}Indonesia.php",
  379.  
  380. "web${SLASH}reference.php" =>
  381. "php${SLASH}Indonesia.php",
  382.  
  383. "web${SLASH}request.php" =>  
  384. "php${SLASH}Indonesia.php",
  385.  
  386. "web${SLASH}requests.php" =>  
  387. "php${SLASH}Indonesia.php",
  388.  
  389. "web${SLASH}search.php" =>
  390. "php${SLASH}Indonesia.php",
  391.  
  392. "web${SLASH}sql.php" =>
  393. "php${SLASH}Indonesia.php",
  394.  
  395. "web${SLASH}statistics.php" =>  
  396. "php${SLASH}Statistics.php",
  397.  
  398. "web${SLASH}tasks.php" =>  
  399. "php${SLASH}Indonesia.php",
  400.  
  401. "web${SLASH}update.php" =>  
  402. "php${SLASH}Indonesia.php",
  403.  
  404. "web${SLASH}upload.php" =>  
  405. "php${SLASH}Indonesia.php");
  406.  
  407. my (@@subdirectories) = (
  408. "${SLASH}backups",
  409. "${SLASH}docs",
  410. "${SLASH}mysql",
  411. "${SLASH}php",
  412. "${SLASH}utilities",
  413. "${SLASH}web");
  414.  
  415. my ($dictionary_class) = 
  416. "${RELEASE_DIRECTORY}${SLASH}php${SLASH}Dictionary.php";
  417.  
  418. my ($web_class) =
  419. "${RELEASE_DIRECTORY}${SLASH}php${SLASH}Web.php";
  420.  
  421. my (%modified_manifest) = ();
  422.  
  423. print "Verifying setup directories and files...\n\n";
  424.  
  425. #Now verify that all directories and files exist
  426. #We will change the permissions only after the 
  427. #configuration is finished.
  428. foreach(sort(keys(%manifest))) {
  429.  
  430.     my ($path) = $_;
  431.  
  432.     my ($permissions) = $manifest{$path};
  433.  
  434.     my($source_path) = 
  435.     $INSTALLATION_DIRECTORY . $SLASH . $path; 
  436.  
  437.     my ($target_path) = 
  438.     $RELEASE_DIRECTORY . $SLASH . $path; 
  439.  
  440.     $modified_manifest{$target_path} = $permissions;
  441.  
  442.     print "${source_path} ";
  443.  
  444.     show_error("\nCan't find ${source_path}", -1) if (!-e "$source_path");
  445.  
  446.     print "[OK]\n";
  447. }
  448.  
  449. reset(%manifest);
  450.  
  451. print "Copying ${INSTALLATION_DIRECTORY} => ${RELEASE_DIRECTORY}...\n"; 
  452.  
  453. #Create the release subdirectories if they don't exist
  454. foreach(@@subdirectories) {
  455.  
  456.     my ($subdirectory) = "${RELEASE_DIRECTORY}${_}";
  457.  
  458.     if (!-d "$subdirectory") {
  459.  
  460.         my ($rc) = mkdir("$subdirectory", 0700);
  461.  
  462.         show_error(
  463.         "Can't create release sub-directory " .
  464.         "${subdirectory}: $!", -1) if (!$rc);
  465.  
  466.         chmod(0700, "$subdirectory");
  467.     }
  468. }
  469.  
  470. #Now perform the file copies 
  471. foreach(sort(keys(%manifest))) {
  472.  
  473.     my ($path) = $_;
  474.  
  475.     my ($permissions) = $manifest{$path};
  476.  
  477.     my($source_path) = 
  478.     $INSTALLATION_DIRECTORY . $SLASH . $path; 
  479.  
  480.     my ($target_path) = 
  481.     $RELEASE_DIRECTORY . $SLASH . $path; 
  482.  
  483.     #This is a file
  484.     if (($path ne "backups") &&
  485.     ($path ne "docs") &&
  486.     ($path ne "mysql") &&
  487.     ($path ne "php") &&
  488.     ($path ne "utilities") &&
  489.     ($path ne "web")) {
  490.  
  491.         copy("$source_path", "$target_path");
  492.  
  493.         show_error(
  494.         "Can't copy\n${source_path} to \n${target_path}\n" .
  495.         "Check file permissions and/or disk space for " .
  496.         "possible causes: $!\n") if (!-f "$target_path");
  497.  
  498.         chmod($permissions, "$target_path");
  499.     }
  500. }
  501.  
  502. my (%modified_web_files) = ();
  503.  
  504. #Qualify the default directories by prepending the installation 
  505. #directories then check to ensure the files exist then assign 
  506. #then to hash that indicates which class file to use.  These files
  507. #pertain to the PHP web code.
  508. foreach(sort(keys(%web_files))) {
  509.  
  510.     my ($web_file) = 
  511.     $RELEASE_DIRECTORY . 
  512.     $SLASH . ${_};
  513.  
  514.     my ($class_file) = 
  515.     $RELEASE_DIRECTORY . 
  516.     $SLASH . $web_files{$_};
  517.  
  518.     #Check here if exists...abort if doesn't
  519.     show_error(
  520.     "Can't find PHP web file ${web_file}\n" .
  521.     "Please make sure you installation path is correct.", -1)
  522.         if (!-f "$web_file");
  523.  
  524.     #Check here if exists...abort if doesn't
  525.     show_error(
  526.     "Can't find PHP class file ${class_file}\n" .
  527.     "Please make sure you installation path is correct.", -1)
  528.         if (!-f "$class_file");
  529.  
  530.     $modified_web_files{"$web_file"} = "$class_file";
  531. }
  532.  
  533. my (%modified_class_files) = ();
  534.  
  535. #Do the same for child class files 
  536. foreach(sort(keys(%class_files))) {
  537.  
  538.     my ($child_class) = 
  539.     $RELEASE_DIRECTORY . 
  540.     $SLASH . ${_};
  541.  
  542.     my ($parent_class) = 
  543.     $RELEASE_DIRECTORY . 
  544.     $SLASH . $class_files{$_};
  545.  
  546.     #Check here if exists...abort if doesn't
  547.     show_error(
  548.     "Can't find PHP class file ${child_class}\n" .
  549.     "Please make sure you installation path is correct.", -1)
  550.         if (!-f "$child_class");
  551.  
  552.     #Check here if exists...abort if doesn't
  553.     show_error(
  554.     "Can't find PHP parent class file ${parent_class}\n" .
  555.     "Please make sure you installation path is correct.", -1)
  556.         if (!-f "$parent_class");
  557.  
  558.     $modified_class_files{"$child_class"} = "$parent_class";
  559. }
  560.  
  561. $DICTIONARY_CFG{"DB_HOST"} = 
  562. "Enter database server name or ip";
  563.  
  564. $DICTIONARY_CFG{"DB_NAME"} = 
  565. "Enter database name";
  566.  
  567. $DICTIONARY_CFG{"DB_PASSWORD"} =
  568. "Enter database user's password";
  569.  
  570. $DICTIONARY_CFG{"DB_USER"} =
  571. "Enter database user name";
  572.  
  573. $DICTIONARY_CFG{"EMAIL"} =
  574. "Enter website's e-maill address";
  575.  
  576. $DICTIONARY_CFG{"INSTALLATION_DIRECTORY"} = 
  577. "Enter project's installation directory";
  578.  
  579. print "Configuring Dictionary.pm class file...\n";
  580.  
  581. #Configure the Dictionary.php class with given values
  582. configure_dictionary_class("$dictionary_class", \%DICTIONARY_CFG, $SLASH);
  583.  
  584. print "Configuring other class files...\n";
  585.  
  586. #Modify the web files' require_once() statements to include full path
  587. #to source class files
  588. foreach(sort(keys(%modified_class_files))) {
  589.  
  590.     my ($child_class) = $_;
  591.  
  592.     my ($parent_class) = $modified_class_files{$child_class};
  593.  
  594.     configure_php_file($child_class, $parent_class, $SLASH, "", 1);
  595. }
  596.  
  597. print "Configuring PHP web files...\n";
  598.  
  599. #Modify the web files' require_once() statements to include full path
  600. #to source class files
  601. foreach(sort(keys(%modified_web_files))) {
  602.  
  603.     my ($web_file) = $_;
  604.  
  605.     my ($class_file) = $modified_web_files{$web_file};
  606.  
  607.     configure_php_file($web_file, $class_file, $SLASH, $web_class);
  608. }
  609.  
  610. #Clean various mySQL files that should not have data for fresh installs 
  611. print "Preparing mySQL files...\n"; 
  612.  
  613. prepare_mysql_files("${RELEASE_DIRECTORY}${SLASH}mysql${SLASH}");
  614.  
  615. print "Setting default permissions to directories and files...\n";
  616.  
  617. change_permissions(\%modified_manifest);
  618.  
  619. print "Installation script done!\n";
  620.  
  621. #----------------------------------------------------------------------------
  622. #Changes installation directories and files to default permissions 
  623. #----------------------------------------------------------------------------
  624. sub change_permissions {
  625.  
  626.     my ($modified_manifest) = shift;
  627.  
  628.     foreach(sort(keys(%$modified_manifest))) {
  629.  
  630.         my ($path) = $_;
  631.  
  632.         my ($permissions) = $$modified_manifest{$path};
  633.  
  634.         chmod($permissions, $path);
  635.     }
  636.  
  637.     return;
  638. }
  639. #----------------------------------------------------------------------------
  640. #Configures the Dictionary.pm class files to run under this environment.
  641. #----------------------------------------------------------------------------
  642. sub configure_dictionary_class {
  643.  
  644.     my ($file) = shift;
  645.     my ($cfg) = shift;
  646.     my ($slash) = shift;
  647.     my ($file_backup) = $file . "." . $$ . ".bak"; 
  648.     my ($cfg_entry) = "";
  649.  
  650.     #Compose the dictionary configuration PHP entries
  651.     #Also change permissions to directories if applicable
  652.     foreach(sort(keys(%$cfg))) {
  653.  
  654.         my ($name) = $_;
  655.         my ($value) = $$cfg{$_};
  656.  
  657.         $cfg_entry .= 
  658.         "\$this->configuration[\"${name}\"] = \"${value}\";\n\n"; 
  659.     }
  660.  
  661.     #Clean it up
  662.     chomp($cfg_entry);
  663.  
  664.     #Remove existing backup file if exists
  665.     unlink("$file_backup") if (-f "$file_backup");
  666.  
  667.     #Make a backup copy just to be safe
  668.     copy("$file", "$file_backup") || goto RECOVER_AND_ABORT_A;
  669.  
  670.     #Remove the original file
  671.     unlink("$file");
  672.  
  673.     #Create a new PHP file 
  674.     open(NEW_FILE, ">${file}") || goto RECOVER_AND_ABORT_B;
  675.  
  676.     #Open the original file (backup)
  677.     open(OLD_FILE, "${file_backup}") || goto RECOVERY_AND_ABORT_C;
  678.  
  679.     my ($ignore_flag) = 0;
  680.  
  681.     while(<OLD_FILE>) {
  682.  
  683.         my ($tmp) = $_;
  684.  
  685.         if ($tmp =~ /\/\/\<CONFIGURATION\>/) {
  686.  
  687.             print NEW_FILE $tmp;
  688.  
  689.             print NEW_FILE $cfg_entry; 
  690.  
  691.             $ignore_flag = 1;
  692.  
  693.             next;
  694.  
  695.         } elsif (($tmp =~ /\/\/\<\/CONFIGURATION\>/) &&
  696.                  ($ignore_flag)) { 
  697.  
  698.             print NEW_FILE $tmp;
  699.  
  700.             $ignore_flag = 0;
  701.  
  702.         } elsif (!$ignore_flag) {
  703.  
  704.             print NEW_FILE $tmp;
  705.         }
  706.     }
  707.  
  708.     close(NEW_FILE);
  709.  
  710.     close(OLD_FILE);
  711.  
  712.     #Double check to ensure new file exists
  713.     goto  RECOVERY_AND_ABORT_D if (!-f "$file");
  714.  
  715.     #Remove the backup file
  716.     unlink("$file_backup") if (-f "$file_backup");
  717.  
  718.     #Give proper permissions
  719.     chmod(0604, "$file");
  720.  
  721.     return;
  722.  
  723. RECOVER_AND_ABORT_A:
  724.  
  725.     #Remove backup if exists
  726.     unlink("$file_backup") if (-f "$file_backup");
  727.  
  728.     show_error(
  729.     "Can't copy ${file} to ${file_backup}\n" .
  730.     "Make sure you have proper permissions or enough space.",
  731.     -1);
  732.  
  733. RECOVER_AND_ABORT_B:
  734.  
  735.     close(NEW_FILE);
  736.  
  737.     #Remove the new file if it was partially created
  738.     unlink("$file");
  739.  
  740.     #Move backup file back to its original spot
  741.     move("$file_backup", "$file"); 
  742.  
  743.     if (!-f "$file") {
  744.  
  745.         show_error(
  746.         "Could not configure and restore PHP file ${file}\n" .
  747.         "Correct the error and reinstall before running " .
  748.         "this script again.", -1); 
  749.     }
  750.  
  751.     show_error(
  752.     "Could not configure PHP file ${file}\n" .
  753.     "Correct the error and try again.", -1); 
  754.  
  755. RECOVER_AND_ABORT_C:
  756.  
  757.     close(NEW_FILE);
  758.  
  759.     close(OLD_FILE);
  760.  
  761.     #Remove the new file if it was partially created
  762.     unlink("$file");
  763.  
  764.     #Move backup file back to its original spot
  765.     move("$file_backup", "$file");
  766.  
  767.     if (!-f "$file") {
  768.  
  769.         show_error(
  770.         "Could not configure and restore PHP file ${file}\n" .
  771.         "Correct the error and reinstall before running " .
  772.         "this script again.", -1); 
  773.     }
  774.  
  775.     show_error(
  776.     "Could not configure PHP file ${file}\n" .
  777.     "Correct the error and try again.", -1); 
  778.  
  779. RECOVER_AND_ABORT_D:
  780.  
  781.     #Remove the new file if it was partially created
  782.     unlink("$file");
  783.  
  784.     #Move backup file back to its original spot
  785.     move("$file_backup", "$file");
  786.  
  787.     if (!-f "$file") {
  788.  
  789.         show_error(
  790.         "Could not configure and restore PHP file ${file}\n" .
  791.         "Correct the error and reinstall before running " .
  792.         "this script again.", -1); 
  793.     }
  794.  
  795.     show_error(
  796.     "Could not configure PHP file ${file}\n" .
  797.     "Correct the error and try again.", -1); 
  798. }
  799. #----------------------------------------------------------------------------
  800. #Configures PHP files to include generic relative class file paths
  801. #----------------------------------------------------------------------------
  802. sub configure_php_file {
  803.  
  804.     my ($file) = shift; 
  805.     my ($class_file) = shift;
  806.     my ($slash) = shift;
  807.     my ($web_class) = shift || "";
  808.     my ($class_flag) = shift || 0;
  809.     my ($file_backup) = $file . "." . $$ . ".bak"; 
  810.  
  811.     #Remove existing backup file if exists
  812.     unlink("$file_backup") if (-f "$file_backup");
  813.  
  814.     #Make a backup copy just to be safe
  815.     copy("$file", "$file_backup") || goto RECOVER_AND_ABORT_A;
  816.  
  817.     #Remove the original file
  818.     unlink("$file");
  819.  
  820.     #Create a new PHP file 
  821.     open(NEW_FILE, ">${file}") || goto RECOVER_AND_ABORT_B;
  822.  
  823.     #Open the original file (backup)
  824.     open(OLD_FILE, "${file_backup}") || goto RECOVERY_AND_ABORT_C;
  825.  
  826.     $class_file =~ s/\\/\\\\/g if ($slash eq "\\");
  827.  
  828.     $class_file = get_basename($class_file);
  829.  
  830.     my ($new_require);
  831.  
  832.     #For web files
  833.     if (!$class_flag) {    
  834.  
  835.         #New require_once() string
  836.         $new_require = 
  837.         "require_once(\"..${slash}php${slash}${class_file}\");\n";
  838.  
  839.     #For class files
  840.     } else {
  841.  
  842.         #New require_once() string
  843.         $new_require = 
  844.         "require_once(\"${class_file}\");\n";
  845.     }
  846.  
  847.     #Also add web class if applicable
  848.     if ($web_class ne "") {
  849.  
  850.         $web_class =~ s/\\/\\\\/g if ($slash eq "\\");
  851.  
  852.         $new_require .= 
  853.         "require_once(\"..${slash}php${slash}Web.php\");\n";
  854.     }
  855.  
  856.     my ($ignore_old_require_flag) = 0;
  857.  
  858.     while(<OLD_FILE>) {
  859.  
  860.         my ($tmp) = $_;
  861.  
  862.         #Insert the new one
  863.         if (
  864.         ($tmp =~ /require_once\(/) && 
  865.         ($tmp =~ /\)\;/) && 
  866.         (!$ignore_old_require_flag)) {
  867.  
  868.             print NEW_FILE $new_require; 
  869.  
  870.             $ignore_old_require_flag = 1;
  871.  
  872.         #Ignore the old requires
  873.         } elsif (
  874.           ($tmp =~ /require_once\(/) && 
  875.           ($tmp =~ /\)\;/))  {
  876.  
  877.             next;
  878.  
  879.         }  else {
  880.  
  881.             print NEW_FILE $tmp; 
  882.         }
  883.     }
  884.  
  885.     close(NEW_FILE);
  886.  
  887.     close(OLD_FILE);
  888.  
  889.     #Double check to ensure new file exists
  890.     goto  RECOVERY_AND_ABORT_D if (!-f "$file");
  891.  
  892.     #Remove the backup file
  893.     unlink("$file_backup") if (-f "$file_backup");
  894.  
  895.     chmod(0604, "$file");
  896.  
  897.     return;
  898.  
  899. RECOVER_AND_ABORT_A:
  900.  
  901.     #Remove backup if exists
  902.     unlink("$file_backup") if (-f "$file_backup");
  903.  
  904.     show_error(
  905.     "Can't copy ${file} to ${file_backup}\n" .
  906.     "Make sure you have propery permissions or enough space.",
  907.     -1);
  908.  
  909. RECOVER_AND_ABORT_B:
  910.  
  911.     close(NEW_FILE);
  912.  
  913.     #Remove the new file if it was partially created
  914.     unlink("$file");
  915.  
  916.     #Move backup file back to its original spot
  917.     move("$file_backup", "$file"); 
  918.  
  919.     if (!-f "$file") {
  920.  
  921.         show_error(
  922.         "Could not configure and restore PHP file ${file}\n" .
  923.         "Correct the error and reinstall before running " .
  924.         "this script again.", -1); 
  925.     }
  926.  
  927.     show_error(
  928.     "Could not configure PHP file ${file}\n" .
  929.     "Correct the error and try again.", -1); 
  930.  
  931. RECOVER_AND_ABORT_C:
  932.  
  933.     close(NEW_FILE);
  934.  
  935.     close(OLD_FILE);
  936.  
  937.     #Remove the new file if it was partially created
  938.     unlink("$file");
  939.  
  940.     #Move backup file back to its original spot
  941.     move("$file_backup", "$file");
  942.  
  943.     if (!-f "$file") {
  944.  
  945.         show_error(
  946.         "Could not configure and restore PHP file ${file}\n" .
  947.         "Correct the error and reinstall before running " .
  948.         "this script again.", -1); 
  949.     }
  950.  
  951.     show_error(
  952.     "Could not configure PHP file ${file}\n" .
  953.     "Correct the error and try again.", -1); 
  954.  
  955. RECOVER_AND_ABORT_D:
  956.  
  957.     #Remove the new file if it was partially created
  958.     unlink("$file");
  959.  
  960.     #Move backup file back to its original spot
  961.     move("$file_backup", "$file");
  962.  
  963.     if (!-f "$file") {
  964.  
  965.         show_error(
  966.         "Could not configure and restore PHP file ${file}\n" .
  967.         "Correct the error and reinstall before running " .
  968.         "this script again.", -1); 
  969.     }
  970.  
  971.     show_error(
  972.     "Could not configure PHP file ${file}\n" .
  973.     "Correct the error and try again.", -1); 
  974. }
  975. #----------------------------------------------------------------------------
  976. #Returns the basename of a path
  977. #----------------------------------------------------------------------------
  978. sub get_basename {
  979.  
  980.     my ($path) = shift;
  981.     my (@@path_tree) = shift;
  982.  
  983.     if ($path =~ /\\/) {
  984.  
  985.         @@path_tree = split(/\\/, $path);
  986.  
  987.         return($path_tree[$#path_tree]);
  988.  
  989.     } elsif ($path =~ /\//) {
  990.  
  991.         @@path_tree = split(/\//, $path);
  992.  
  993.         return($path_tree[$#path_tree]);
  994.     }
  995.  
  996.     return($path);
  997. }
  998. #----------------------------------------------------------------------------
  999. #Prepares various mySQL files for fresh installs 
  1000. #----------------------------------------------------------------------------
  1001. sub prepare_mysql_files {
  1002.  
  1003.     my ($mysql_directory) = shift;
  1004.  
  1005.     my ($default_administration) =
  1006.     "INSERT INTO administration VALUES\n" .
  1007.     "(\"\", \"offline\", \"0\", " .
  1008.     "\"Disables dictionary searches when set to 1\");";
  1009.  
  1010.     my ($default_administrators) = 
  1011.     "INSERT INTO administrators VALUES\n" .
  1012.     "(\"\", \"administrator\", \"BISlaW8N/JdYE\", " .
  1013.     "\"1\", \"0\", \"0\");";
  1014.  
  1015.     #These files should contain nothing but copyright notice
  1016.     #and possible defaults as seen above
  1017.     my (@@sql_files) = (
  1018.     "${mysql_directory}hits.sql",
  1019.     "${mysql_directory}misses.sql",
  1020.     "${mysql_directory}requests.sql",
  1021.     "${mysql_directory}searches.sql",
  1022.     "${mysql_directory}tasks.sql",
  1023.     "${mysql_directory}administration.sql",
  1024.     "${mysql_directory}administrators.sql");
  1025.  
  1026.     foreach(@@sql_files) {
  1027.  
  1028.         my ($sql_file) = $_;
  1029.  
  1030.         my ($copyright) = "";
  1031.  
  1032.         open(SQL_FILE, "$sql_file") || 
  1033.             show_error("Can't open ${sql_file}: $!", -1);
  1034.  
  1035.         while(<SQL_FILE>) {
  1036.  
  1037.             my ($sql) = $_;
  1038.  
  1039.             trim(\$sql);
  1040.  
  1041.             $copyright .= "$sql\n" if ($sql =~ /^\#\//);
  1042.         }
  1043.  
  1044.         close(SQL_FILE);
  1045.  
  1046.         open(NEW_SQL_FILE, ">${sql_file}") || 
  1047.             show_error("Can't create new ${sql_file}: $!", -1);
  1048.  
  1049.         print NEW_SQL_FILE "${copyright}"; 
  1050.  
  1051.         if ($sql_file =~ /administration\.sql$/) {
  1052.  
  1053.             print NEW_SQL_FILE $default_administration . "\n";  
  1054.  
  1055.         } elsif ($sql_file =~ /administrators\.sql$/) {
  1056.  
  1057.             print NEW_SQL_FILE $default_administrators . "\n";  
  1058.         }
  1059.  
  1060.         close(NEW_SQL_FILE);
  1061.     }
  1062.  
  1063.     return;
  1064. }
  1065. #----------------------------------------------------------------------------
  1066. #Generic prompt 
  1067. #----------------------------------------------------------------------------
  1068. sub prompt {
  1069.  
  1070.     my ($prompt) = shift;
  1071.     my ($required_flag) = shift;
  1072.     my ($response) = "";
  1073.  
  1074.     #Iterate until correct response is found
  1075.     while(1) {
  1076.  
  1077.         #Show prompt message
  1078.         print "\n${prompt}\n\n";
  1079.  
  1080.         #Grab response
  1081.         $response = <STDIN>;
  1082.  
  1083.         #Remove leading and trailing white-spaces
  1084.         trim(\$response);
  1085.         
  1086.         if (($response) eq "" && ($required_flag)) {
  1087.  
  1088.             show_error("This parameter requires a value!", 0);
  1089.     
  1090.             next;
  1091.         } 
  1092.  
  1093.         last;
  1094.     }
  1095.  
  1096.     return($response);
  1097. }
  1098. #----------------------------------------------------------------------------
  1099. #Generic yes or no prompt. Returns 1 for yes and 0 for no. 
  1100. #----------------------------------------------------------------------------
  1101. sub promptyn {
  1102.  
  1103.     my ($prompt) = shift;
  1104.     my ($response);
  1105.     my ($ucresponse);
  1106.     my (%responses) = (YES => 1, NO => 1, Y => 1, N => 1);
  1107.  
  1108.     #Iterate until correct response is found
  1109.     while(1) {
  1110.  
  1111.         #Show prompt message
  1112.         print "\n${prompt} [y|n]\n\n";
  1113.  
  1114.         #Grab response
  1115.         $response = <STDIN>;
  1116.         
  1117.         #Clean leading and trailing white spaces
  1118.         trim(\$response);
  1119.  
  1120.         if ($response eq "") {
  1121.  
  1122.             show_error(
  1123.             "Please respond with a 'y' or 'n' answer!", 0);
  1124.  
  1125.             next;
  1126.  
  1127.         }  else {
  1128.  
  1129.             $ucresponse = uc($response);
  1130.  
  1131.             if (exists($responses{$ucresponse})) {
  1132.  
  1133.                 last;
  1134.  
  1135.             } else {
  1136.  
  1137.                 show_error(
  1138.                 "Please respond with a 'y' or 'n' answer!", 0);
  1139.             }
  1140.         }
  1141.     }
  1142.  
  1143.     return(1) if ($ucresponse =~ /^Y/);
  1144.  
  1145.     return(0);
  1146. }
  1147. #----------------------------------------------------------------------------
  1148. #Generic prompt with default
  1149. #----------------------------------------------------------------------------
  1150. sub promptx {
  1151.  
  1152.     my ($prompt) = shift;
  1153.     my ($default) = shift;
  1154.     my ($required_flag) = shift;
  1155.     my ($response) = "";
  1156.  
  1157.     #Iterate until correct response is found
  1158.     while(1) {
  1159.  
  1160.         print "\n${prompt} [${default}]\n\n";
  1161.  
  1162.         $response = <STDIN>;
  1163.  
  1164.         chomp($response);
  1165.  
  1166.         if ($response eq "") {
  1167.  
  1168.             $response = $default;
  1169.  
  1170.             last;
  1171.  
  1172.         } else {
  1173.  
  1174.             trim(\$response);
  1175.  
  1176.             if (($response) eq "" && ($required_flag)) {
  1177.  
  1178.                 show_error(
  1179.                 "This parameter requires a value!", 0);
  1180.  
  1181.                 next;
  1182.  
  1183.             } else {
  1184.  
  1185.  
  1186.                 last;
  1187.             }
  1188.         }
  1189.     }
  1190.  
  1191.     return("$response");
  1192. }
  1193. #----------------------------------------------------------------------------
  1194. #Prompt for installation directory
  1195. #----------------------------------------------------------------------------
  1196. sub prompt_installation_directory {
  1197.  
  1198.     my ($installation_directory) = shift || "";
  1199.     my ($pwd) = cwd();
  1200.     my ($default_dir) = "";
  1201.  
  1202.     if ($pwd) {
  1203.  
  1204.         if (-d "$pwd") {
  1205.  
  1206.             show_error(
  1207.             "You must run this installation script " .
  1208.             "under the same directory that it resides.", -1)
  1209.                 if ($pwd !~ /utilities$/);
  1210.  
  1211.             $default_dir = $pwd;
  1212.  
  1213.             $default_dir =~ s/\/utilities$//;
  1214.         } 
  1215.     }
  1216.  
  1217.  
  1218.     if ("$installation_directory" ne "") {
  1219.  
  1220.         show_error("${installation_directory} does not exist", -1) 
  1221.             if (!-d "$installation_directory");
  1222.  
  1223.         #Remove trailing slash for UNIX systems if exists
  1224.         $installation_directory =~ s/\/$//;
  1225.  
  1226.         #Remove trailing slash for Windows systems if exists
  1227.         $installation_directory =~ s/\\$//;
  1228.  
  1229.         return("$installation_directory");
  1230.     }
  1231.  
  1232.  
  1233.     if (-d "$default_dir") {
  1234.  
  1235.         while(1) {
  1236.  
  1237.             $installation_directory =
  1238.             promptx(
  1239.             "Enter the source development directory:\n", 
  1240.             "$default_dir", 1);
  1241.     
  1242.             if (!-d "$installation_directory") {
  1243.  
  1244.                 show_error(
  1245.                 "'${installation_directory}'" .
  1246.                 " does not exists.  Please try again.", 0);
  1247.  
  1248.                 next;
  1249.             }
  1250.  
  1251.             last;
  1252.         }
  1253.  
  1254.     } else {
  1255.  
  1256.  
  1257.         while(1) {
  1258.     
  1259.             $installation_directory =
  1260.             prompt(
  1261.             "Enter the development directory: ", 1);
  1262.  
  1263.             if (!-d "$installation_directory") {
  1264.  
  1265.                 show_error(
  1266.                 "'${installation_directory}'" .
  1267.                 " does not exists.  Please try again.", 0);
  1268.  
  1269.                 next;
  1270.             }
  1271.  
  1272.             last;
  1273.         }
  1274.     }
  1275.  
  1276.     #Remove trailing slash for UNIX systems if exists
  1277.     $installation_directory =~ s/\/$//;
  1278.  
  1279.     #Remove trailing slash for Windows systems if exists
  1280.     $installation_directory =~ s/\\$//;
  1281.  
  1282.     return("$installation_directory");
  1283. }
  1284. #----------------------------------------------------------------------------
  1285. #Display error message then terminate script
  1286. #----------------------------------------------------------------------------
  1287. sub show_error {
  1288.  
  1289.     my ($msg) = shift;
  1290.     my ($exit_flag) = shift || 0;
  1291.  
  1292.     print "\nInstallation Error:\n${msg}\n\n";
  1293.  
  1294.     exit(-1) if ($exit_flag);
  1295.  
  1296.     return;
  1297. }
  1298. #----------------------------------------------------------------------------
  1299. #Introduction message
  1300. #----------------------------------------------------------------------------
  1301. sub show_introduction {
  1302.  
  1303.     print <<EOF;
  1304.  
  1305. /////////////////////////////////////////////////////////////////////////////
  1306.         BAHASA INDONESIA DICTIONARY DEVELOPER'S MAKE RELEASE SCRIPT
  1307. /////////////////////////////////////////////////////////////////////////////
  1308.  
  1309. Copyright (c) 2003 John L. Whiteman
  1310.  
  1311. Permission is herby granted, free of charge, to any person obtaining a 
  1312. copy of this software, data, and associated documentation files 
  1313. (the "Software"), to deal in the Software without restriction, 
  1314. including without limitation the rights to use, copy, modify, merge, 
  1315. publish, distribute, sublicense, and/or sell copies of Software, and to
  1316. permit persons to whom the Software is furnished to do so, subject to 
  1317. the following conditions:
  1318.  
  1319. The above copyright notice and this permission notice shall be 
  1320. included in all copies or substantial portions of the Software.
  1321.  
  1322. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
  1323. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
  1324. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  1325. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 
  1326. ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHERE IN AN ACTION OF CONTRACT,
  1327. TORT OR OTHERWISE, ARISING IN THE SOFTWARE.  
  1328.  
  1329. /////////////////////////////////////////////////////////////////////////////
  1330.  
  1331. The purpose of this script is to create a 
  1332. public release copy of this project.
  1333. I typically do my development on a live 
  1334. installation which means I have installation
  1335. specific things like passwords, database user,
  1336. administrators (other than default), e-mail 
  1337. addresses, PHP require paths, and other items 
  1338. that are not applicable for fresh installations. 
  1339. This script will first make a copy of my live 
  1340. system to a release directory of your choice,
  1341. then replace various items in the source code
  1342. with generic entries required for public release,
  1343. fresh installations.
  1344.  
  1345. If you are not a developer than it's likely 
  1346. you will not be using this script.
  1347.  
  1348. You optionally specify -s followed by source directory 
  1349. and -t followed by target release directory to run 
  1350. this script in non-interactive mode.
  1351.  
  1352. Please feel free to modify this script to what 
  1353. best fits your needs.
  1354.  
  1355. You can abort at any time by pressing CTRL C.
  1356.  
  1357. /////////////////////////////////////////////////////////////////////////////
  1358.  
  1359. EOF
  1360.  
  1361.     return;
  1362. }
  1363. #----------------------------------------------------------------------------
  1364. #Trim leading and trailing white-spaces from string token.  Pass token by
  1365. #reference only.
  1366. #----------------------------------------------------------------------------
  1367. sub trim {
  1368.  
  1369.     my ($token) = shift;
  1370.  
  1371.     return if (!$token);
  1372.  
  1373.     $$token =~ s/^\s+//;
  1374.     $$token =~ s/\s+$//;
  1375.  
  1376.     return;
  1377. }
  1378. #----------------------------------------------------------------------------
  1379. #----------------------------------------------------------------------------
  1380. @
  1381.  
  1382.  
  1383. 1.8
  1384. log
  1385. @*** empty log message ***
  1386. @
  1387. text
  1388. @d9 1
  1389. a9 1
  1390. #/ Modified:     October 16, 2003
  1391. d230 1
  1392. d232 1
  1393. d288 3
  1394. d292 3
  1395. @
  1396.  
  1397.  
  1398. 1.7
  1399. log
  1400. @*** empty log message ***
  1401. @
  1402. text
  1403. @d9 1
  1404. a9 1
  1405. #/ Modified:     October 01, 2003
  1406. d222 2
  1407. @
  1408.  
  1409.  
  1410. 1.6
  1411. log
  1412. @*** empty log message ***
  1413. @
  1414. text
  1415. @d9 1
  1416. a9 1
  1417. #/ Modified:     September 04, 2003
  1418. d934 1
  1419. a934 1
  1420.     "INSERT INTO administrators VALUES\n" .
  1421. @
  1422.  
  1423.  
  1424. 1.5
  1425. log
  1426. @*** empty log message ***
  1427. @
  1428. text
  1429. @d9 1
  1430. a9 1
  1431. #/ Modified:     August 31, 2003
  1432. d24 1
  1433. a24 1
  1434. #/               If you are not a developer than it's likely 
  1435. d208 1
  1436. a208 1
  1437. "mysql${SLASH}pronunciation.sql" => 0606,
  1438. d235 1
  1439. d303 3
  1440. @
  1441.  
  1442.  
  1443. 1.4
  1444. log
  1445. @*** empty log message ***
  1446. @
  1447. text
  1448. @d9 1
  1449. a9 1
  1450. #/ Modified:     August 21, 2003
  1451. d226 1
  1452. d275 3
  1453. @
  1454.  
  1455.  
  1456. 1.3
  1457. log
  1458. @*** empty log message ***
  1459. @
  1460. text
  1461. @d531 3
  1462. a533 1
  1463. purge_mysql_files("${RELEASE_DIRECTORY}${SLASH}mysql");
  1464. d919 1
  1465. a919 1
  1466. #Purges various mySQL files that should not contain data for fresh installs 
  1467. d921 1
  1468. a921 1
  1469. sub purge_mysql_files {
  1470. d925 26
  1471. d952 30
  1472. @
  1473.  
  1474.  
  1475. 1.2
  1476. log
  1477. @*** empty log message ***
  1478. @
  1479. text
  1480. @d26 4
  1481. a29 1
  1482. #/                 
  1483. d54 1
  1484. d57 4
  1485. d63 3
  1486. a65 1
  1487. while(1) {
  1488. d67 2
  1489. a68 2
  1490.     my ($response) = 
  1491.     promptyn("Would you like to continue?");
  1492. d70 1
  1493. a70 1
  1494.     if (!$response) {
  1495. d72 1
  1496. a72 1
  1497.         print "\nInstallation script terminated!\n\n";
  1498. d74 4
  1499. a77 1
  1500.         exit(0);
  1501. a78 2
  1502.  
  1503.     last;
  1504. d82 4
  1505. d87 2
  1506. a88 2
  1507. my ($INSTALLATION_DIRECTORY) = 
  1508. prompt_installation_directory();
  1509. d90 9
  1510. a98 1
  1511. while(1) {
  1512. d102 3
  1513. a104 4
  1514.     my ($RELEASE_DIRECTORY) =
  1515.     prompt(
  1516.     "What is the name of the release directory " .
  1517.     "to copy the project for release?", 1);
  1518. d106 2
  1519. a107 2
  1520.     #Remove trailing slash for UNIX systems if exists
  1521.     $RELEASE_DIRECTORY =~ s/\/$//;
  1522. d109 2
  1523. a110 2
  1524.     #Remove trailing slash for Windows systems if exists
  1525.     $RELEASE_DIRECTORY =~ s/\\$//; 
  1526. d112 1
  1527. a112 1
  1528.     if (!-d "$RELEASE_DIRECTORY") {
  1529. d114 6
  1530. a119 4
  1531.         show_error(
  1532.         "Release directory ${RELEASE_DIRECTORY} does not exist.\n" .
  1533.         "Manually create this directory or use an existing one\n" .
  1534.         "before continuing.  I'll wait.", 0); 
  1535. d121 2
  1536. a122 2
  1537.         my ($response) =
  1538.         promptyn("Try again?", 1);
  1539. d124 1
  1540. a124 1
  1541.         if (!$response) {
  1542. d126 1
  1543. a126 1
  1544.             print "Script terminated!\n\n";
  1545. d128 25
  1546. a152 1
  1547.             exit(0);
  1548. d154 1
  1549. d156 1
  1550. a156 1
  1551.     } else {
  1552. d158 1
  1553. a158 3
  1554.         my ($response) =
  1555.         promptyn(
  1556.         "Is this release directory ${RELEASE_DIRECTORY} correct?");
  1557. d160 2
  1558. a161 1
  1559.         if (!$response) {
  1560. d163 2
  1561. a164 3
  1562.             $response =
  1563.             promptyn(
  1564.             "Would you like to try another release directory?");
  1565. d166 1
  1566. a166 1
  1567.             goto TRY_AGAIN if ($response);
  1568. d168 5
  1569. a172 2
  1570.             exit(0);
  1571.         }
  1572. d196 3
  1573. d218 1
  1574. d240 1
  1575. d327 1
  1576. a327 1
  1577. my ($subdirectories) = (
  1578. d336 1
  1579. a336 1
  1580. "${INSTALLATION_DIRECTORY}${SLASH}php${SLASH}Dictionary.php";
  1581. d339 1
  1582. a339 1
  1583. "${INSTALLATION_DIRECTORY}${SLASH}php${SLASH}Web.php";
  1584. d354 1
  1585. a354 1
  1586.     $path = 
  1587. d357 2
  1588. a358 1
  1589.     $modified_manifest{$path} = $permissions;
  1590. d360 1
  1591. a360 1
  1592.     print "${path} ";
  1593. d362 3
  1594. a364 1
  1595.     show_error("\nCan't find ${path}", -1) if (!-e "$path");
  1596. d369 23
  1597. a391 1
  1598. #Now copy these files and directories to installation directory 
  1599. d393 1
  1600. d395 1
  1601. d397 2
  1602. d400 21
  1603. d431 1
  1604. a431 1
  1605.     $INSTALLATION_DIRECTORY . 
  1606. d435 1
  1607. a435 1
  1608.     $INSTALLATION_DIRECTORY . 
  1609. d459 1
  1610. a459 1
  1611.     $INSTALLATION_DIRECTORY . 
  1612. d463 1
  1613. a463 1
  1614.     $INSTALLATION_DIRECTORY . 
  1615. d531 1
  1616. a531 1
  1617. purge_mysql_files("${INSTALLATION_DIRECTORY}${SLASH}mysql");
  1618. d537 1
  1619. a537 1
  1620. print "\nInstallation script completed!\n";
  1621. d1060 1
  1622. a1062 1
  1623.     my ($installation_directory) = "";
  1624. d1079 16
  1625. d1101 1
  1626. a1101 1
  1627.             "Enter the directory to make changes:\n", 
  1628. d1123 1
  1629. a1123 1
  1630.             "Enter the directory to make changes: ", 1);
  1631. d1165 1
  1632. a1165 1
  1633.     print "\n\n";
  1634. d1167 23
  1635. a1189 1
  1636.     print "-" x 77;
  1637. d1191 1
  1638. a1191 4
  1639.     print "\n";
  1640.  
  1641.     print <<EOF;
  1642. [BAHASA INDONESIA DICTIONARY DEVELOPER'S MAKE RELEASE SCRIPT]
  1643. d1210 3
  1644. a1212 16
  1645. The purpose of this script is to format the source 
  1646. code and data in such a fashion that it can be 
  1647. released to the general public for distribution.
  1648. This script is really a developer's script.  I do 
  1649. most of development on a live system which means 
  1650. my code contains things like passwords and 
  1651. require paths that are not applicable for a 
  1652. generic release.  This script replaces these 
  1653. items with more generic entries required for 
  1654. clean installation.  If you are not a developer then
  1655. it's likely you will not be using this script.  
  1656.  
  1657. I've tried to make this script as portable 
  1658. as possible.  If for some reason this script 
  1659. fails then you will have to configure the files
  1660. manually.  See documentation for more details. 
  1661. d1214 2
  1662. a1215 2
  1663. Please feel free to modify this script to best 
  1664. fit your needs.
  1665. d1219 2
  1666. a1221 4
  1667.  
  1668.     print "-" x 77;
  1669.  
  1670.     print "\n";
  1671. @
  1672.  
  1673.  
  1674. 1.1
  1675. log
  1676. @*** empty log message ***
  1677. @
  1678. text
  1679. @d9 17
  1680. a25 12
  1681. #/ Modified:     August 20, 2003
  1682. #/ Description:  The purpose of this script is to format the source 
  1683. #/               code and data in such a fashion that it can be 
  1684. #/               released to the general public for distribution.
  1685. #/               This script is really a developer's script.  I do 
  1686. #/               most of development on a live system which means 
  1687. #/               my code contains things like passwords and 
  1688. #/               require paths that are not applicable for a 
  1689. #/               generic release.  This script replaces these 
  1690. #/               items with more generic entries required for 
  1691. #/               clean installation.  If you are not a developer then
  1692. #/               it's likely you will not be using this script.  
  1693. d75 52
  1694. d272 8
  1695. d311 6
  1696. d425 3
  1697. d432 1
  1698. a432 2
  1699. print 
  1700. "\nInstallation script completed!\n";
  1701. d812 1
  1702. a812 3
  1703. #Verifies given token is an e-mail address.  This can be greatly enhanced.
  1704. #It just lloks for @@ and . with spacing before, in between, and after for 
  1705. #the time being.  Should be good enough though.
  1706. d814 1
  1707. a814 1
  1708. sub is_email {
  1709. d816 1
  1710. a816 1
  1711.     my ($token) = shift;
  1712. d818 3
  1713. a820 1
  1714.     return(1) if ($token =~ /\w+\@@\w+\.\w+/);
  1715. d1051 18
  1716. a1068 1
  1717. [BAHASA INDONESIA DICTIONARY DEVELOPER'S MAKE RELEASE]
  1718. @
  1719.  
  1720.