mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2024-11-06 05:29:42 +00:00
Btrfs Assistant(+snapper), grub-btrfs Setup added
Adds fedora-btrfs-assistant.sh, updates tab_data and documentation.
This commit is contained in:
parent
476dbf3a12
commit
84551e2b6c
97
core/tabs/system-setup/fedora/fedora-btrfs-assistant.sh
Normal file
97
core/tabs/system-setup/fedora/fedora-btrfs-assistant.sh
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
. ../../common-script.sh
|
||||||
|
|
||||||
|
# This script automates the installation and root snapshot configuration of Snapper and installs Grub-Btrfs on Fedora. Also installs python3-dnf-plugin-snapper package for automatic snapshots after dnf commands.
|
||||||
|
|
||||||
|
# Check the root filesystem type
|
||||||
|
checkFs() {
|
||||||
|
fs_type=$(findmnt -n -o FSTYPE /)
|
||||||
|
if [ "$fs_type" != "btrfs" ]; then
|
||||||
|
printf "%b\n" "${RED}This operation can only be performed on a Btrfs filesystem.${RC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
printf "%b\n" "${GREEN}}Btrfs filesystem detected. Continuing with the operation...${RC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install Btrfs-Assistant/snapper and dependencies
|
||||||
|
installBtrfsStack() {
|
||||||
|
if ! command_exists snapper; then
|
||||||
|
printf "%b\n" "${YELLOW}Installing btrfs-assistant/snapper and dependencies...${RC}"
|
||||||
|
case "$PACKAGER" in
|
||||||
|
dnf)
|
||||||
|
"$ESCALATION_TOOL" "$PACKAGER" install -y btrfs-assistant make inotify-tools python3-dnf-plugin-snapper git
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
printf "%b\n" "${RED}Unsupported package manager: ""$PACKAGER""${RC}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
printf "%b\n" "${GREEN}Snapper is already installed.${RC}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create first snapper config for root and home and create new manual snapshots
|
||||||
|
configureSnapper() {
|
||||||
|
printf "%b\n" "${YELLOW}Creating snapper root config and taking the first root snapshot...${RC}"
|
||||||
|
snapper -c root create-config / && snapper -c root create --description "Manual Snapshot"
|
||||||
|
snapper -c home create-config /home && snapper -c home create --description "Manual Snapshot"
|
||||||
|
# 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
|
||||||
|
# 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
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the grub-btrfs dir exists before attempting to clone into it.
|
||||||
|
cloneGrubBtrfs() {
|
||||||
|
if [ -d "$HOME/grub-btrfs" ]; then
|
||||||
|
rm -rf "$HOME/grub-btrfs"
|
||||||
|
fi
|
||||||
|
cd "$HOME" && git clone https://github.com/Antynea/grub-btrfs
|
||||||
|
}
|
||||||
|
|
||||||
|
# Install grub-btrfs
|
||||||
|
installGrubBtrfs() {
|
||||||
|
printf "%b\n" "${YELLOW}Installing grub-btrfs...${RC}"
|
||||||
|
cd "$HOME/grub-btrfs"
|
||||||
|
printf "%b\n" "${YELLOW}Modifying grub-btrfs configuration for Fedora...${RC}"
|
||||||
|
sed -i '/#GRUB_BTRFS_SNAPSHOT_KERNEL/a GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="systemd.volatile=state"' config
|
||||||
|
sed -i '/#GRUB_BTRFS_GRUB_DIRNAME/a GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"' config
|
||||||
|
sed -i '/#GRUB_BTRFS_MKCONFIG=/a GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig' config
|
||||||
|
sed -i '/#GRUB_BTRFS_SCRIPT_CHECK=/a GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check' config
|
||||||
|
"$ESCALATION_TOOL" make install
|
||||||
|
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" "${YELLOW}Setup complete. Grub-btrfs and automatic snapshot configuration is now active.${RC}"
|
||||||
|
printf "%b\n" "${YELLOW}Notice: You can manage snapshots from the GUI with Btrfs Assistant.${RC}"
|
||||||
|
printf "%b\n" "${YELLOW}Notice: You may want to 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 with the Btrfs Assistant GUI.${RC}"
|
||||||
|
}
|
||||||
|
|
||||||
|
checkEnv
|
||||||
|
checkEscalationTool
|
||||||
|
checkFs
|
||||||
|
installBtrfsStack
|
||||||
|
configureSnapper
|
||||||
|
cloneGrubBtrfs
|
||||||
|
installGrubBtrfs
|
||||||
|
serviceStartEnable
|
|
@ -65,6 +65,12 @@ description = "Enables Virtualization through dnf"
|
||||||
script = "fedora/virtualization.sh"
|
script = "fedora/virtualization.sh"
|
||||||
task_list = "I"
|
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: After installation you may want to change (Hourly, daily, weekly, monthly, yearly) timeline settings via Btrfs Assistant GUI.\nNotice: To perform a system recovery via Grub-btrfs, after the snapshot is booted, perform the restore operation with the Btrfs Assistant GUI.\nNotice: The /boot partition is in EXT4 format by default in Fedora, so it will not be included in the snapshots."
|
||||||
|
script = "fedora/fedora-btrfs-assistant.sh"
|
||||||
|
task_list = "I"
|
||||||
|
|
||||||
[[data]]
|
[[data]]
|
||||||
name = "Build Prerequisites"
|
name = "Build Prerequisites"
|
||||||
description = "This script is designed to handle the installation of various software dependencies across different Linux distributions"
|
description = "This script is designed to handle the installation of various software dependencies across different Linux distributions"
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
- **NVIDIA Proprietary Driver Setup**: Installs proprietary NVIDIA drivers for GPUs from 2014 or later.
|
- **NVIDIA Proprietary Driver Setup**: Installs proprietary NVIDIA drivers for GPUs from 2014 or later.
|
||||||
- **Virtualization Setup**: Installs virtualization tools.
|
- **Virtualization Setup**: Installs virtualization tools.
|
||||||
- **Configure DNF**: Optimizes DNF for better speeds.
|
- **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. Enables snapper-timeline and snapper-cleanup services. Notice: After installation you may want to change (Hourly, daily, weekly, monthly, yearly) timeline settings via Btrfs Assistant GUI. Notice: To perform a system recovery via Grub-btrfs, after the snapshot is booted, perform the restore operation with the Btrfs Assistant GUI. Notice: The /boot partition is in EXT4 format by default in Fedora, so it will not be included in the snapshots.
|
||||||
|
|
||||||
## Applications Setup
|
## Applications Setup
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user