home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- # $Id: lilo-ins.pl,v 1.14 2000/07/11 12:37:36 duwe Exp $
-
- $nam = $insimage = $ARGV[0];
- $nam =~ s/\.//g;
-
- open (ELC, "</etc/lilo.conf") || die;
-
- # Determine if this is a true Pentium or better and we can use that kernel,
- # and if we need to disable SMP (for AMD, Cyrix, ...). Set failsafe defaults.
- $apic = " noapic nosmp";
- $pc97 = "";
- if (open(CI, "</proc/cpuinfo")) {
- while(<CI>) {
- m/^\s*flags\s*:.* fpu\b.* tsc\b/ && ($pc97 = "-pc97");
- m/^\s*flags\s*:.* apic\b/ && ($apic = "");
- }
- close CI;
- }
-
- # Now let's see whether we need an initrd for the current root.
- $thisroot = `/usr/sbin/rdev`;
- $thisroot =~ s/\s.*$//sm;
- $initrd = "\tinitrd = /boot/initrd-$insimage.gz\n";
- ($thisroot =~ m,^/dev/hd, ) && ( $initrd = "" );
-
- $secret = "no";
- $otherimg = "";
- # Seek forward to just before the first "image=" entry (if there is one)
- while (<ELC>) {
- if (m/^\s*password\s*=/i) { $secret = "yes"; }
- if (m/^\s*image\s*=/) { $otherimg = $_; last; }
- print;
- }
-
- $vga = "";
- if (open(ESC, "</etc/system.cnf")) {
- while(<ESC>) {
- m/^\s*CONF_GRAPHIC_CARD1_VESAMODE\s*=\s*"?(\w+)/ && ($vga = "$1");
- }
- close ESC;
- }
- $vga = "274" if ($vga eq "");
- print "image = /boot/vmlinuz$pc97-$insimage-modular\n";
- print "\tlabel = Linux\n";
- print "\troot = $thisroot\n" unless ($thisroot eq "");
- print "\tvga = $vga\n";
- print "\tread-only\n";
- print "\tappend = \"quiet$apic console=ttyS3,9600 apm=off acpi=no-idle\"\n$initrd\n";
-
- # and now dump the remaining input file
- print $otherimg;
- while (<ELC>) {
- if (m/^\s*password\s*=/i) { $secret = "yes"; }
- s/(label|alias)\s*=\s*oldlinux\b/\1 = cruft$$/; # the best we can do
- s/(label|alias)\s*=\s*desktop.lx\s*linux\b/\1 = oldlinux/i;
- print;
- }
- close ELC;
-
- chmod 0600, "/proc/self/fd/1" unless ($secret eq "no");
-