Commit cdd73465 authored by David Johnson's avatar David Johnson

If no lilo, but grub, adjust grub config file to boot a linkdelay kernel

if possible.
parent b3bc5c12
......@@ -75,8 +75,8 @@ my $KERNELJAIL = "jail";
my $KERNELLDELAY= "linkdelay";
my $TMDELMAP = TMDELMAP; # Really comes from libloc.
my $TC = "/usr/local/sbin/tc"; # This is the working version!
my $IPTABLES = "/usr/local/sbin/iptables"; # This is the working version!
my $TC = "/sbin/tc"; # This is the working version!
my $IPTABLES = "/sbin/iptables"; # This is the working version!
# This should never happen!
if (REMOTE() || MFS()) {
......@@ -222,8 +222,8 @@ sub LinkDelaySetup()
#
# NB: Linux doesn't support floats either, and wants usecs.
#
$delay = int($delay + 0.5) * 1000;
$rdelay = int($rdelay + 0.5) * 1000;
#$delay = int($delay + 0.5) * 1000;
#$rdelay = int($rdelay + 0.5) * 1000;
#
# Sweet! 'k' as in "kbit" means 1024, not 1000, to tc.
......@@ -278,13 +278,10 @@ sub LinkDelaySetup()
print DEL "ifconfig $iface txqueuelen $queue\n";
print DEL "$TC qdisc add dev $iface handle $pipeno root ";
print DEL "plr $plr\n";
print DEL "netem loss ${plr}% delay ${delay}ms\n";
print DEL "$TC qdisc add dev $iface handle ". ($pipeno+10) ." ";
print DEL "parent ${pipeno}:1 delay usecs $delay\n";
print DEL "$TC qdisc add dev $iface handle ". ($pipeno+20) ." ";
print DEL "parent ". ($pipeno+10) .":1 htb default 1\n";
print DEL "parent ". ($pipeno) .":1 htb default 1\n";
if ($bandw != 0) {
print DEL "$TC class add dev $iface classid ". ($pipeno+20) .":1 ";
......@@ -391,10 +388,89 @@ sub checkkernel($)
# XXX only works for linkdelay right now
return if ($kernel ne $KERNELLDELAY);
my $lilocmd = "/sbin/lilo -D $kernel";
if (system ($lilocmd)) {
print STDERR "Error ($?) running '$lilocmd'\n";
return 1;
if (!($kernvers =~ /$kernel/i)) {
# XXX only works for linkdelay right now
return if ($kernel ne $KERNELLDELAY);
# check if we have lilo or grub:
my $islilo = 0;
if (-e "/etc/lilo.conf" && -x "/sbin/lilo") {
$islilo = 1;
}
elsif (-e "/boot/grub/grub.conf" || -e "/boot/grub/menu.lst") {
$isgrub = 1;
}
else {
print STDERR "Error: neither grub nor lilo seems to be " .
"installed!\n";
return 1;
}
if ($islilo) {
my $lilocmd = "/sbin/lilo -D $kernel";
if (system ($lilocmd)) {
print STDERR "Error ($?) running '$lilocmd'\n";
return 1;
}
}
elsif ($isgrub) {
# we could have had both grub and lilo detected, but if lilo
# was installed, we just blew away the first sector, so fixing up
# grub becomes rather pointless.
my $file = "/boot/grub/grub.conf";
if (!(-e $file)) {
$file = "/boot/grub/menu.lst";
if (!(-e $file)) {
print STDERR "Error: could not find any grub " .
"conf files!\n";
return 1;
}
}
my @lines;
open(FD,$file) or die "could not open $file!";
@lines = <FD>;
close(FD);
my $i = 0;
my $found = 0;
foreach my $line (@lines) {
if ($line =~ /^\s*Title\s+/i) {
if ($line =~ /$kernel/i) {
$found = 1;
last;
}
++$i;
}
}
if (!$found) {
print STDERR "Error: could not find a linkdelay kernel " .
" in $file!\n";
return 1;
}
my $idx = $i;
$found = 0;
for ($i = 0; $i < scalar(@lines); ++$i) {
if ($lines[$i] =~ /\s*default\s*=\s*(\d+)/i) {
$lines[$i] = "default=$idx\n";
$found = 1;
# note that we don't just quit -- there could be more.
}
}
if (!$found) {
@lines = ("default=$idx\n",@lines);
}
# rewrite it.
open(FD,">$file") or die "could not open $file!";
foreach my $line (@lines) {
print FD $line;
}
}
system("sync");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment