1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#! /bin/sh -e
. /usr/share/debconf/confmodule
chroot_has () {
PATH="$CHROOT_PATH" search-path "$1"
}
chroot_run () {
debconf-disconnect chroot /target "$@"
}
# Work out a sensible $PATH with respect to /target.
CHROOT_PATH=
OLD_IFS="$IFS"
IFS=:
for element in $PATH; do
# Only include absolute elements.
if [ "${element#/}" != "$element" ]; then
CHROOT_PATH="${CHROOT_PATH:+$CHROOT_PATH:}/target$element"
fi
done
IFS="$OLD_IFS"
shell_failed () {
db_capb
db_subst rescue/shell/run-failed SHELL "$*"
db_subst rescue/shell/run-failed DEVICE "$RESCUE_ROOTDEV"
db_input critical rescue/shell/run-failed
db_go || true
db_capb backup
}
if [ -f /target/bin/sh ] && [ -x /target/bin/sh ]; then
chroot_run /bin/sh -i || shell_failed '/bin/sh -i'
elif chroot_has sash; then
chroot_run sash || shell_failed sash
elif chroot_has busybox; then
# Try this last even though busybox is useful, since it might fail
# due to a missing sh applet.
chroot_run busybox sh || shell_failed 'busybox sh'
else
db_capb
db_subst rescue/shell/not-found DEVICE "$RESCUE_ROOTDEV"
db_input critical rescue/shell/not-found
db_go || true
db_capb backup
fi
exit 0
|