#!/usr/bin/perl # This script takes in two parameters. The first is the # full path to the kernel image. The second is the full # path to the initial ramdisk image die unless ($#ARGV == 1); $Root = ""; open (LILO,"/etc/lilo.conf"); while ($ThisLine = ) { # Rename current image named 'linux' to 'linux-old' $ThisLine =~ s/label\s*=\s*linux22$/label=linux22-old/; $ThisLine =~ s/^default=.*$/default=linux22/; # Find out the root partition unless ($Root) { if ($ThisLine =~ /root\s*=\s*(.+)$/) { $Root = $1; } } # Store config line... push @conf, $ThisLine; } close (LILO); $Done = 0; open (LILO,">/etc/lilo.conf"); foreach $ThisLine (@conf) { if ($ThisLine =~ /^image\s*=/) { unless ($Done) { # Time to insert our new block... print LILO "image=$ARGV[0]\n"; print LILO "\tlabel=linux22\n"; print LILO "\troot=$Root\n"; print LILO "\tinitrd=$ARGV[1]\n"; print LILO "\tread-only\n"; $Done = 1; } } print LILO $ThisLine; } close (LILO);