From 01c90fa16d136f2c7ca896aeedfd0bb31b140afd Mon Sep 17 00:00:00 2001 From: Stephan Raabe Date: Tue, 27 Feb 2024 11:16:40 +0100 Subject: [PATCH] Updates --- scripts/installtimeshift.sh | 17 +++++++++-- scripts/snapshot.sh | 57 +++++++++++++++++++++++++++++++++---- 2 files changed, 65 insertions(+), 9 deletions(-) diff --git a/scripts/installtimeshift.sh b/scripts/installtimeshift.sh index affb8d5..44c4859 100755 --- a/scripts/installtimeshift.sh +++ b/scripts/installtimeshift.sh @@ -21,11 +21,22 @@ _isInstalledYay() { return; #false } -if [[ $(_isInstalledYay "timeshift") == "0" ]] ;then +timeshift_installed=$(_isInstalledYay "timeshift") +grubbtrfs_installed=$(_isInstalledYay "grub-btrfs") + +if [[ $timeshift_installed == "0" ]] ;then echo ":: Timeshift is already installed" - sleep 3 else if gum confirm "DO YOU WANT TO INSTALL Timeshift now?" ;then yay -S timeshift fi -fi \ No newline at end of file +fi +if [[ -d /boot/grub ]] && [[ $grubbtrfs_installed == "0" ]] ;then + echo ":: grub-btrfs is already installed" +else + echo ":: grub-btrfs is required to select a snapshot on grub bootloader." + if gum confirm "DO YOU WANT TO INSTALL grub-btrfs now?" ;then + yay -S grub-btrfs + fi +fi +sleep 3 diff --git a/scripts/snapshot.sh b/scripts/snapshot.sh index 1f6b128..51c5d3e 100755 --- a/scripts/snapshot.sh +++ b/scripts/snapshot.sh @@ -6,11 +6,56 @@ # |____/|_| |_|\__,_| .__/|___/_| |_|\___/ \__| # |_| # -# by Stephan Raabe (2023) +# by Stephan Raabe (2024) # ----------------------------------------------------- -c=$(gum input --placeholder "Enter a comment for the snapshot...") -sudo timeshift --create --comments "$c" -sudo timeshift --list -sudo grub-mkconfig -o /boot/grub/grub.cfg -echo "DONE. Snapshot $c created!" +sleep 1 +clear +figlet "Snapshot" + +_isInstalledYay() { + package="$1"; + check="$(yay -Qs --color always "${package}" | grep "local" | grep "${package} ")"; + if [ -n "${check}" ] ; then + echo 0; #'0' means 'true' in Bash + return; #true + fi; + echo 1; #'1' means 'false' in Bash + return; #false +} + +timeshift_installed=$(_isInstalledYay "timeshift") +grubbtrfs_installed=$(_isInstalledYay "grub-btrfs") + +if [[ $timeshift_installed == "0" ]] ;then + c=$(gum input --placeholder "Enter a comment for the snapshot...") + sudo timeshift --create --comments "$c" + sudo timeshift --list + if [[ -d /boot/grub ]] ;then + if [[ -d /boot/grub ]] && [[ $grubbtrfs_installed == "1" ]] ;then + if gum confirm "DO YOU WANT TO INSTALL grub-btrfs now?" ;then + yay -S grub-btrfs + + else + exit + fi + fi + sudo grub-mkconfig -o /boot/grub/grub.cfg + fi + echo "DONE. Snapshot $c created!" +else + echo "ERROR: Timeshift is not installed." + if gum confirm "DO YOU WANT TO INSTALL Timeshift now?" ;then + yay -S timeshift + echo + echo ":: Timeshift has been installed. Please restart this script." + if [[ -d /boot/grub ]] && [[ $grubbtrfs_installed == "1" ]] ;then + echo ":: grub-btrfs is required to select a snapshot on grub bootloader." + if gum confirm "DO YOU WANT TO INSTALL grub-btrfs now?" ;then + yay -S grub-btrfs + else + exit + fi + fi + fi +fi \ No newline at end of file