home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / images / ramdisk2.img / usr / lib / perl / lilo < prev    next >
Text File  |  1995-11-01  |  7KB  |  385 lines

  1. # set up lilo -*-perl-*-
  2.  
  3. $liloconf = "";
  4. $append_text = "";
  5.  
  6. sub install_lilo {
  7.  
  8.     local ( $boot );
  9.  
  10.     if (! -e "$fsmount/vmlinuz") {
  11.     &rhs_msgbox("Error",
  12. <<EOM
  13. >
  14. No kernel is installed!
  15. >
  16. LILO can not be configured without a kernel.
  17. >
  18. EOM
  19.             , 60);
  20.     return 0;
  21.     }
  22.  
  23.     if (! &rhs_yesno("LILO",
  24. <<EOM
  25. >
  26. LILO is a Boot Manager which allows you to start
  27. Red Hat Linux directly from your hard
  28. drive.  It will also let you boot other operating systems
  29. on other partitions.
  30. >
  31. If you do not install LILO, you will have to use your boot
  32. diskette or some other boot loader to start the Network
  33. Desktop.
  34. >
  35. Do you want to install LILO?
  36. >
  37. EOM
  38.              , 60)) {
  39.     return 1;
  40.     }
  41.  
  42.     $_ = $root_dev;
  43.     if (/\/dev\/hd.*/) {
  44.     $p1 = "/dev/hda";
  45.     $p2 = "/dev/sda";
  46.     $t1 = "IDE";
  47.     $t2 = "SCSI";
  48.     } else {
  49.     $p2 = "/dev/hda";
  50.     $p1 = "/dev/sda";
  51.     $t2 = "IDE";
  52.     $t1 = "SCSI";
  53.     }
  54.  
  55.     if (! &rhs_menu("LILO Installation",
  56. <<EOM
  57. >
  58. Where do you want to install LILO?
  59. >
  60. EOM
  61.             , 70, 5,
  62.             $p1, "On the MBR of $p1. (The first $t1 hard disk)",
  63.             $p2, "On the MBR of $p2. (The first $t2 hard disk)",
  64.             "/dev/fd0", "On a floppy in /dev/fd0. (Drive A:)",
  65.             $root_dev, "On the superblock of your root Linux partition",
  66.             "other", "On some other partition")) {
  67.     return 1;
  68.     }
  69.     $boot = $dialog_result;
  70.  
  71.     if ($boot eq "other") {
  72.         if (! &rhs_inputbox("LILO Installation",
  73. <<EOM
  74. >
  75. Where do you want to put LILO?
  76. EOM
  77.                 , 50, "/dev/")) {
  78.         return 1;
  79.     }
  80.     $boot = $dialog_result;
  81.     }
  82.  
  83.     $liloconf =
  84. <<EOM
  85. boot=$boot
  86. map=/boot/map
  87. install=/boot/boot.b
  88. prompt
  89. timeout=50
  90. image=/vmlinuz
  91.     label=linux
  92.     root=$root_dev
  93.     read-only
  94. EOM
  95.     ;
  96.  
  97.     &do_append_stuff;
  98.  
  99.     &add_os_to_liloconf;
  100.  
  101.     open(FD, ">$fsmount/etc/lilo.conf");
  102.     print FD $liloconf;
  103.     close(FD);
  104.     
  105.     if (! $express_install) {
  106.     &rhs_textbox("Review /etc/lilo.conf", "$fsmount/etc/lilo.conf", 78, 22);
  107.  
  108.     if (! &rhs_yesno("Notice",
  109. <<EOM
  110. >
  111. If you think that the lilo.conf file you just reviewed
  112. is incorrect, cancel the LILO configuration, start
  113. a shell, fix $fsmount/etc/lilo.conf, and run
  114. lilo -r $fsmount.
  115. >
  116. Continue with LILO configuration?
  117. >
  118. EOM
  119.              , 60)) {
  120.         return 0;
  121.     }
  122.     }
  123.  
  124.     &rhs_infobox("LILO",
  125. <<EOM
  126. >
  127. Installing LILO...
  128. >
  129. EOM
  130.          , 50);
  131.  
  132.     if (&invoke("lilo -r $fsmount")) {
  133.     &rhs_msgbox("Error",
  134. <<EOM
  135. >
  136. Something went wrong running LILO.  Try configuring LILO again.
  137. >
  138. EOM
  139.             , 60);
  140.     return 0;
  141.     } else {
  142.     return 1;
  143.     }
  144. }
  145.  
  146. sub do_append_stuff {
  147.  
  148.     if (&rhs_yesno("LILO Configuration",
  149. <<EOM
  150. >
  151. If you needed to specify hardware parameters on the
  152. LILO command line to boot the install disk, you will
  153. need to add some information to your lilo configuration.
  154. >
  155. Do you need to specify hardware parameters?
  156. >
  157. EOM
  158.            , 60)) {
  159.     if (&rhs_inputbox("LILO Configuration",
  160. <<EOM
  161. >
  162. Enter the parameter below (ex: hd=64,32,202).
  163. This will be added as an append line to your
  164. LILO configuration.
  165. >
  166. EOM
  167.               , 70, $append_text)) {
  168.         $append_text = $dialog_result;
  169.     }
  170.     }
  171.     $liloconf .= 
  172. <<EOM
  173.     append = "$append_text"
  174. EOM
  175.     ;
  176. }
  177.  
  178. sub add_os_to_liloconf {
  179.     local ( %tmpparlist, $dev, $label, $table );
  180.     local ( $p, $r );
  181.  
  182.     while (&rhs_yesno("LILO Configuration",
  183. <<EOM
  184. >
  185. Do you want to indicate another operating system as an option for LILO to start?
  186. EOM
  187.               , 60)) {
  188.     if (! &rhs_menu("LILO Configuration",
  189. <<EOM
  190. >
  191. Which operating system do you wish to add?
  192. >
  193. EOM
  194.             , 60, 4,
  195.             "Linux", "Another Linux partition",
  196.             "DOS", "A DOS partition",
  197.             "OS/2", "An OS/2 partition",
  198.             "Other", "An operating system not listed here")) {
  199.         next;
  200.     }
  201.     
  202.     if ($dialog_result eq "Linux") {
  203.         %tmpparlist = ();
  204.         open(SAVEERR, ">&STDERR");
  205.         open(STDERR, ">/dev/null");
  206.         open(PROC, "fdisk -l |");
  207.         while (<PROC>) {
  208.         if (/^(.{10}).{5}(.{31}).*Linux native$/) {
  209.             $p = $1; $r = $2;
  210.             $p =~ s/\s$//;
  211.             $tmpparlist{$p} = "$r";
  212.         }
  213.         }
  214.         close PROC;
  215.         open(STDERR, ">&SAVEERR");
  216.         if (! &rhs_menua("LILO Configuration",
  217. <<EOM
  218. >
  219. Which Linux partition?
  220. >
  221. >      Device   Begin   Start     End  Blocks
  222. EOM
  223.                  , 54, %tmpparlist)) {
  224.         next;
  225.         }
  226.         $dev = $dialog_result;
  227.         $label = &lilo_getlabel;
  228.         next if ($label eq "");
  229.         $liloconf .=
  230. <<EOM
  231. image=/vmlinuz
  232.     label=$label
  233.     root=$dev
  234.     read-only
  235. EOM
  236.     ;
  237.         &do_append_stuff;
  238.     } elsif ($dialog_result eq "DOS") {
  239.         %tmpparlist = ();
  240.         open(SAVEERR, ">&STDERR");
  241.         open(STDERR, ">/dev/null");
  242.         open(PROC, "fdisk -l |");
  243.         while (<PROC>) {
  244.         if (/^(.{10}).{5}(.{31}).*DOS.*$/) {
  245.             $p = $1; $r = $2;
  246.             $p =~ s/\s$//;
  247.             $tmpparlist{$p} = "$r";
  248.         }
  249.         }
  250.         close PROC;
  251.         open(STDERR, ">&SAVEERR");
  252.         if (! &rhs_menua("LILO Configuration",
  253. <<EOM
  254. >
  255. Which DOS partition?
  256. >
  257. >      Device   Begin   Start     End  Blocks
  258. EOM
  259.                  , 54, %tmpparlist)) {
  260.         next;
  261.         }
  262.         $dev = $dialog_result;
  263.         $label = &lilo_getlabel;
  264.         next if ($label eq "");
  265.         $table = substr($dev, 0, 8);
  266.         $liloconf .=
  267. <<EOM
  268. other=$dev
  269.     label=$label
  270.     table=$table
  271. EOM
  272.     ;
  273.     } elsif ($dialog_result eq "OS/2") {
  274.         %tmpparlist = ();
  275.         open(SAVEERR, ">&STDERR");
  276.         open(STDERR, ">/dev/null");
  277.         open(PROC, "fdisk -l |");
  278.         while (<PROC>) {
  279.         if (/^(.{10}).{5}(.{31}).*DOS.*$/) {
  280.             $p = $1; $r = $2;
  281.             $p =~ s/\s$//;
  282.             $tmpparlist{$p} = "$r";
  283.         }
  284.         if (/^(.{10}).{5}(.{31}).*HPFS.*$/) {
  285.             $p = $1; $r = $2;
  286.             $p =~ s/\s$//;
  287.             $tmpparlist{$p} = "$r";
  288.         }
  289.         }
  290.         close PROC;
  291.         open(STDERR, ">&SAVEERR");
  292.         if (! &rhs_menua("LILO Configuration",
  293. <<EOM
  294. >
  295. Which OS/2 partition?
  296. >
  297. >      Device   Begin   Start     End  Blocks
  298. EOM
  299.                  , 54, %tmpparlist)) {
  300.         next;
  301.         }
  302.         $dev = $dialog_result;
  303.         $label = &lilo_getlabel;
  304.         next if ($label eq "");
  305.         $table = substr($dev, 0, 8);
  306.         $liloconf .=
  307. <<EOM
  308. other=$dev
  309.     label=$label
  310.     table=$table
  311. EOM
  312.     ;
  313.         if ($table eq "/dev/hda") {
  314.         $liloconf .=
  315. <<EOM
  316.     loader = /boot/os2_d.b
  317. EOM
  318.     ;
  319.         }
  320.     } elsif ($dialog_result eq "Other") {
  321.         %tmpparlist = ();
  322.         open(SAVEERR, ">&STDERR");
  323.         open(STDERR, ">/dev/null");
  324.         open(PROC, "fdisk -l |");
  325.         while (<PROC>) {
  326.         if (/^(\/dev\/.{5}).{5}(.{31}).*$/) {
  327.             $p = $1; $r = $2;
  328.             $p =~ s/\s$//;
  329.             $tmpparlist{$p} = "$p";
  330.         }
  331.         }
  332.         close PROC;
  333.         open(STDERR, ">&SAVEERR");
  334.         if (! &rhs_menua("LILO Configuration",
  335. <<EOM
  336. >
  337. Which is your main Linux parition?
  338. >
  339. >      Device   Begin   Start     End  Blocks
  340. EOM
  341.                  , 54, %tmpparlist)) {
  342.         next;
  343.         }
  344.         $dev = $dialog_result;
  345.         $label = &lilo_getlabel;
  346.         next if ($label eq "");
  347.         $table = substr($dev, 0, 8);
  348.         $liloconf .=
  349. <<EOM
  350. other=$dev
  351.     label=$label
  352.     table=$table
  353.     loader=/boot/any_d.b
  354. EOM
  355.     ;
  356.     }
  357.     }
  358.  
  359.     return 1;
  360. }
  361.  
  362. sub lilo_getlabel {
  363.  
  364.     if (! &rhs_inputbox("LILO Configuration",
  365. <<EOM
  366. >
  367. Enter a single word as a name for this system. A
  368. LILO: prompt appears when you start your computer;
  369. this is the name that you will type to start this
  370. operating system.
  371. EOM
  372.             , 60, "")) {
  373.     return "";
  374.     }
  375.  
  376.     return $dialog_result;
  377. }
  378.  
  379.  
  380. ##########################
  381. 1;
  382.