From 3bb366c6b9334969177e760779dbe6df0f641312 Mon Sep 17 00:00:00 2001
From: Ludovic Pouzenc <ludovic.pouzenc@mines-albi.fr>
Date: Thu, 28 Jun 2018 10:21:38 +0200
Subject: Eviter les clonages de master en boucle si le BIOS redémarre sur
 eficast
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 make-boot-image.sh | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/make-boot-image.sh b/make-boot-image.sh
index b8654b9..8852256 100755
--- a/make-boot-image.sh
+++ b/make-boot-image.sh
@@ -365,13 +365,23 @@ echo_color() {
 	[ "x$4" == "xversion" ] && echo " (eficast v"$(cat /etc/eficast_version)")" || echo
 }
 
-# if no args, print colored message, wait 10 sec and reboot
+# no args, print colored message, wait 10 sec and reboot
 eficast_end() {
-	( sfx_success ; touch /run/nosound ) &
-	message reboot "in 10s"
+	echo -e "\e]2;eficast_end\007"	# Term title (tmux), intentionnal carriage return
 	echo_color white green "----- EFICAST end of execution  ------"
-	read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time...'
-	reboot
+	( sfx_success ; touch /run/nosound ) &
+	[ -r touch /run/eficast_end ] && action=$(cat /run/eficast_end)
+	case $action in
+		poweroff) 	read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time for poweroff...'
+				poweroff
+				;;
+		reboot)		read -t10 -p 'Ctrl+C to have a shell, Enter to skip wait time for reboot...'
+				reboot
+				;;
+		*)		echo "Dropping a shell (consider putting poweroff or reboot in /run/eficast_end)"
+				PS1='\h:\w# ' HOME='/root/' /bin/busybox sh
+				;;
+	esac
 }
 
 # note : rcS rescue_shell is slighly different because most of the env is not ready in rcS
-- 
cgit v1.2.3