home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 February / OpenLinux 2.3 CD.iso / live / usr / libexec / kernel / lilo-ins.pl < prev   
Encoding:
Perl Script  |  1999-08-10  |  1.5 KB  |  54 lines

  1. #!/usr/bin/perl
  2. # $Id: lilo-ins.pl,v 1.8 1999/07/22 11:11:28 duwe Exp $
  3.  
  4. $nam = $insimage = $ARGV[0];
  5. $nam =~ s/\.//g;
  6.  
  7. open (ELC, "</etc/lilo.conf") || die;
  8.  
  9. # Determine if this is a true Pentium or better and we can use that kernel,
  10. # and if we need to disable SMP (for AMD, Cyrix, ...). Set failsafe defaults.
  11. $apic = " noapic nosmp";
  12. $pc97 = "";
  13. if (open(CI, "</proc/cpuinfo")) {
  14.   while(<CI>) {
  15.     m/^\s*flags\s*:.* fpu\b.* tsc\b/ && ($pc97 = "-pc97");
  16.     m/^\s*flags\s*:.* apic\b/ && ($apic = "");
  17.   }
  18.   close CI;
  19. }
  20.  
  21. # Now let's see whether we need an initrd for the current root.
  22. $thisroot = `/usr/sbin/rdev`;
  23. $thisroot =~ s/\s.*$//sm;
  24. $initrd = "\tinitrd = /boot/initrd-$insimage.gz\n";
  25. $initrd = "" unless $thisroot =~ m,^/dev/(?:ida/|rd/|sd),;
  26.  
  27. $secret = "no";
  28. $otherimg = "";
  29. # Write it out just before the first "image=" entry (if there is one)
  30. while (<ELC>) {
  31.   if (m/^\s*password\s*=/i) { $secret = "yes"; }
  32.   if (m/^\s*image\s*=/) { $otherimg = $_; last; }
  33.   print;
  34. }
  35.  
  36. print "image = /boot/vmlinuz$pc97-$insimage-modular\n";
  37. print "\tlabel  = linux\n";
  38. print "\troot   = $thisroot\n" unless ($thisroot eq "");
  39. print "\tvga    = 274\n";
  40. print "\tread-only\n";
  41. print "\tappend = \"debug=2$apic\"\n$initrd\n";
  42.  
  43. # and now dump the remaining input file
  44. print $otherimg;
  45. while (<ELC>) {
  46.   if (m/^\s*password\s*=/i) { $secret = "yes"; }
  47.   s/(label|alias)\s*=\s*oldlinux\b/\1 = cruft$$/; # the best we can do
  48.   s/(label|alias)\s*=\s*linux\b/\1 = oldlinux/;
  49.   print;
  50. }
  51. close ELC;
  52.  
  53. chmod 0600, "/proc/self/fd/1" unless ($secret eq "no");
  54.