hd.setup 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/bin/perl
  2. #
  3. # Copyright (C) 1994 Carl Streeter <streeter@cae.wisc.edu>
  4. #
  5. # this script is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2,
  8. # or (at your option) any later version.
  9. #
  10. # this script is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public
  16. # License along with this script; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. $vardir = $ARGV[0];
  19. print "Is the partition to install from mounted? [Y] ";
  20. $ans = <STDIN>;
  21. if ($ans =~ /^[Nn]/) {
  22. do {
  23. do {
  24. print "Which device should I mount? /dev/";
  25. $drive = <STDIN>;
  26. chop $drive;
  27. $drive =~ tr/[A-Z]/[a-z]/;
  28. } while (! -b "/dev/$drive");
  29. $mpoint = "/mnt";
  30. do {
  31. print "Where should I mount it? (Please use full path) [$mpoint] ";
  32. $newmp = <STDIN>;
  33. chop $newmp;
  34. $mpoint = $newmp if ($newmp !~ /^$/);
  35. } while (($mpoint !~ ?^/?) || (! -d $mpoint));
  36. print "These filesystems are available:";
  37. open(FILESYS, "</proc/filesystems");
  38. $systems = " ";
  39. while (<FILESYS>) {
  40. next if /^nodev/;
  41. chop;
  42. /(\w+)/;
  43. $systems .= "$1 ";
  44. }
  45. print "$systems\n";
  46. do {
  47. print "What filesystem is the partition to mount? [ext2] ";
  48. $filesys = <STDIN>;
  49. chop $filesys;
  50. $filesys = "ext2" if ($filesys =~ /^$/);
  51. $filesys =~ tr/[A-Z]/[a-z]/;
  52. } while ($systems !~ /\s$filesys\s/);
  53. do {
  54. print "Any other options for mount? ";
  55. print "(eg. '-o ro' for cdrom, must start with '-') [] ";
  56. $opts = <STDIN>;
  57. chop $opts;
  58. } while ($opts !~ /^$/ && $opts !~ /^\-/);
  59. $command = "/bin/mount -t $filesys $opts /dev/$drive $mpoint";
  60. print "I will now run \"$command\"\n";
  61. # system("$command");
  62. } while ($?);
  63. } # I never knew how hard I could make it to mount a drive.
  64. # Assumedly, the drive is now mounted
  65. open (STATUS, ">$vardir/methods/hd/hd.status") || die "Can't open hd.status";
  66. do {
  67. print "What is the full path to the 'available' file?\n";
  68. print "This file is found as Packages on the ftp site and CDROM";
  69. print "Use 'none' if you don't have one.";
  70. $avail = <STDIN>;
  71. chop $avail;
  72. } while (! -f $avail || $avail !~ ?^/? || $avail !~ /none/);
  73. do{
  74. print "What is the full path to the base directory ";
  75. print "containing the .deb packages?\n";
  76. $debpath = <STDIN>;
  77. chop $debpath;
  78. } while(! -d $debpath || $debpath !~ ?^/?);
  79. print STATUS "AVAIL: $avail\n";
  80. print STATUS "DEBDIR: $debpath\n";
  81. close (STATUS);
  82. exit (0);