#!/usr/bin/perl
# $Id: lilo-del.pl,v 1.6 1999/07/22 11:11:19 duwe Exp $

$delimage = "\Q$ARGV[0]";

open (ELC, "</etc/lilo.conf") || die;

$elc = "";

$i = 0;

# read /etc/lilo.conf line by line, assembling it into "entries"
while (<ELC>) {
  m/^\s*(?:image|other)\s*=/ && $i++; # advance to a new entry
  $elc[$i] .= $_;
}
close ELC;

$secret = "no";

# Now write out all entries but the ones that reference the named kernel.
while (@elc) {
  if ($elc[0] !~
      m,^\s*image\s*=\s*/boot/vmlinuz(?:-pc97)?-$delimage-modular\s,sm) {
    print $elc[0];
    ($elc[0] =~ m,^\s*password\s*=,sim) && ($secret = "yes");
  }
  shift @elc;
}

chmod 0600, "/proc/self/fd/1" unless ($secret eq "no");
