]> git.ipfire.org Git - thirdparty/dracut.git/blob - modules.d/98dracut-systemd/dracut-emergency.sh
1a11220b8c08d970a8357adf8af2346451d3926e
[thirdparty/dracut.git] / modules.d / 98dracut-systemd / dracut-emergency.sh
1 #!/bin/sh
2
3 export DRACUT_SYSTEMD=1
4 if [ -f /dracut-state.sh ]; then
5 . /dracut-state.sh 2>/dev/null
6 fi
7 type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
8
9 source_conf /etc/conf.d
10
11 type plymouth >/dev/null 2>&1 && plymouth quit
12
13 export _rdshell_name="dracut" action="Boot" hook="emergency"
14 _emergency_action=$(getarg rd.emergency)
15
16 if getargbool 1 rd.shell -d -y rdshell || getarg rd.break -d rdbreak; then
17 FSTXT="/run/dracut/fsck/fsck_help_$fstype.txt"
18 RDSOSREPORT="$(rdsosreport)"
19 source_hook "$hook"
20 while read _tty rest; do
21 (
22 echo
23 echo $RDSOSREPORT
24 echo
25 echo
26 echo 'Entering emergency mode. Exit the shell to continue.'
27 echo 'Type "journalctl" to view system logs.'
28 echo 'You might want to save "/run/initramfs/rdsosreport.txt" to a USB stick or /boot'
29 echo 'after mounting them and attach it to a bug report.'
30 echo
31 echo
32 [ -f "$FSTXT" ] && cat "$FSTXT"
33 ) > /dev/$_tty
34 done < /dev/consoles
35 [ -f /etc/profile ] && . /etc/profile
36 [ -z "$PS1" ] && export PS1="$_name:\${PWD}# "
37 exec sulogin -e
38 else
39 export hook="shutdown-emergency"
40 warn "$action has failed. To debug this issue add \"rd.shell rd.debug\" to the kernel command line."
41 source_hook "$hook"
42 [ -z "$_emergency_action" ] && _emergency_action=halt
43 fi
44
45 /bin/rm -f -- /.console_lock
46
47 case "$_emergency_action" in
48 reboot)
49 reboot || exit 1;;
50 poweroff)
51 poweroff || exit 1;;
52 halt)
53 halt || exit 1;;
54 esac
55
56 exit 0