/lib/recovery-mode/recovery-menu is in friendly-recovery 0.2.31.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | #!/bin/bash
if [ ! -x "$(which whiptail)" ]; then
echo "Couldn't find whiptail, starting root shell instead of recovery menu."
sulogin
clear
exit
fi
# include gettext stuff
. /lib/recovery-mode/l10n.sh
# main
READONLY=true
while true; do
unset items
if [ "$READONLY" = "true" ]; then
menu_text=$(eval_gettext "Recovery Menu (filesystem state: read-only)")
else
menu_text=$(eval_gettext "Recovery Menu (filesystem state: read/write)")
fi
items[c++]="resume"
items[c++]=$(eval_gettext " Resume normal boot")
for i in /lib/recovery-mode/options/*; do
if [ -x "$i" ]; then
name="`"$i" test`"
if [ $? -eq 0 ]; then
items[c++]="${i##*/}"
items[c++]=" $name"
fi
fi
done
choice="$(whiptail --nocancel --menu "$menu_text" 18 70 10 \
"${items[@]}" \
3>&1 1>&2 2>&3 3>&-)"
if [ -z "$choice" ]; then
continue
fi
if [ "$choice" = "resume" ]; then
box_text=$(eval_gettext "You are now going to exit the recovery mode and continue the boot sequence. Please note that some graphic drivers require a full graphical boot and so will fail when resuming from recovery.
If that's the case, simply reboot from the login screen and then perform a standard boot.")
whiptail --msgbox "$box_text" 12 70
clear
exit
fi
/lib/recovery-mode/options/$choice test mode >/dev/null 2>&1
retval=$?
# Hack for the fsck case (needs to be cosidered read/write only when
# in read-only mode and read-only only when in read/write mode)
if [ "$choice" = "fsck" ] && [ "$READONLY" = "false" ]; then
retval=1
fi
case "$retval" in
0)
# 0 => requires read/write
if [ "$READONLY" = "true" ]; then
box_text=$(eval_gettext "Continuing will remount your / filesystem in read/write mode and mount any other filesystem defined in /etc/fstab.
Do you wish to continue?")
whiptail --yesno "$box_text" 10 70 || continue
if [ "$choice" = "fsck" ]; then
FSCHECK="true"
fi
. /etc/default/rcS
if [ -d /run/systemd/system ]; then
[ "$FSCKFIX" = "yes" ] && fsck_mode="-y" || fsck_mode='-a'
[ "$FSCHECK" = "true" ] || [ -f /forcefsck ] && fsck $fsck_mode
systemctl start --job-mode=ignore-dependencies systemd-remount-fs.service
mount -a
else
[ "$FSCHECK" = "true" ] || [ -f /forcefsck ] && force_fsck="--force-fsck"
[ "$FSCKFIX" = "yes" ] && fsck_fix="--fsck-fix"
mountall $force_fsck $fsck_fix --no-events
fi
rm -f /forcefsck
if [ "$choice" = "fsck" ]; then
echo ""
echo $(eval_gettext "Finished, please press ENTER")
read TMP
fi
READONLY=false
fi
;;
1)
# 1 => read-only only
if [ "$READONLY" = "false" ]; then
box_text=$(eval_gettext "The option you selected requires your filesystem to be in read-only mode. Unfortunately another option you selected earlier, made you exit this mode.
The easiest way of getting back in read-only mode is to reboot your system.")
whiptail --msgbox "$box_text" 12 70
continue
fi
;;
2)
# 2 => works in all cases
# nothing to do
;;
esac
export READONLY
/lib/recovery-mode/options/$choice
done
|