home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / images / ramdisk2-beta.img / usr / lib / perl / ftp < prev    next >
Text File  |  1995-12-04  |  4KB  |  211 lines

  1. # -*-perl-*-
  2.  
  3. $ftp_site = "";
  4. $ftp_dir = "";
  5. $ftp_configured = 0;
  6. $ftp_series_file = "/tmp/series";
  7. @ftp_spec = ();
  8.  
  9. sub ftp_init {
  10.     require "/usr/lib/rhs/rpm/rpmftp.pl";
  11.  
  12.     if (! $net_up) {
  13.     &make_net_up;
  14.     if (! $net_up) {
  15.         &rhs_msgbox("Error",
  16. <<EOM
  17. >
  18. The network must be properly configured for an
  19. FTP install to work.
  20. >
  21. EOM
  22.             , 60);
  23.         return 0;
  24.     }
  25.     }
  26.  
  27.     $ftp_configured = 0;
  28.  
  29.     if (! &configure_ftp) {
  30.     return 0;
  31.     }
  32.     while (! &test_ftp) {
  33.     if (! &rhs_menu("FTP Configuration",
  34. <<EOM
  35. >
  36. FTP initialization failed.
  37. >
  38. The following error was returned:
  39. >
  40. $ftp_error
  41. >
  42. EOM
  43.             , 60, 2,
  44.             "Configure", "Reconfigure FTP",
  45.             "Give Up", "Just forget it")) {
  46.         return 0;
  47.     }
  48.     if ($dialog_result eq "Give Up") {
  49.         return 0;
  50.     }
  51.     &configure_ftp;
  52.     }
  53.  
  54.     $ftp_configured = 1;
  55.     return 1;
  56. }
  57.  
  58. sub test_ftp {
  59.  
  60.     &rhs_infobox("FTP Configuration",
  61. <<EOM
  62. >
  63. Testing ftp://$ftp_site$ftp_dir
  64. >
  65. EOM
  66.          , 60);
  67.  
  68.     if (! &get_ftp_file("RedHat/base/series", $ftp_series_file)) {
  69.     return 0;
  70.     }
  71.  
  72.     return 1;
  73. }
  74.  
  75. sub get_ftp_file {
  76.     local ( $remote, $local ) = @_;
  77.  
  78.     return &ftp_file("ftp://$ftp_site$ftp_dir/$remote", $local);
  79. }
  80.  
  81. sub get_ftp_dir {
  82.     local ( $dir ) = @_;
  83.     local ( @result );
  84.  
  85.     @result = &ftp_dir("ftp://$ftp_site$ftp_dir/$dir");
  86.     return @result;
  87. }
  88.  
  89. sub configure_ftp {
  90.  
  91.     if (! &rhs_menu("FTP Configuration",
  92. <<EOM
  93. Choose one of the following Official Red Hat Mirror sites.
  94. EOM
  95.             , 75, 6,
  96.             "ftp://ftp.pht.com/pub/linux/redhat/ftp-install", "",
  97.             "ftp://ftp.caldera.com/pub/mirrors/redhat/ftp-install", "",
  98.             "ftp://ftp.cms.uncwil.edu/linux/redhat/ftp-install", "",
  99.             "ftp://ftp.wilmington.net/linux/redhat/ftp-install", "",
  100.             "ftp://ftp.lasermoon.co.uk/pub/distributions/RedHat/ftp-install", "",
  101.             "Other", ""
  102.             )) {
  103.     return 0;
  104.     }
  105.  
  106.     if ($dialog_result ne "Other") {
  107.     $dialog_result =~ m|ftp://([^/]*)(.*)|;
  108.     
  109.     $ftp_site = $1;
  110.     $ftp_dir = $2;
  111.     } else {
  112.     if (! &rhs_inputbox ( "FTP Configuration",
  113. <<EOM
  114. >
  115. Enter the FTP host name.
  116. >
  117. EOM
  118.                  , 60, $ftp_site)) {
  119.         return 0;
  120.     }
  121.     $ftp_site = $dialog_result;
  122.     if (! &rhs_inputbox ( "FTP Configuration",
  123. <<EOM
  124. >
  125. Enter the path to the Red Hat files on $ftp_site.
  126. >
  127. EOM
  128.                  , 60, $ftp_dir)) {
  129.         return 0;
  130.     }
  131.     $ftp_dir = $dialog_result;
  132.     if ($ftp_dir =~ m|^[^/]|) {
  133.         $ftp_dir = "/" . $ftp_dir;
  134.     }
  135.  
  136. #    if (&rhs_yesno("FTP Configuration",
  137. #<<EOM
  138. #>
  139. #If you are behind a firewall, you may need to log in as
  140. #something other than anonymous, and give a real password.
  141. #>
  142. #Do you need to do this?
  143. #>
  144. #EOM
  145. #               , 60)) {
  146. #        if (! &rhs_inputbox ( "FTP Configuration",
  147. #<<EOM
  148. #>
  149. #Enter the login name for your FTP server
  150. #>
  151. #EOM
  152. #                 , 60, $rpm_ftp_login)) {
  153. #        return 0;
  154. #        }
  155. #        $rpm_ftp_login = $dialog_result;
  156. #        if (! &rhs_inputbox ( "FTP Configuration",
  157. #<<EOM
  158. #>
  159. #Enter the password for your FTP server
  160. #>
  161. #THIS PASSWORD WILL SHOW IN THE SCREEN IN CLEAR TEXT!
  162. #>
  163. #EOM
  164. #                 , 60, $rpm_ftp_password)) {
  165. #        return 0;
  166. #        }
  167. #        $rpm_ftp_password = $dialog_result;
  168. #    }
  169.  
  170.     }
  171.  
  172.     return 1;
  173. }
  174.  
  175. sub ftp_get_file_list {
  176.     local (*files) = @_;
  177.  
  178.     if (! $ftp_configured) {
  179.     &rhs_msgbox("FTP Install", "\nFTP is not configured!\nYou will" .
  180.         "have to configure it and return to this stage.\n\n", , 70);
  181.     return 0;
  182.     }
  183.  
  184.     &rhs_infobox("FTP Install",
  185. <<EOM
  186. >
  187. Getting list of packages from FTP site.
  188. >
  189. EOM
  190.          , 60);
  191.  
  192.     @files = &get_ftp_dir("RedHat/RPMS");
  193.     if ($ftp_error) {
  194.     &rhs_msgbox("FTP Install",
  195. <<EOM
  196. >
  197. FTP failed!
  198. >
  199. Error returned: $ftp_error
  200. >
  201. EOM
  202.             , 70);
  203.     return 0;
  204.     }
  205.  
  206.     return 1;
  207. }
  208.  
  209. ###########
  210. 1;
  211.