#!/usr/local/bin/perl # install.cgi # Install the GRUB boot loader require './grub-lib.pl'; &error_setup($text{'install_err'}); &ReadParse(); # Find out which partition the menu file is on @st = stat($config{'menu_file'}); &foreign_require("mount", "mount-lib.pl"); foreach $d (sort { length($a->[0]) <=> length($b->[0]) } &mount::list_mounted()) { @fst = stat($d->[0]); $mount = $d->[0] if ($fst[0] == $st[0]); } $mount =~ s/\/$//; $menu_file = $config{'menu_file'}; $menu_file =~ s/^\Q$mount\E//; # Ask grub where the menu.lst file is $temp = &transname(); open(TEMP, ">$temp"); print TEMP "find $menu_file\n"; close(TEMP); open(GRUB, "$config{'grub_path'} --batch <$temp |"); while() { if (/find\s+(\S+)/ && $1 eq $menu_file) { $out .= $_; $_ = ; if (/^\s*(\(\S+\))/) { $root = $1; } } $out .= $_; } close(GRUB); unlink($temp); if (!$root || $?) { # Didn't find it! &error($text{'install_efind'},"
",$out,"
"); } # Setup on the chosen device &ui_print_header(undef, $text{'install_title'}, ""); print &text('install_desc', $in{'dev'}, "root $root", "setup $config{'install'}"),"

\n"; print "

";
open(TEMP, ">$temp");
print TEMP "root $root\n";
print TEMP "setup $config{'install'}\n";
close(TEMP);
open(GRUB, "$config{'grub_path'} --batch <$temp |");
while() {
	if (/\d+\s+sectors\s+are\s+embedded/i) {
		$embedded++;
		}
	elsif (/error/) {
		$error++;
		}
	print &html_escape($_);
	}
close(GRUB);
print "
\n"; if (!$embedded || $? || $error) { print "$text{'install_failed'}

\n"; } else { print "$text{'install_ok'}

\n"; } &webmin_log("install"); &ui_print_footer("", $text{'index_return'});