From 6c1572dfe9f28ad614d9d9446a6f9fcd29b8e885 Mon Sep 17 00:00:00 2001 From: leventbesli Date: Sat, 5 Oct 2024 11:32:50 +0300 Subject: [PATCH] updated wording and add prompts for actions --- .../fedora/fedora-btrfs-assistant.sh | 108 ++++++++++++------ core/tabs/system-setup/tab_data.toml | 4 +- docs/userguide.md | 2 +- 3 files changed, 73 insertions(+), 41 deletions(-) diff --git a/core/tabs/system-setup/fedora/fedora-btrfs-assistant.sh b/core/tabs/system-setup/fedora/fedora-btrfs-assistant.sh index 06e04126..8a006b92 100644 --- a/core/tabs/system-setup/fedora/fedora-btrfs-assistant.sh +++ b/core/tabs/system-setup/fedora/fedora-btrfs-assistant.sh @@ -16,11 +16,11 @@ checkFs() { # Install Btrfs-Assistant/snapper and dependencies installBtrfsStack() { - if ! command_exists snapper; then - printf "%b\n" "${YELLOW}Installing btrfs-assistant/snapper and dependencies...${RC}" + if ! command_exists btrfs-assistant; then + printf "%b\n" "${YELLOW}Installing Btrfs Assistant with snapper...${RC}" case "$PACKAGER" in dnf) - "$ESCALATION_TOOL" "$PACKAGER" install -y btrfs-assistant inotify-tools python3-dnf-plugin-snapper make git + "$ESCALATION_TOOL" "$PACKAGER" install -y btrfs-assistant ;; *) printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}" @@ -28,41 +28,83 @@ installBtrfsStack() { ;; esac else - printf "%b\n" "${GREEN}Snapper is already installed.${RC}" - exit 1 + printf "%b\n" "${GREEN}Btrfs Assistant is already installed.${RC}" fi } # Create first snapper config for root and home and create new manual snapshots configureSnapper() { + if command_exists snapper; then + printf "%b\n" "${YELLOW}Snapper tool detected. Do you want to configure root and home configs and take first snapshots? (y/n): ${RC}" + read -r response + case "$response" in + [yY]*) + ;; + *) + printf "%b\n" "${GREEN}Snapper configurations will not be changed.${RC}" + return + ;; + esac + else + "$ESCALATION_TOOL" "$PACKAGER" install -y snapper python3-dnf-plugin-snapper + fi printf "%b\n" "${YELLOW}Creating snapper root(/) and home config and taking the first snapshots...${RC}" snapper -c root create-config / && snapper -c root create --description "First root Snapshot" snapper -c home create-config /home && snapper -c home create --description "First home Snapshot" + printf "%b\n" "${YELLOW}Updating timeline settings...${RC}" # Modifyling default timeline root config - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_HOURLY="[^"]*"/TIMELINE_LIMIT_HOURLY="1"/' /etc/snapper/configs/root - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_DAILY="[^"]*"/TIMELINE_LIMIT_DAILY="2"/' /etc/snapper/configs/root - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_WEEKLY="[^"]*"/TIMELINE_LIMIT_WEEKLY="1"/' /etc/snapper/configs/root - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_MONTHLY="[^"]*"/TIMELINE_LIMIT_MONTHLY="0"/' /etc/snapper/configs/root - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_YEARLY="[^"]*"/TIMELINE_LIMIT_YEARLY="0"/' /etc/snapper/configs/root + "$ESCALATION_TOOL" sed -i ' + s/^TIMELINE_LIMIT_HOURLY="[^"]*"/TIMELINE_LIMIT_HOURLY="1"/; + s/^TIMELINE_LIMIT_DAILY="[^"]*"/TIMELINE_LIMIT_DAILY="2"/; + s/^TIMELINE_LIMIT_WEEKLY="[^"]*"/TIMELINE_LIMIT_WEEKLY="1"/; + s/^TIMELINE_LIMIT_MONTHLY="[^"]*"/TIMELINE_LIMIT_MONTHLY="0"/; + s/^TIMELINE_LIMIT_YEARLY="[^"]*"/TIMELINE_LIMIT_YEARLY="0"/ + ' /etc/snapper/configs/root # Modifyling default timeline for home config - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_HOURLY="[^"]*"/TIMELINE_LIMIT_HOURLY="2"/' /etc/snapper/configs/home - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_DAILY="[^"]*"/TIMELINE_LIMIT_DAILY="1"/' /etc/snapper/configs/home - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_WEEKLY="[^"]*"/TIMELINE_LIMIT_WEEKLY="0"/' /etc/snapper/configs/home - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_MONTHLY="[^"]*"/TIMELINE_LIMIT_MONTHLY="1"/' /etc/snapper/configs/home - "$ESCALATION_TOOL" sed -i 's/^TIMELINE_LIMIT_YEARLY="[^"]*"/TIMELINE_LIMIT_YEARLY="0"/' /etc/snapper/configs/home + "$ESCALATION_TOOL" sed -i ' + s/^TIMELINE_LIMIT_HOURLY="[^"]*"/TIMELINE_LIMIT_HOURLY="2"/; + s/^TIMELINE_LIMIT_DAILY="[^"]*"/TIMELINE_LIMIT_DAILY="1"/; + s/^TIMELINE_LIMIT_WEEKLY="[^"]*"/TIMELINE_LIMIT_WEEKLY="0"/; + s/^TIMELINE_LIMIT_MONTHLY="[^"]*"/TIMELINE_LIMIT_MONTHLY="1"/; + s/^TIMELINE_LIMIT_YEARLY="[^"]*"/TIMELINE_LIMIT_YEARLY="0"/ + ' /etc/snapper/configs/home + printf "%b\n" "${GREEN}Snapper configs and first snapshots created.${RC}" + serviceStartEnable } -# Check if the grub-btrfs dir exists before attempting to clone into it. -cloneGrubBtrfs() { - printf "%b\n" "${YELLOW}Downloading grub-btrfs...${RC}" - if [ -d "$HOME/grub-btrfs" ]; then - rm -rf "$HOME/grub-btrfs" - fi - cd "$HOME" && git clone https://github.com/Antynea/grub-btrfs +# Starting services +serviceStartEnable() { + printf "%b\n" "${YELLOW}Starting and enabling snapper-timeline.timer and snapper-cleanup.timer services...${RC}" + systemctl start snapper-timeline.timer && systemctl enable snapper-timeline.timer #enables scheduled timeline snapshots + systemctl start snapper-cleanup.timer && systemctl enable snapper-cleanup.timer #enables scheduled snapshot cleanup + printf "%b\n" "${GREEN}Snapper services started and enabled.${RC}" +} + +# Ask user if they want to install grub-btrfs +askInstallGrubBtrfs() { + printf "%b\n" "${YELLOW}You can skip installing grub-btrfs and use only Btrfs Assistant GUI or snapper CLI.${RC}" + printf "%b\n" "${RED}grub-btrfs may cause problems on encrypted systems with secure boot/tpm. ${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 } # Install grub-btrfs installGrubBtrfs() { + # Check if the grub-btrfs dir exists before attempting to clone into it. + printf "%b\n" "${YELLOW}Downloading grub-btrfs and installing dependencies...${RC}" + if [ -d "$HOME/grub-btrfs" ]; then + rm -rf "$HOME/grub-btrfs" + fi + "$ESCALATION_TOOL" "$PACKAGER" install -y make git inotify-tools + cd "$HOME" && git clone https://github.com/Antynea/grub-btrfs printf "%b\n" "${YELLOW}Installing grub-btrfs...${RC}" cd "$HOME/grub-btrfs" printf "%b\n" "${YELLOW}Modifying grub-btrfs configuration for Fedora...${RC}" @@ -76,23 +118,15 @@ installGrubBtrfs() { "$ESCALATION_TOOL" grub2-mkconfig -o /boot/grub2/grub.cfg && systemctl enable --now grub-btrfsd.service printf "%b\n" "${YELLOW}Cleaning up installation files...${RC}" cd .. && rm -rf "$HOME/grub-btrfs" #deletes downloaded git folder -} - -# Starting services -serviceStartEnable() { - printf "%b\n" "${YELLOW}Starting and enabling snapper-timeline.timer and snapper-cleanup.timer services...${RC}" - systemctl start snapper-timeline.timer && systemctl enable snapper-timeline.timer #enables scheduled timeline snapshots - systemctl start snapper-cleanup.timer && systemctl enable snapper-cleanup.timer #enables scheduled snapshot cleanup - printf "%b\n" "${YELLOW}Restarting grub-btrfsd service...${RC}" - systemctl restart grub-btrfsd - printf "%b\n" "${GREEN}Installation completed. Grub-btrfs and automatic snapshot configuration is now active.${RC}" + printf "%b\n" "${GREEN}Grub-btrfs installed and service enabled.${RC}" + printf "%b\n" "${CYAN}Notice: To perform a system recovery via grub-btrfs, after booting into your snapshot, do the 'restore' operation via Btrfs Assistant GUI.${RC}" } # Post install information someNotices() { - printf "%b\n" "${YELLOW}Notice: You can manage snapshots from the GUI with Btrfs Assistant.${RC}" - printf "%b\n" "${YELLOW}Notice: You may change (Hourly, daily, weekly, monthly, yearly) timeline settings via Btrfs Assistant GUI.${RC}" - printf "%b\n" "${YELLOW}Notice: To perform a system recovery via Grub-btrfs, after booting into your snapshot, do the 'restore' operation via Btrfs Assistant GUI.${RC}" + printf "%b\n" "${GREEN}Notice: Setup process completed.${RC}" + printf "%b\n" "${YELLOW}Notice: You can manage snapshots from GUI with Btrfs Assistant or CLI with snapper.${RC}" + printf "%b\n" "${YELLOW}Notice: You may change (Hourly, daily, weekly, monthly, yearly) timeline settings with Btrfs Assistant GUI.${RC}" printf "%b\n" "${CYAN}Notice: If you used the default Fedora disk partitioning during OS installation, the /boot configured as an separate EXT4 partition. Therefore, it cannot be included in root snapshots. Backup separately...${RC}" } @@ -101,7 +135,5 @@ checkEscalationTool checkFs installBtrfsStack configureSnapper -cloneGrubBtrfs -installGrubBtrfs -serviceStartEnable +askInstallGrubBtrfs someNotices diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml index b9665c9e..0ff47dee 100644 --- a/core/tabs/system-setup/tab_data.toml +++ b/core/tabs/system-setup/tab_data.toml @@ -66,8 +66,8 @@ script = "fedora/virtualization.sh" task_list = "I" [[data.entries]] -name = "Btrfs Assistant(+snapper), grub-btrfs Setup" -description = "Installs Btrfs-Assistan/Snapper, dnf snapper plugin and takes the first root(/) and /home snapshots\nInstalls Grub-Btrfs.\nEnables snapper-timeline and snapper-cleanup services.\nNotice: To perform a system recovery via Grub-btrfs, after the snapshot is booted, restore with the Btrfs Assistant GUI.\nNotice: If you used the default Fedora disk partitioning during OS installation, the /boot configured as an separate EXT4 partition. Therefore, it cannot be included in root snapshots. Backup separately." +name = "Btrfs Assistant, Snapper Config, grub-btrfs" +description = "Installs Btrfs Assistant, Snapper, dnf snapper plugin and takes the first root(/) and /home snapshots.\nEnables snapper-timeline and snapper-cleanup services.\n(Optionally)Installs Grub-Btrfs.\nTo perform a system recovery via grub-btrfs, do restore operation with Btrfs Assistant GUI after booting into snapshot.\nNotice: If you used the default Fedora disk partitioning during OS installation, the /boot configured as an separate EXT4 partition. Therefore, it cannot be included in root snapshots. Backup separately." script = "fedora/fedora-btrfs-assistant.sh" task_list = "I" diff --git a/docs/userguide.md b/docs/userguide.md index 99b4c1ec..2ee441c2 100644 --- a/docs/userguide.md +++ b/docs/userguide.md @@ -23,7 +23,7 @@ - **NVIDIA Proprietary Driver Setup**: Installs proprietary NVIDIA drivers for GPUs from 2014 or later. - **Virtualization Setup**: Installs virtualization tools. - **Configure DNF**: Optimizes DNF for better speeds. -- **Btrfs Assistant(+snapper), grub-btrfs Setup**: Installs Btrfs-Assistan/Snapper, dnf snapper plugin and takes the first root(/) and /home snapshots. Notice: The /boot configured as a separate EXT4 partition by default in Fedora, so it can't be included in the snapshots. Backup it seperately. +- **Btrfs Assistant, Snapper Config, grub-btrfs**: Installs Btrfs Assistant, Snapper, dnf snapper plugin and grub-btrfs. Creates snapper configs. Notice: The /boot configured as a separate EXT4 partition by default in Fedora, so it can't be included in the snapshots. Backup it seperately. ## Applications Setup