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

Re: [PATCH] use dialog (when available) for shutdown/reboot message



Hi all,

I just updated the patch. It now detects the current action (reboot or
shutdown) and shows the correct message to the user depending on this
context.

Greetings

Ronny Standtke

-- 
Ronny Standtke                 Fachhochschule Nordwestschweiz
Dozent Medienpädagogik / ICT   Pädagogische Hochschule
Telefon: +41 32 627 92 47      Obere Sternengasse 7
Mobil  : +41 79 786 81 82      4502 Solothurn
diff --git a/debian/live-initramfs.init b/debian/live-initramfs.init
index 4cf767a..7cad468 100644
--- a/debian/live-initramfs.init
+++ b/debian/live-initramfs.init
@@ -134,18 +134,33 @@ do_stop ()
 	if [ -z ${QUICKREBOOT} ]
 	then
 		# TODO: i18n
-		BOOT_DEVICE="$(get_boot_device)"
+		# determine current action (do we shutdown or reboot?)
+		# this info is used later for the messages prompted to the user
+		if [ "${RUNLEVEL}" = "0" ]
+		then
+			ACTION="Shutdown"
+			INFINITIVE="shutdown"
+			FUTURE="shut down"
+		elif [ "${RUNLEVEL}" = "6" ]
+		then
+			ACTION="Reboot"
+			INFINITIVE="reboot"
+			FUTURE="rebooted"
+		else
+			log_warning_msg "Unsupported runlevel!"
+		fi
 
+		BOOT_DEVICE="$(get_boot_device)"
 		if device_is_USB_flash_drive ${BOOT_DEVICE}
 		then
 			# do NOT eject USB flash drives!
 			# otherwise rebooting with most USB flash drives
 			# failes because they actually remember the
 			# "ejected" state even after reboot
-			MESSAGE="Please remove the USB flash drive"
+			MESSAGE="You may now savely remove the USB flash drive and"
 		else
 			# ejecting is a very good idea here
-			MESSAGE="Please remove the disc, close the the tray (if any)"
+			MESSAGE="Please remove the disc, close the the tray (if any) and"
 
 			if [ -x /usr/bin/eject ]
 			then
@@ -154,19 +169,31 @@ do_stop ()
 
 			[ "$prompt" ] || return 0
 		fi
+		PRESS_ENTER="press ENTER to ${INFINITIVE} the system"
 
 		stty sane < /dev/console
 
-		echo -n -e "\n\n${MESSAGE} and press ENTER to continue:" > /dev/console
+		if [ -x /usr/bin/dialog ]
+		then
+			MESSAGE="${MESSAGE} ${PRESS_ENTER}.\n\n(If you do nothing, the system will be automatically ${FUTURE} when the timer runs out.)"
+			dialog --nocancel --backtitle "${ACTION}" --ok-label "${ACTION}" --pause "${MESSAGE}" 15 40 30
+		else
+			echo -n -e "\n\n${MESSAGE}\n${PRESS_ENTER}:" > /dev/console
+			READX="true"
+		fi
 
 		if [ -x /sbin/usplash_write ]
 		then
 			/sbin/usplash_write "TIMEOUT 86400"
 			/sbin/usplash_write "TEXT-URGENT ${MESSAGE}"
 			/sbin/usplash_write "TEXT-URGENT and press ENTER to continue"
+			READX="true"
 		fi
 
-		read x < /dev/console
+		if [ -n "${READX}" ]
+		then
+			read x < /dev/console
+		fi
 	fi
 }
 

Reply to: