This commit is contained in:
Stephan Raabe 2024-03-29 13:08:22 +01:00
parent 60f2229b42
commit 5c0a5028fe
5 changed files with 166 additions and 46 deletions

View File

@ -3,45 +3,160 @@
# ------------------------------------------------------
datets=$(date '+%Y%m%d%H%M%S')
if [ -d ~/dotfiles ] || [ -f ~/.bashrc ]; then
echo -e "${GREEN}"
figlet "Backup"
echo -e "${NONE}"
if [ -d ~/dotfiles ]; then
echo ":: The script has detected an existing dotfiles folder and will try to create a backup into the folder:"
echo " ~/dotfiles-versions/backups/$datets"
fi
if [ ! -L ~/.bashrc ] && [ -f ~/.bashrc ]; then
echo ":: The script has detected an existing .bashrc file and will try to create a backup to:"
echo " ~/dotfiles-versions/backups/$datets/.bashrc-old"
fi
if gum confirm "Do you want to create a backup?" ;then
# Create Backup File Structure
if [ ! -d ~/dotfiles-versions ]; then
mkdir ~/dotfiles-versions
echo "~/dotfiles-versions created."
fi
if [ ! -d ~/dotfiles-versions/backups ]; then
mkdir ~/dotfiles-versions/backups
echo "~/dotfiles-versions/backups created"
if [ ! -d ~/dotfiles-versions/backup ]; then
mkdir ~/dotfiles-versions/backup
echo "~/dotfiles-versions/backup created"
fi
if [ -d ~/dotfiles-versions/backups ]; then
mv ~/dotfiles-versions/backups ~/dotfiles-versions/archive
echo ":: Existing backups moved into ~/dotfiles-versions/archive"
fi
if [ ! -d ~/dotfiles-versions/archive ]; then
mkdir ~/dotfiles-versions/archive
echo "~/dotfiles-versions/archive created"
fi
# Backup Existing Dotfiles
if [ -d ~/dotfiles ] || ! test -L ~/.bashrc || [ -d ~/.config/hypr ] || [ -d ~/.config/qtile ]; then
echo -e "${GREEN}"
figlet "Backup"
echo -e "${NONE}"
echo "The script has detected the following files and folders for a backup:"
if [ -d ~/dotfiles ]; then
echo " - $HOME/dotfiles"
fi
if ! test -L ~/.bashrc ;then
echo " - $HOME/.bashrc"
fi
if ! test -L ~/.config/qtile && [ -d ~/.config/qtile ] ;then
echo " - $HOME/.config/qtile/"
fi
if ! test -L ~/.config/hypr && [ -d ~/.config/hypr ] ;then
echo " - $HOME/.config/hypr/"
fi
if ! test -L ~/.config/rofi && [ -d ~/.config/rofi ] ;then
echo " - $HOME/.config/rofi/"
fi
if ! test -L ~/.config/wal && [ -d ~/.config/wal ] ;then
echo " - $HOME/.config/wal/"
fi
if ! test -L ~/.config/waybar && [ -d ~/.config/waybar ] ;then
echo " - $HOME/.config/waybar/"
fi
if ! test -L ~/.config/wlogout && [ -d ~/.config/wlogout ] ;then
echo " - $HOME/.config/wlogout/"
fi
if ! test -L ~/.config/alacritty && [ -d ~/.config/alacritty ] ;then
echo " - $HOME/.config/alacritty/"
fi
if ! test -L ~/.config/starship && [ -d ~/.config/starship ] ;then
echo " - $HOME/.config/starship/"
fi
if ! test -L ~/.config/picom && [ -d ~/.config/picom ] ;then
echo " - $HOME/.config/picom/"
fi
if ! test -L ~/.config/nvim && [ -d ~/.config/nvim ] ;then
echo " - $HOME/.config/nvim/"
fi
if ! test -L ~/.config/vim && [ -d ~/.config/vim ] ;then
echo " - $HOME/.config/vim/"
fi
if ! test -L ~/.config/dunst && [ -d ~/.config/dunst ] ;then
echo " - $HOME/.config/dunst/"
fi
if ! test -L ~/.config/swappy && [ -d ~/.config/swappy ] ;then
echo " - $HOME/.config/swappy/"
fi
# Start Backup
if gum confirm "Do you want to create a backup?" ;then
if [ ! -z "$(ls -A ~/dotfiles-versions/backup)" ] ;then
if gum confirm "Do you want to archive the existing backup?" ;then
rsync -a ~/dotfiles-versions/backup/ ~/dotfiles-versions/archive/$datets/
echo ":: Current backup archived in ~/dotfiles-versions/archive/$datets"
fi
if [ ! -d ~/dotfiles-versions/backups/$datets ]; then
mkdir ~/dotfiles-versions/backups/$datets
echo "~/dotfiles-versions/backups/$datets created"
fi
if [ -d ~/dotfiles ]; then
rsync -a ~/dotfiles/ ~/dotfiles-versions/backups/$datets/
echo ":: Backup of your current dotfiles in ~/dotfiles-versions/backups/$datets created."
rsync -a ~/dotfiles ~/dotfiles-versions/backup/
echo ":: Backup of $HOME/dotfiles created in ~/dotfiles-versions/backup"
fi
if [ -f ~/.bashrc ]; then
cp ~/.bashrc ~/dotfiles-versions/backups/$datets/.bashrc-old
echo ":: Existing .bashrc file found in homefolder. .bashrc-old created"
if ! test -L ~/.bashrc ;then
cp ~/.bashrc ~/dotfiles-versions/backup
echo ":: Backup of $HOME/.bashrc created in ~/dotfiles-versions/backup"
fi
if [ ! -d ~/dotfiles-versions/backup/config ] ;then
mkdir ~/dotfiles-versions/backup/config
fi
if ! test -L ~/.config/qtile && [ -d ~/.config/qtile ] ;then
cp ~/.config/qtile ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/qtile created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/hypr && [ -d ~/.config/hypr ] ;then
cp ~/.config/hypr ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/hypr created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/qtile && [ -d ~/.config/rofi ] ;then
cp ~/.config/rofi ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/rofi created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/wal && [ -d ~/.config/wal ] ;then
cp ~/.config/wal ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/wal created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/waybar && [ -d ~/.config/waybar ] ;then
cp ~/.config/waybar ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/waybar created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/wlogout && [ -d ~/.config/wlogout ] ;then
cp ~/.config/wlogout ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/wlogout created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/alacritty && [ -d ~/.config/alacritty ] ;then
cp ~/.config/alacritty ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/alacritty created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/starship && [ -d ~/.config/starship ] ;then
cp ~/.config/starship ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/starship created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/picom && [ -d ~/.config/picom ] ;then
cp ~/.config/picom ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/picom created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/nvim && [ -d ~/.config/nvim ] ;then
cp ~/.config/nvim ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/nvim created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/vim && [ -d ~/.config/vim ] ;then
cp ~/.config/vim ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/vim created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/dunst && [ -d ~/.config/dunst ] ;then
cp ~/.config/dunst ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/dunst created in ~/dotfiles-versions/backup/config/"
fi
if ! test -L ~/.config/swappy && [ -d ~/.config/swappy ] ;then
cp ~/.config/swappy ~/dotfiles-versions/backup/config
echo ":: Backup of $HOME/.config/swappy created in ~/dotfiles-versions/backup/config/"
fi
echo
echo ":: PLEASE NOTE: You can create a fresh installation of teh dotfiles by removing the folder ~/dotfiles"
elif [ $? -eq 130 ]; then
exit 130
else
echo ":: Backup skipped."
fi
echo ""
else
echo ":: Nothing to backup"
fi
echo

View File

@ -5,13 +5,13 @@ echo -e "${GREEN}"
figlet "Preparation"
echo -e "${NONE}"
if [ -d ~/.config ]; then
echo ".config folder already exists."
echo ":: $HOME/.config folder already exists."
else
mkdir ~/.config
echo ".config folder created."
echo ":: $HOME/.config folder created."
fi
echo
echo ":: Preparing temporary folders for the installation."
echo "Preparing temporary folders for the installation."
if [ ! -d ~/dotfiles-versions ]; then
mkdir ~/dotfiles-versions
echo ":: ~/dotfiles-versions folder created."
@ -32,5 +32,5 @@ if [[ $(_isFolderEmpty ~/dotfiles-versions/$version/) == 0 ]] ;then
echo "Execution of rsync -a -I --exclude-from=.install/includes/excludes.txt . ~/dotfiles-versions/$version/ is required."
exit
fi
echo ":: dotfiles $version successfully prepared in ~/dotfiles-versions/$version/"
echo ""
echo ":: ML4W Dotfiles $version successfully prepared in ~/dotfiles-versions/$version/"
echo

View File

@ -4,12 +4,11 @@
# Synchronize packages
sudo pacman -Sy
echo ""
echo
# Check for required packages
echo ":: Checking that required packages for the installation are installed..."
echo "Checking that required packages for the installation are installed..."
_installPackagesPacman "rsync" "gum" "figlet" "python";
echo ""
# Double check rsync
if ! command -v rsync &> /dev/null; then
@ -18,4 +17,4 @@ if ! command -v rsync &> /dev/null; then
else
echo ":: rsync double checked"
fi
echo ""
echo

View File

@ -5,7 +5,13 @@
echo -e "${GREEN}"
figlet "System Update"
echo -e "${NONE}"
echo "It's important that your system is up-to-date before you proceed with the installation of the ML4W Dotfiles."
if gum confirm "Do you want to update the packages of your system with yay now?" ;then
echo "It's important that your system is up-to-date before you proceed."
if gum confirm "Do you want to update your system with yay now?" ;then
echo ":: Update started"
yay
elif [ $? -eq 130 ]; then
exit 130
else
echo ":: System update skipped"
fi
echo

View File

@ -14,11 +14,11 @@ if [ ! -z $1 ]; then
fi
echo -e "${GREEN}"
cat <<"EOF"
__ __ _ _ ___ __ _ _ __ _ _
| \/ | | | || \ \ / / __| | ___ | |_ / _(_) | ___ ___
| |\/| | | | || |\ \ /\ / / / _` |/ _ \| __| |_| | |/ _ \/ __|
| | | | |__|__ _\ V V / | (_| | (_) | |_| _| | | __/\__ \
|_| |_|_____| |_| \_/\_/ \__,_|\___/ \__|_| |_|_|\___||___/
__ __ _ _ ___ __ ____ _ __ _ _
| \/ | | | || \ \ / / | _ \ ___ | |_ / _(_) | ___ ___
| |\/| | | | || |\ \ /\ / / | | | |/ _ \| __| |_| | |/ _ \/ __|
| | | | |__|__ _\ V V / | |_| | (_) | |_| _| | | __/\__ \
|_| |_|_____| |_| \_/\_/ |____/ \___/ \__|_| |_|_|\___||___/
EOF
echo -e "${NONE}"
@ -27,8 +27,8 @@ echo "Version: $version"
echo "by Stephan Raabe 2024"
echo ""
if [ -d ~/dotfiles ] ;then
echo "A ML4W dotfiles installation has been detected."
echo "This script will guide you through the update process of the ML4W dotfiles."
echo "A ML4W Dotfiles installation has been detected."
echo "This script will guide you through the update process of the ML4W Dotfiles."
else
echo "This script will guide you through the installation process of the ML4W dotfiles."
fi