mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-05 21:28:48 +00:00
improved y/n loop
This commit is contained in:
parent
7ef34b6791
commit
7cb3bdc3ca
|
@ -67,19 +67,31 @@ serviceStartEnable() {
|
|||
|
||||
# Ask user if they want to install grub-btrfs
|
||||
askInstallGrubBtrfs() {
|
||||
printf "%b\n" "${YELLOW}grub-btrfs installation...${RC}"
|
||||
printf "%b\n" "${YELLOW}(optional) grub-btrfs installation...${RC}"
|
||||
printf "%b\n" "${YELLOW}You can skip installing grub-btrfs and use only Btrfs Assistant GUI or snapper CLI.${RC}"
|
||||
printf "%b\n" "${CYAN}Notice: grub-btrfs may cause problems with booting into snapshots and other OSes on systems with secure boot/tpm. You will be asked to apply mitigation for this issue in next step.${RC}"
|
||||
printf "%b\n" "${YELLOW}Do you want to install grub-btrfs? (y/n): ${RC}"
|
||||
read -r response
|
||||
case "$response" in
|
||||
[yY]*)
|
||||
installGrubBtrfs
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${GREEN}Skipping grub-btrfs installation.${RC}"
|
||||
;;
|
||||
esac
|
||||
|
||||
while true; do
|
||||
printf "%b\n" "${YELLOW}Do you want to install grub-btrfs? Press (y) for yes, (n) for no, (f) to apply tpm mitigation to already installed grub-btrfs: ${RC}"
|
||||
read -r response
|
||||
case "$response" in
|
||||
[yY]*)
|
||||
installGrubBtrfs
|
||||
break
|
||||
;;
|
||||
[nN]*)
|
||||
printf "%b\n" "${GREEN}Skipping grub-btrfs installation.${RC}"
|
||||
break
|
||||
;;
|
||||
[fF]*)
|
||||
mitigateTpmError
|
||||
break
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${RED}Invalid input. Please enter 'y' for yes or 'n' for no.${RC}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Install grub-btrfs
|
||||
|
@ -106,31 +118,37 @@ installGrubBtrfs() {
|
|||
cd .. && rm -rf "$HOME/grub-btrfs" #deletes downloaded git folder
|
||||
printf "%b\n" "${GREEN}Grub-btrfs installed and service enabled.${RC}"
|
||||
printf "%b\n" "${CYAN}Notice: To perform a system recovery via grub-btrfs, perform a restore operation with Btrfs Assistant GUI after booting into the snapshot.${RC}"
|
||||
# Ask user if they want to apply mitigation for "tpm.c:150:unknown TPM error"
|
||||
printf "%b\n" "${YELLOW}Mitigation for 'tpm.c:150:unknown TPM error'...${RC}"
|
||||
printf "%b\n" "${YELLOW}Some systems with secure boot/tpm may encounter 'tpm.c:150:unknown TPM error' when booting into snapshots.${RC}"
|
||||
printf "%b\n" "${YELLOW}If you encounter this issue, you can come back later and apply this mitigation or you can apply it now.${RC}"
|
||||
printf "%b\n" "${YELLOW}Do you want to apply mitigation for 'tpm.c:150:unknown TPM error'? (y/n): ${RC}"
|
||||
read -r response
|
||||
case "$response" in
|
||||
[yY]*)
|
||||
mitigateTpmError
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${GREEN}Skipping mitigation for 'tpm.c:150:unknown TPM error'.${RC}"
|
||||
;;
|
||||
esac
|
||||
mitigateTpmError
|
||||
}
|
||||
|
||||
# Mitigation for "tpm.c:150:unknown TPM error"
|
||||
mitigateTpmError() {
|
||||
printf "%b\n" "${YELLOW}Applying mitigation for 'tpm.c:150:unknown TPM error'...${RC}"
|
||||
printf "%b\n" "${YELLOW}Creating /etc/grub.d/02_tpm file...${RC}"
|
||||
echo '#!/bin/sh' | "$ESCALATION_TOOL" tee /etc/grub.d/02_tpm > /dev/null
|
||||
echo 'echo "rmmod tpm"' | "$ESCALATION_TOOL" tee -a /etc/grub.d/02_tpm > /dev/null
|
||||
"$ESCALATION_TOOL" chmod +x /etc/grub.d/02_tpm #makes the file executable
|
||||
"$ESCALATION_TOOL" grub2-mkconfig -o /boot/grub2/grub.cfg #updates grub config
|
||||
printf "%b\n" "${GREEN}Mitigation applied and grub config updated.${RC}"
|
||||
# Ask user if they want to apply mitigation for "tpm.c:150:unknown TPM error"
|
||||
printf "%b\n" "${YELLOW}Mitigation for 'tpm.c:150:unknown TPM error'...${RC}"
|
||||
printf "%b\n" "${YELLOW}Some systems with secure boot/tpm may encounter 'tpm.c:150:unknown TPM error' when booting into snapshots.${RC}"
|
||||
printf "%b\n" "${YELLOW}If you encounter this issue, you can come back later and apply this mitigation or you can apply it now.${RC}"
|
||||
while true; do
|
||||
printf "%b\n" "${YELLOW}Do you want to apply the TPM error mitigation? (y/n): ${RC}"
|
||||
read -r response
|
||||
case "$response" in
|
||||
[yY]*)
|
||||
printf "%b\n" "${YELLOW}Creating /etc/grub.d/02_tpm file...${RC}"
|
||||
echo '#!/bin/sh' | "$ESCALATION_TOOL" tee /etc/grub.d/02_tpm > /dev/null
|
||||
echo 'echo "rmmod tpm"' | "$ESCALATION_TOOL" tee -a /etc/grub.d/02_tpm > /dev/null
|
||||
"$ESCALATION_TOOL" chmod +x /etc/grub.d/02_tpm # makes the file executable
|
||||
"$ESCALATION_TOOL" grub2-mkconfig -o /boot/grub2/grub.cfg # updates grub config
|
||||
printf "%b\n" "${GREEN}Mitigation applied and grub config updated.${RC}"
|
||||
break
|
||||
;;
|
||||
[nN]*)
|
||||
printf "%b\n" "${GREEN}Skipping TPM error mitigation.${RC}"
|
||||
break
|
||||
;;
|
||||
*)
|
||||
printf "%b\n" "${RED}Invalid input. Please enter 'y' for yes or 'n' for no.${RC}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
# Post install information
|
||||
|
|
Loading…
Reference in New Issue
Block a user