forked from Shinonome/dots-hyprland
install.sh : Add an option to create config and local backup (#756)
Thank you for the work!
This commit is contained in:
+35
-23
@@ -7,33 +7,45 @@ source ./scriptdata/installers
|
|||||||
source ./scriptdata/options
|
source ./scriptdata/options
|
||||||
|
|
||||||
#####################################################################################
|
#####################################################################################
|
||||||
if ! command -v pacman >/dev/null 2>&1;then printf "\e[31m[$0]: pacman not found, it seems that the system is not ArchLinux or Arch-based distros. Aborting...\e[0m\n";exit 1;fi
|
if ! command -v pacman >/dev/null 2>&1; then
|
||||||
|
printf "\e[31m[$0]: pacman not found, it seems that the system is not ArchLinux or Arch-based distros. Aborting...\e[0m\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
prevent_sudo_or_root
|
prevent_sudo_or_root
|
||||||
startask (){
|
|
||||||
printf "\e[34m[$0]: Hi there! Before we start:\n"
|
startask () {
|
||||||
printf 'This script 1. only works for ArchLinux and Arch-based distros.\n'
|
printf "\e[34m[$0]: Hi there! Before we start:\n"
|
||||||
printf ' 2. does not handle system-level/hardware stuff like Nvidia drivers\n'
|
printf 'This script 1. only works for ArchLinux and Arch-based distros.\n'
|
||||||
printf "\e[31m"
|
printf ' 2. does not handle system-level/hardware stuff like Nvidia drivers\n'
|
||||||
printf "Please CONFIRM that you HAVE ALREADY BACKED UP \"$XDG_CONFIG_HOME\" and \"$HOME/.local/\" folders!\n"
|
printf "\e[31m"
|
||||||
printf "\e[0m"
|
|
||||||
printf "Enter capital \"YES\" (without quotes) to continue:"
|
printf "Would you like to create a backup for \"$XDG_CONFIG_HOME\" and \"$HOME/.local/\" folders?\n[y/N]: "
|
||||||
read -p " " p
|
read -p " " backup_confirm
|
||||||
case $p in "YES")sleep 0;; *)echo "Received \"$p\", aborting...";exit 1;;esac
|
case $backup_confirm in
|
||||||
printf '\n'
|
[yY][eE][sS]|[yY])
|
||||||
printf 'Do you want to confirm every time before a command executes?\n'
|
backup_configs
|
||||||
printf ' y = Yes, ask me before executing each of them. (DEFAULT)\n'
|
;;
|
||||||
printf ' n = No, just execute them automatically.\n'
|
*)
|
||||||
printf ' a = Abort.\n'
|
echo "Skipping backup..."
|
||||||
read -p "====> " p
|
;;
|
||||||
case $p in
|
esac
|
||||||
n)ask=false;;
|
|
||||||
a)exit 1;;
|
|
||||||
*)ask=true;;
|
printf '\n'
|
||||||
esac
|
printf 'Do you want to confirm every time before a command executes?\n'
|
||||||
|
printf ' y = Yes, ask me before executing each of them. (DEFAULT)\n'
|
||||||
|
printf ' n = No, just execute them automatically.\n'
|
||||||
|
printf ' a = Abort.\n'
|
||||||
|
read -p "====> " p
|
||||||
|
case $p in
|
||||||
|
n) ask=false ;;
|
||||||
|
a) exit 1 ;;
|
||||||
|
*) ask=true ;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
case $ask in
|
case $ask in
|
||||||
false)sleep 0;;
|
false)sleep 0 ;;
|
||||||
*)startask ;;
|
*)startask ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,5 @@ XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache}
|
|||||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
|
XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config}
|
||||||
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
|
XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}
|
||||||
XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state}
|
XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state}
|
||||||
|
BACKUP_DIR=${BACKUP_DIR:-$HOME/backup}
|
||||||
|
|
||||||
|
|||||||
@@ -72,3 +72,14 @@ function prevent_sudo_or_root(){
|
|||||||
root)echo -e "\e[31m[$0]: This script is NOT to be executed with sudo or as root. Aborting...\e[0m";exit 1;;
|
root)echo -e "\e[31m[$0]: This script is NOT to be executed with sudo or as root. Aborting...\e[0m";exit 1;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function backup_configs() {
|
||||||
|
local backup_dir="$BACKUP_DIR"
|
||||||
|
mkdir -p "$backup_dir"
|
||||||
|
echo "Backing up $XDG_CONFIG_HOME to $backup_dir/config_backup"
|
||||||
|
rsync -av --progress "$XDG_CONFIG_HOME/" "$backup_dir/config_backup/"
|
||||||
|
|
||||||
|
echo "Backing up $HOME/.local to $backup_dir/local_backup"
|
||||||
|
rsync -av --progress "$HOME/.local/" "$backup_dir/local_backup/"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user