[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#747515: grub-installer: Please add a grub-installer/timeout installer option



Package: grub-installer
Version: 1.94
Severity: minor
Tags: patch

Please add a grub-installer/timeout Debian installer option to change the grub
timeout. I want to reduce the grub timeout to 2 seconds without writing a
preseed/late_command rules for it. This option is already implemented in
Ubuntu's grub-installer package. You might want to adopt their modification. The
part of the Ubuntu modification is attached as patch against git head.

-- 
Benjamin Drung
System Developer

ProfitBricks GmbH - The IaaS-Company
Greifswalder Str. 207
D - 10405 Berlin

Mail: benjamin.drung@profitbricks.com
Fax:  +49 30 577 008 598
URL:  http://www.profitbricks.com

Sitz der Gesellschaft: Berlin.
Registergericht: Amtsgericht Charlottenburg, HRB 125506 B.
Geschäftsführer: Andreas Gauger, Achim Weiss.
diff --git a/grub-installer b/grub-installer
index be63e9e..f6011f3 100755
--- a/grub-installer
+++ b/grub-installer
@@ -1059,6 +1059,42 @@ if [ "$grub_version" = grub ]; then
 	fi
 fi
 
+if db_get grub-installer/timeout
+then
+	# Check whether it's a number
+	if [ "$RET" -eq "$RET" ] 2> /dev/null
+	then
+		timeout="$RET"
+	fi
+fi
+
+if [ -s /tmp/os-probed ]; then
+	# Other operating systems are installed, so show the menu by default
+	# and raise the timeout.
+	if [ "$grub_version" = grub ]; then
+		sed -i 's/^hiddenmenu[[:space:]]*$/#hiddenmenu/;
+			s/^\(timeout[[:space:]][[:space:]]*\).*/\110/' \
+			$ROOT/boot/grub/menu.lst
+	else
+		sed -i 's/^GRUB_HIDDEN_TIMEOUT=.*/#&/;
+			s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=10/' \
+			$ROOT/etc/default/grub
+		update_grub # propagate to grub.cfg
+	fi
+elif [ -n "$timeout" ]; then
+	# Leave a slight delay
+	if [ "$grub_version" = grub ]; then
+		sed -i 's/^hiddenmenu[[:space:]]*$/#hiddenmenu/;
+			s/^\(timeout[[:space:]][[:space:]]*\).*/\1'$timeout'/' \
+			$ROOT/boot/grub/menu.lst
+	else
+		sed -i 's/^GRUB_HIDDEN_TIMEOUT=.*/#&/;
+			s/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT='$timeout'/' \
+			$ROOT/etc/default/grub
+		update_grub # propagate to grub.cfg
+	fi
+fi
+
 if [ "$serial" ] ; then
 	# Modify menu.lst so _grub_ uses serial console.
 	case $grub_package in

Reply to: