mirror of
https://gitlab.postmarketos.org/postmarketOS/pmaports.git
synced 2025-07-13 00:29:49 +03:00
postmarketos-initramfs: prevent entering debug shell twice
It is sometimes possible that we spawn multiple shells on the same TTY when boot fails and the user tries using some functions like mount_subpartitions which call fail_halt_boot() on failure. Add some global state to track this and avoid entering the debug shell if already entered. Signed-off-by: Casey Connolly <kcxt@postmarketos.org>
This commit is contained in:
parent
1e4a82767d
commit
5c8bd91f9f
2 changed files with 31 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
# Maintainer: Casey Connolly <kcxt@postmarketos.org>
|
# Maintainer: Casey Connolly <kcxt@postmarketos.org>
|
||||||
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
|
# Co-Maintainer: Clayton Craft <clayton@craftyguy.net>
|
||||||
pkgname=postmarketos-initramfs
|
pkgname=postmarketos-initramfs
|
||||||
pkgver=3.8.4
|
pkgver=3.8.5
|
||||||
pkgrel=0
|
pkgrel=0
|
||||||
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
|
pkgdesc="Base files for the postmarketOS initramfs / initramfs-extra"
|
||||||
url="https://postmarketos.org"
|
url="https://postmarketos.org"
|
||||||
|
@ -109,7 +109,7 @@ sha512sums="
|
||||||
c0233d22858a5901db64e1d2fe1f6d39a2e2cfd1b94a10932483f55fed9461e9b8aa2d73b154b9d99a7a8b49ee02abfbddfe917ce0c6d7576601ba2668589c01 00-initramfs-base.files
|
c0233d22858a5901db64e1d2fe1f6d39a2e2cfd1b94a10932483f55fed9461e9b8aa2d73b154b9d99a7a8b49ee02abfbddfe917ce0c6d7576601ba2668589c01 00-initramfs-base.files
|
||||||
d0f35562365756d93066ce45924d17fb347b54095179c3262daa2f073e12743505cd5d9372ad30485915ca754d95a8edba9a74314e7949e0b3cf6978a87d03a5 00-initramfs-extra-base.files
|
d0f35562365756d93066ce45924d17fb347b54095179c3262daa2f073e12743505cd5d9372ad30485915ca754d95a8edba9a74314e7949e0b3cf6978a87d03a5 00-initramfs-extra-base.files
|
||||||
7ec5e9596b27f48d3abe51bc92d70d9708479b5e7df5fa9903d9e58f5945f2a7de5c390cc2d82842b899dfc9fa9bdb2b84b29cc1daf5d534861cf1324628d57b init.sh
|
7ec5e9596b27f48d3abe51bc92d70d9708479b5e7df5fa9903d9e58f5945f2a7de5c390cc2d82842b899dfc9fa9bdb2b84b29cc1daf5d534861cf1324628d57b init.sh
|
||||||
8948bb1bb17cf707790e0dc91a51a1c1293b883deea08137bbb92b19584282173d5ba7bb4481daafe5d84ee300808c5e9b23fae1256b64f4c2c7ef192b7a97a7 init_functions.sh
|
89b5238b044aa3bee74d36d4a17c8af08d55e66531b528901e5948a813bb9be4a4f1383111c02d67198fd75d8d8d1ab9f3deffc63db1518642ab0ff4f91a00d5 init_functions.sh
|
||||||
7cf0b1e7511bf289a90ed6cf3190a78119be46e2d885ee3af2dd1fb048eaac7c0875bfd74cc576dd062d17c5fae23f7e721b86f8d71d2b3fb2917bcc184390c1 init_2nd.sh
|
7cf0b1e7511bf289a90ed6cf3190a78119be46e2d885ee3af2dd1fb048eaac7c0875bfd74cc576dd062d17c5fae23f7e721b86f8d71d2b3fb2917bcc184390c1 init_2nd.sh
|
||||||
bb421896e7bebdc13822258d219795da79f3b17f4f0016f16e00cfc46c46beaf7b4873dd0418fc397a839570512a18030a6d8d452a0b54fd35b48be2de06be08 init_functions_2nd.sh
|
bb421896e7bebdc13822258d219795da79f3b17f4f0016f16e00cfc46c46beaf7b4873dd0418fc397a839570512a18030a6d8d452a0b54fd35b48be2de06be08 init_functions_2nd.sh
|
||||||
675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf
|
675e7d5bee39b2df7d322117f8dcaccc274d61beaf4d50ead19bbf2109446d64b1c0aa0c5b4f9846eb6c1c403418f28f6364eff4537ba41120fbfcbc484b7da7 mdev.conf
|
||||||
|
|
|
@ -13,6 +13,8 @@ CONFIGFS_ACM_FUNCTION="acm.usb0"
|
||||||
CONFIGFS_MASS_STORAGE_FUNCTION="mass_storage.0"
|
CONFIGFS_MASS_STORAGE_FUNCTION="mass_storage.0"
|
||||||
HOST_IP="${unudhcpd_host_ip:-172.16.42.1}"
|
HOST_IP="${unudhcpd_host_ip:-172.16.42.1}"
|
||||||
|
|
||||||
|
IN_DEBUG_SHELL=""
|
||||||
|
|
||||||
deviceinfo_getty="${deviceinfo_getty:-}"
|
deviceinfo_getty="${deviceinfo_getty:-}"
|
||||||
deviceinfo_name="${deviceinfo_name:-}"
|
deviceinfo_name="${deviceinfo_name:-}"
|
||||||
deviceinfo_codename="${deviceinfo_codename:-}"
|
deviceinfo_codename="${deviceinfo_codename:-}"
|
||||||
|
@ -1002,6 +1004,11 @@ setup_usb_storage_configfs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
debug_shell() {
|
debug_shell() {
|
||||||
|
# We can't set the IN_DEBUG_SHELL variable before we might be running in a subshell
|
||||||
|
if [ "$IN_DEBUG_SHELL" = "y" ]; then
|
||||||
|
info "Already in debug shell"
|
||||||
|
return
|
||||||
|
fi
|
||||||
echo "Entering debug shell"
|
echo "Entering debug shell"
|
||||||
# if we have a UDC it's already been configured for USB networking
|
# if we have a UDC it's already been configured for USB networking
|
||||||
local have_udc
|
local have_udc
|
||||||
|
@ -1051,6 +1058,7 @@ debug_shell() {
|
||||||
cat <<-EOF > /etc/profile
|
cat <<-EOF > /etc/profile
|
||||||
cat /README
|
cat /README
|
||||||
. /init_functions.sh
|
. /init_functions.sh
|
||||||
|
export IN_DEBUG_SHELL=y
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat <<-EOF > /sbin/pmos_getty
|
cat <<-EOF > /sbin/pmos_getty
|
||||||
|
@ -1158,19 +1166,26 @@ debug_shell() {
|
||||||
|
|
||||||
# Check if the user is pressing a key and either drop to a shell or halt boot as applicable
|
# Check if the user is pressing a key and either drop to a shell or halt boot as applicable
|
||||||
check_keys() {
|
check_keys() {
|
||||||
{
|
local action=""
|
||||||
# If the user is pressing either the left control key or the volume down
|
|
||||||
# key then drop to a debug shell.
|
|
||||||
if iskey KEY_LEFTCTRL KEY_VOLUMEDOWN; then
|
|
||||||
debug_shell
|
|
||||||
# If instead they're pressing left shift or volume up, then fail boot
|
|
||||||
# and dump logs
|
|
||||||
elif iskey KEY_LEFTSHIFT KEY_VOLUMEUP; then
|
|
||||||
fail_halt_boot
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# If the user is pressing either the left control key or the volume down
|
||||||
|
# key then drop to a debug shell.
|
||||||
|
if iskey KEY_LEFTCTRL KEY_VOLUMEDOWN; then
|
||||||
|
IN_DEBUG_SHELL="y"
|
||||||
|
action="debug_shell"
|
||||||
|
# If instead they're pressing left shift or volume up, then fail boot
|
||||||
|
# and dump logs
|
||||||
|
elif iskey KEY_LEFTSHIFT KEY_VOLUMEUP; then
|
||||||
|
action="fail_halt_boot"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Perform the selected action in a subshell and poll for completion
|
||||||
|
if [ -n "$action" ]; then
|
||||||
|
{
|
||||||
|
eval "$action"
|
||||||
touch /tmp/debug_shell_exited
|
touch /tmp/debug_shell_exited
|
||||||
} &
|
} &
|
||||||
|
fi
|
||||||
|
|
||||||
while ! [ -e /tmp/debug_shell_exited ]; do
|
while ! [ -e /tmp/debug_shell_exited ]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -1323,6 +1338,10 @@ export_logs() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fail_halt_boot() {
|
fail_halt_boot() {
|
||||||
|
if [ "$IN_DEBUG_SHELL" = "y" ]; then
|
||||||
|
info "Boot fail while already in debug shell"
|
||||||
|
return
|
||||||
|
fi
|
||||||
export_logs
|
export_logs
|
||||||
debug_shell
|
debug_shell
|
||||||
echo "Looping forever"
|
echo "Looping forever"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue