On Fri, Apr 2, 2021 at 12:28 PM Coiby Xu <coxu(a)redhat.com> wrote:
On Thu, Mar 18, 2021 at 01:12:31PM +0800, Kairui Song wrote:
>Use a modified and minimized version of emergency shell.
>The differences of this kdump shell and dracut emergency shell are:
>
> - Kdump shell won't generate a rdsosreport automatically
> - Customized prompts
> - Never ask root password
> - Won't tangle with dracut's emergency_action. If emergency_action is
> set, dracut emergency shell will perform dracut's emergency_action
> instead of kdump final_action on exit.
> - If rd.shell=no is set, kdump shell will still work, dracut emergency
> shell won't, even if kdump failure_action is set to shell.
>
>Signed-off-by: Kairui Song <kasong(a)redhat.com>
>---
> kdump-lib-initramfs.sh | 33 +++++++++++++++++++++++++++++----
> 1 file changed, 29 insertions(+), 4 deletions(-)
>
>diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
>index 7198db1..d03f981 100755
>--- a/kdump-lib-initramfs.sh
>+++ b/kdump-lib-initramfs.sh
>@@ -231,10 +231,35 @@ dump_to_rootfs()
>
> kdump_emergency_shell()
> {
>- echo "PS1=\"kdump:\\\${PWD}# \"" >/etc/profile
>- ddebug "Switching to dracut emergency..."
>- /bin/dracut-emergency
>- rm -f /etc/profile
>+ ddebug "Switching to kdump emergency shell..."
>+
>+ [ -f /etc/profile ] && . /etc/profile
>+ export PS1='kdump:\\\${PWD}# '
Since you use "'", you shouldn't escape "$", i.e.,
export PS1='kdump:${PWD}# '.
Thanks, good point!
WIll update this.
Btw, even if you use double quotes, "\" doesn't need to be escaped, i.e.,
PS1="kdump:\${PWD}# "
>+
>+ . /lib/dracut-lib.sh
>+ if [ -f /dracut-state.sh ]; then
>+ . /dracut-state.sh 2>/dev/null
>+ fi
>+
>+ source_conf /etc/conf.d
>+
>+ type plymouth >/dev/null 2>&1 && plymouth quit
>+
>+ source_hook "emergency"
>+ while read _tty rest; do
>+ (
>+ echo
>+ echo
>+ echo 'Entering kdump emergency mode.'
>+ echo 'Type "journalctl" to view system logs.'
>+ echo 'Type "rdsosreport" to generate a sosreport, you can
then'
>+ echo 'save it elsewhere and attach it to a bug report.'
>+ echo
>+ echo
>+ ) > /dev/$_tty
>+ done < /proc/consoles
>+ sh -i -l
>+ /bin/rm -f -- /.console_lock
> }
>
> do_failure_action()
>--
>2.29.2
>_______________________________________________
>kexec mailing list -- kexec(a)lists.fedoraproject.org
>To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
>Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
>List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
>List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
>Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure
--
Best regards,
Coiby
--
Best Regards,
Kairui Song