Updates for rsync

This commit is contained in:
Stephan Raabe 2023-11-25 16:53:12 +01:00
parent 4a657c7f11
commit 49093fef5d
4 changed files with 40 additions and 2 deletions

View File

@ -54,6 +54,12 @@ if gum confirm "Do you want to install the prepared dotfiles now?" ;then
echo "~/dotfiles folder created." echo "~/dotfiles folder created."
fi fi
rsync -a -I ~/dotfiles-versions/$version/ ~/dotfiles/ rsync -a -I ~/dotfiles-versions/$version/ ~/dotfiles/
if [[ $(_isFolderEmpty ~/dotfiles/) == 0 ]] ;then
echo "AN ERROR HAS OCCURED. Copy prepared dofiles from ~/dotfiles-versions/$version/ to ~/dotfiles/ failed"
echo "Please check that rsync is installad on your system."
echo "Execution of rsync -a -I ~/dotfiles-versions/$version/ ~/dotfiles/ is required."
exit
fi
echo "All files from ~/dotfiles-versions/$version/ to ~/dotfiles/ copied." echo "All files from ~/dotfiles-versions/$version/ to ~/dotfiles/ copied."
else else
echo "Skipped: DEV MODE!" echo "Skipped: DEV MODE!"

View File

@ -34,6 +34,19 @@ _isInstalledYay() {
return; #false return; #false
} }
_isFolderEmpty() {
folder="$1"
if [ -d $folder ] ;then
if [ -z "$(ls -A $folder)" ]; then
echo 0
else
echo 1
fi
else
echo 1
fi
}
# ------------------------------------------------------ # ------------------------------------------------------
# Function Install all package if not installed # Function Install all package if not installed
# ------------------------------------------------------ # ------------------------------------------------------

View File

@ -22,10 +22,16 @@ if [ ! -d ~/dotfiles-versions/$version ]; then
echo "~/dotfiles-versions/$version folder created." echo "~/dotfiles-versions/$version folder created."
else else
echo "The folder ~/dotfiles-versions/$version already exists from previous installations." echo "The folder ~/dotfiles-versions/$version already exists from previous installations."
rm -fr ~/dotfiles-versions/$version rm -rf ~/dotfiles-versions/$version
mkdir ~/dotfiles-versions/$version mkdir ~/dotfiles-versions/$version
echo "Clean build prepared for the installation." echo "Clean build prepared for the installation."
fi fi
rsync -a -I --exclude-from=.install/excludes.txt . ~/dotfiles-versions/$version/ rsync -a -I --exclude-from=.install/excludes.txt . ~/dotfiles-versions/$version/
if [[ $(_isFolderEmpty ~/dotfiles-versions/$version/) == 0 ]] ;then
echo "AN ERROR HAS OCCURED. Preparation of ~/dotfiles-versions/$version/ failed"
echo "Please check that rsync is installad on your system."
echo "Execution of rsync -a -I --exclude-from=.install/excludes.txt . ~/dotfiles-versions/$version/ is required."
exit
fi
echo "dotfiles $version successfully prepared in ~/dotfiles-versions/$version/" echo "dotfiles $version successfully prepared in ~/dotfiles-versions/$version/"
echo "" echo ""

View File

@ -2,7 +2,20 @@
# Check for required packages to run the installation # Check for required packages to run the installation
# ------------------------------------------------------ # ------------------------------------------------------
echo "Checking that required packages for the installation are installed..." # Synchronize packages
sudo pacman -Sy
echo "" echo ""
# Check for required packages
echo ":: Checking that required packages for the installation are installed..."
_installPackagesPacman "rsync" "gum"; _installPackagesPacman "rsync" "gum";
echo "" echo ""
# Double check rsync
if ! command -v rsync &> /dev/null; then
echo ":: Force rsync installation"
sudo pacman -S rsync --noconfirm
else
echo ":: rsync double checked"
fi
echo ""