mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-07-16 05:49:49 +00:00
add GRUB timeout TUI and restructure boot menu
- Rename "Boot Rescue & Repair" to "Boot Rescue + GRUB" - Add interactive GRUB timeout settings (Disable, 3s, 5s, Custom) - Implement robust `_set_grub_var` and `_apply_grub_setting` helpers - Add /etc/default/grub.d/99_script_override.cfg to bypass VM/Cloud-init overrides - Handle Secure Boot countdown policy restrictions by using menu style - Fix independent install check for lightdm and lightdm-gtk-greeter-settings
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ main_menu() {
|
|||||||
"8" "ZRAM" \
|
"8" "ZRAM" \
|
||||||
"9" "Swap Management" \
|
"9" "Swap Management" \
|
||||||
"10" "Install Programs and Software" \
|
"10" "Install Programs and Software" \
|
||||||
"11" "Boot Rescue & Repair" \
|
"11" "Boot Rescue + GRUB" \
|
||||||
"12" "Desktop & Display" \
|
"12" "Desktop & Display" \
|
||||||
"13" "Exit")
|
"13" "Exit")
|
||||||
|
|
||||||
|
|||||||
@@ -52,14 +52,20 @@ lightdm_config_menu() {
|
|||||||
for item in $cleaned; do
|
for item in $cleaned; do
|
||||||
case $item in
|
case $item in
|
||||||
install_lightdm)
|
install_lightdm)
|
||||||
if is_installed lightdm; then
|
if ! is_installed lightdm; then
|
||||||
echo -e "${GREEN}LightDM is already installed.${NC}"
|
_run_cmd "LightDM" "sudo apt install -y lightdm" "Installing LightDM..."
|
||||||
else
|
else
|
||||||
_run_cmd "LightDM" "sudo apt install -y lightdm lightdm-gtk-greeter-settings" "Installing LightDM..."
|
echo -e "${GREEN}[LightDM] already installed, skipping...${NC}"
|
||||||
|
fi
|
||||||
|
if ! is_installed lightdm-gtk-greeter-settings; then
|
||||||
|
_run_cmd "LightDM Settings" "sudo apt install -y lightdm-gtk-greeter-settings" "Installing LightDM Settings..."
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}[LightDM Settings] already installed, skipping...${NC}"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
enable_userlist)
|
enable_userlist)
|
||||||
local conf="/etc/lightdm/lightdm.conf.d/50-debianito-userlist.conf"
|
local conf="/etc/lightdm/lightdm.conf.d/50-debianito-userlist.conf"
|
||||||
|
sudo mkdir -p "$(dirname "$conf")"
|
||||||
if echo "[Seat:*]
|
if echo "[Seat:*]
|
||||||
greeter-hide-users=false" | sudo tee "$conf" > /dev/null; then
|
greeter-hide-users=false" | sudo tee "$conf" > /dev/null; then
|
||||||
echo -e "${GREEN}User list enabled in LightDM.${NC}"
|
echo -e "${GREEN}User list enabled in LightDM.${NC}"
|
||||||
|
|||||||
+122
-9
@@ -53,23 +53,136 @@ _rescue_initramfs() {
|
|||||||
_pause
|
_pause
|
||||||
}
|
}
|
||||||
|
|
||||||
rescue_boot() {
|
# ----------------------------------------------------------------------
|
||||||
|
# GRUB helpers
|
||||||
|
# ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
_set_grub_var() {
|
||||||
|
local var="$1" val="$2" file="/etc/default/grub"
|
||||||
|
if grep -q "^${var}=" "$file" 2>/dev/null; then
|
||||||
|
sudo sed -i "s/^${var}=.*/${var}=${val}/" "$file"
|
||||||
|
elif grep -q "^#${var}=" "$file" 2>/dev/null; then
|
||||||
|
sudo sed -i "s/^#${var}=.*/${var}=${val}/" "$file"
|
||||||
|
else
|
||||||
|
echo "${var}=${val}" | sudo tee -a "$file" >/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_apply_grub_setting() {
|
||||||
|
local timeout="$1" style="$2" recordfail="$3" os_prober="$4"
|
||||||
|
local file="/etc/default/grub"
|
||||||
|
local backup="${file}.backup.$(date +%Y%m%d_%H%M%S)"
|
||||||
|
local override="/etc/default/grub.d/99_script_override.cfg"
|
||||||
|
|
||||||
|
sudo cp "$file" "$backup"
|
||||||
|
|
||||||
|
_set_grub_var GRUB_TIMEOUT "$timeout"
|
||||||
|
_set_grub_var GRUB_TIMEOUT_STYLE "$style"
|
||||||
|
_set_grub_var GRUB_RECORDFAIL_TIMEOUT "$recordfail"
|
||||||
|
[ -n "$os_prober" ] && _set_grub_var GRUB_DISABLE_OS_PROBER "$os_prober"
|
||||||
|
|
||||||
|
sudo mkdir -p /etc/default/grub.d
|
||||||
|
if [ -n "$os_prober" ]; then
|
||||||
|
cat << EOF | sudo tee "$override" > /dev/null
|
||||||
|
GRUB_TIMEOUT_STYLE=$style
|
||||||
|
GRUB_TIMEOUT=$timeout
|
||||||
|
GRUB_RECORDFAIL_TIMEOUT=$recordfail
|
||||||
|
GRUB_DISABLE_OS_PROBER=$os_prober
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat << EOF | sudo tee "$override" > /dev/null
|
||||||
|
GRUB_TIMEOUT=$timeout
|
||||||
|
GRUB_TIMEOUT_STYLE=$style
|
||||||
|
GRUB_RECORDFAIL_TIMEOUT=$recordfail
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
local summary
|
||||||
|
summary="Settings applied:\n\n"
|
||||||
|
summary+=" GRUB_TIMEOUT=$timeout\n"
|
||||||
|
summary+=" GRUB_TIMEOUT_STYLE=$style\n"
|
||||||
|
summary+=" GRUB_RECORDFAIL_TIMEOUT=$recordfail\n"
|
||||||
|
[ -n "$os_prober" ] && summary+=" GRUB_DISABLE_OS_PROBER=$os_prober\n"
|
||||||
|
summary+="\nRunning update-grub..."
|
||||||
|
|
||||||
|
echo -e "$summary"
|
||||||
|
|
||||||
|
if sudo update-grub >/dev/null 2>&1; then
|
||||||
|
_msg "GRUB Settings" \
|
||||||
|
"GRUB settings applied successfully!\n\nBackup saved: ${backup}\n\nReboot to see the changes."
|
||||||
|
else
|
||||||
|
echo -e "${RED}update-grub failed. Restoring backup...${NC}"
|
||||||
|
sudo cp "$backup" "$file"
|
||||||
|
sudo rm -f "$override"
|
||||||
|
_msg "Error" "update-grub failed.\nBackup restored from ${backup}\nOverride removed: ${override}."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
_grub_menu_settings() {
|
||||||
while true; do
|
while true; do
|
||||||
local choice
|
local choice
|
||||||
choice=$(_menu "Boot Rescue & Repair" \
|
choice=$(_menu "GRUB Boot Menu Settings" \
|
||||||
"Select a rescue operation${SCROLL_HINT}:" \
|
"Configure when and how the GRUB menu appears${SCROLL_HINT}:" \
|
||||||
$TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
|
$TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
|
||||||
"1" "Refirm Secure Boot (shim + GRUB)" \
|
"1" "Disable GRUB menu on start (Fastest boot)" \
|
||||||
"2" "Regenerate initramfs (all kernels)" \
|
"2" "Faster boot (Show 3-sec countdown)" \
|
||||||
"3" "Return to main menu")
|
"3" "Default boot (Show menu for 5 secs)" \
|
||||||
|
"4" "Custom timeout (Input seconds)" \
|
||||||
|
"5" "Back")
|
||||||
|
|
||||||
[ -z "$choice" ] && return
|
[ -z "$choice" ] && return
|
||||||
clear
|
clear
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
1) _rescue_boot_sb ;;
|
1)
|
||||||
2) _rescue_initramfs ;;
|
if _confirm "Disable GRUB Menu" \
|
||||||
3) return ;;
|
"GRUB menu will be hidden entirely for fastest boot.\n\nTo access the menu on next boot, press and hold ESC\nimmediately after powering on.\n\nProceed?"; then
|
||||||
|
_apply_grub_setting 0 hidden 0 true
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
2)
|
||||||
|
_apply_grub_setting 3 menu 3 ""
|
||||||
|
;;
|
||||||
|
3)
|
||||||
|
_apply_grub_setting 5 menu 5 ""
|
||||||
|
;;
|
||||||
|
4)
|
||||||
|
local custom_timeout
|
||||||
|
custom_timeout=$(whiptail --title "Custom GRUB Timeout" \
|
||||||
|
--inputbox "Enter the GRUB timeout in seconds.\n\nUse -1 for indefinite wait." \
|
||||||
|
10 60 "" 3>&1 1>&2 2>&3 || true)
|
||||||
|
if [ -n "$custom_timeout" ]; then
|
||||||
|
if [[ "$custom_timeout" =~ ^-?[0-9]+$ ]]; then
|
||||||
|
_apply_grub_setting "$custom_timeout" menu "$custom_timeout" ""
|
||||||
|
else
|
||||||
|
_msg "Invalid Input" "Please enter a valid integer (e.g. 0, 5, -1)."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
5) return ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
rescue_boot() {
|
||||||
|
while true; do
|
||||||
|
local choice
|
||||||
|
choice=$(_menu "Boot Rescue + GRUB Configuration" \
|
||||||
|
"Select an operation${SCROLL_HINT}:" \
|
||||||
|
$TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
|
||||||
|
"1" "GRUB Boot Menu Settings" \
|
||||||
|
"2" "Refirm Secure Boot (shim + GRUB)" \
|
||||||
|
"3" "Regenerate initramfs (all kernels)" \
|
||||||
|
"4" "Return to main menu")
|
||||||
|
|
||||||
|
[ -z "$choice" ] && return
|
||||||
|
clear
|
||||||
|
|
||||||
|
case "$choice" in
|
||||||
|
1) _grub_menu_settings ;;
|
||||||
|
2) _rescue_boot_sb ;;
|
||||||
|
3) _rescue_initramfs ;;
|
||||||
|
4) return ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user