-
Notifications
You must be signed in to change notification settings - Fork 238
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootloader switcher script added and consequential change to tab TOML file. #447
Conversation
…tab_data toml file.
@fam007e I think you should rewrite the script yourself. Without using LLMs. |
detect_bootloader() { | ||
if [ -d /boot/grub ]; then | ||
printf "GRUB\n" | ||
elif [ -d /boot/loader ]; then | ||
printf "systemd-boot\n" | ||
else | ||
printf "Unknown\n" | ||
fi | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be rewritten not to use printf
s or echo
s.
BACKUP_DIR="/boot/backup/bootloader" | ||
TIMESTAMP=$(date +%Y%m%d-%H%M%S) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be in /boot/backup/bootloader
. BOOT partitions are usually somewhat small.
Also not the best idea to have commands running here. Move this.
restore_grub() { | ||
if [ -z "$1" ]; then | ||
printf "${RED}Please provide the backup file for GRUB restore.${RC}\n" | ||
exit 1 | ||
fi | ||
|
||
printf "${YELLOW}Restoring GRUB configuration from %s...${RC}\n" "$1" | ||
$ESCALATION_TOOL tar -xzf "$1" -C / | ||
grub-mkconfig -o /boot/grub/grub.cfg | ||
printf "${GREEN}GRUB configuration restored.${RC}\n" | ||
} | ||
|
||
# Restore systemd-boot configuration | ||
restore_systemd_boot() { | ||
if [ -z "$1" ]; then | ||
printf "${RED}Please provide the backup file for systemd-boot restore.${RC}\n" | ||
exit 1 | ||
fi | ||
|
||
printf "${YELLOW}Restoring systemd-boot configuration from %s...${RC}\n" "$1" | ||
$ESCALATION_TOOL tar -xzf "$1" -C / | ||
printf "${GREEN}systemd-boot configuration restored.${RC}\n" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script is not supposed to be ran manually. No need for func arguments.
case "$DTYPE" in | ||
debian | ubuntu) | ||
$ESCALATION_TOOL apt-get install -y grub-efi | ||
grub-install | ||
grub-mkconfig -o /boot/grub/grub.cfg | ||
;; | ||
arch) | ||
$ESCALATION_TOOL pacman -S --noconfirm grub | ||
grub-install --target=x86_64-efi --efi-directory=/boot | ||
grub-mkconfig -o /boot/grub/grub.cfg | ||
;; | ||
fedora) | ||
$ESCALATION_TOOL dnf install -y grub2-efi | ||
grub2-install | ||
grub2-mkconfig -o /boot/grub2/grub.cfg | ||
;; | ||
*) | ||
printf "${RED}Unsupported distribution for GRUB installation.${RC}\n" | ||
exit 1 | ||
;; | ||
esac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use
$PACKAGER
. - The installation should be separated and config merged into one.
case "$DTYPE" in | ||
debian | ubuntu | arch | fedora) | ||
$ESCALATION_TOOL bootctl install | ||
;; | ||
*) | ||
printf "${RED}Unsupported distribution for systemd-boot installation.${RC}\n" | ||
exit 1 | ||
;; | ||
esac |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case "$DTYPE" in | |
debian | ubuntu | arch | fedora) | |
$ESCALATION_TOOL bootctl install | |
;; | |
*) | |
printf "${RED}Unsupported distribution for systemd-boot installation.${RC}\n" | |
exit 1 | |
;; | |
esac | |
if ! command_exists "systemctl"; then | |
printf "%b\n" "${RED}systemd-boot only works on systemd distros.${RC}" | |
exit 1 | |
fi | |
$ESCALATION_TOOL bootctl install |
display_backup_list() { | ||
printf "${YELLOW}Available backups:${RC}\n" | ||
ls -1 "$BACKUP_DIR" | grep -E 'grub-backup|systemd-boot-backup' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used only once. No need for a function.
3) | ||
printf "${GREEN}Exiting.${RC}\n" | ||
exit 0 | ||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this.
printf "${YELLOW}1) Switch to GRUB${RC}\n" | ||
fi | ||
printf "${YELLOW}2) Restore backup${RC}\n" | ||
printf "${YELLOW}3) Exit${RC}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this.
You should use |
You have conflicts that need fixing. |
Type of Change
Description
The Bootloader Switcher script provides functionality to switch between GRUB and systemd-boot bootloaders, offering automatic detection of the current bootloader, creating backups of the configurations, and restoring them when needed.
Key Features:
Consequential Change:
tab_data
TOML file has been updated to accommodate this new functionality and ensure seamless integration with the system.Testing
Impact
This script simplifies managing bootloaders, reducing manual steps for installation, backup, and restoration. The impact includes better flexibility for users on multi-boot systems or those who want to switch between bootloaders easily.
Issue related to PR
Additional Information
No additional information at this time.
Checklist