home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- # $Id: lilo-ins.pl,v 1.8 1999/07/22 11:11:28 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";
- $initrd = "" unless $thisroot =~ m,^/dev/(?:ida/|rd/|sd),;
-
- $secret = "no";
- $otherimg = "";
- # Write it out 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;
- }
-
- print "image = /boot/vmlinuz$pc97-$insimage-modular\n";
- print "\tlabel = linux\n";
- print "\troot = $thisroot\n" unless ($thisroot eq "");
- print "\tvga = 274\n";
- print "\tread-only\n";
- print "\tappend = \"debug=2$apic\"\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*linux\b/\1 = oldlinux/;
- print;
- }
- close ELC;
-
- chmod 0600, "/proc/self/fd/1" unless ($secret eq "no");
-