emergency_shell()
{
+ if [ $1 = "-n" ]; then
+ _rdshell_name=$2
+ shift 2
+ else
+ _rdshell_name=dracut
+ fi
wait_for_loginit
echo ; echo
echo $@
if getarg rdshell || getarg rdbreak; then
echo "Dropping to debug shell."
echo
- sh -i
+ export PS1="$_rdshell_name:\${PWD}# "
+ [ -e /.profile ] || echo "exec 0<>/dev/console 1<>/dev/console 2<>/dev/console" > /.profile
+ sh -i -l
else
echo "Boot has failed, sleeping forever."
while :; do sleep 365d;done
source_conf /etc/conf.d
# run scriptlets to parse the command line
-getarg 'rdbreak=cmdline' && emergency_shell "Break before cmdline"
+getarg 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
source_all cmdline
[ -z "$root" ] && die "No or empty root= argument"
} > /tmp/root.info
# pre-udev scripts run before udev starts, and are run only once.
-getarg 'rdbreak=pre-udev' && emergency_shell "Break before pre-udev"
+getarg 'rdbreak=pre-udev' && emergency_shell -n pre-udev "Break before pre-udev"
source_all pre-udev
# start up udev and trigger cold plugs
getarg rdudevinfo && udevadm control $UDEV_LOG_PRIO_ARG=info
getarg rdudevdebug && udevadm control $UDEV_LOG_PRIO_ARG=debug
-getarg 'rdbreak=pre-trigger' && emergency_shell "Break before pre-trigger"
+getarg 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
source_all pre-trigger
# then the rest
udevadm trigger $udevtriggeropts >/dev/null 2>&1
-getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue"
+getarg 'rdbreak=initqueue' && emergency_shell -n initqueue "Break before initqueue"
i=0
while :; do
# pre-mount happens before we try to mount the root filesystem,
# and happens once.
-getarg 'rdbreak=pre-mount' && emergency_shell "Break pre-mount"
+getarg 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
source_all pre-mount
-getarg 'rdbreak=mount' && emergency_shell "Break mount"
+getarg 'rdbreak=mount' && emergency_shell -n mount "Break mount"
# mount scripts actually try to mount the root filesystem, and may
# be sourced any number of times. As soon as one suceeds, no more are sourced.
i=0
} | vinfo
# pre pivot scripts are sourced just before we switch over to the new root.
-getarg 'rdbreak=pre-pivot' && emergency_shell "Break pre-pivot"
+getarg 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
source_all pre-pivot
# by the time we get here, the root filesystem should be mounted.
emergency_shell
}
-getarg rdbreak && emergency_shell "Break before switch_root"
+getarg rdbreak && emergency_shell -n switch_root "Break before switch_root"
# stop udev queue before killing it
udevadm control --stop-exec-queue