INSTALL.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. # Directories to backup
  3. BACKUP_DIRS="$HOME/.config/alacritty
  4. $HOME/.config/awesome
  5. $HOME/.config/bspwm
  6. $HOME/.config/cagebreak
  7. $HOME/.config/cava
  8. $HOME/.config/cmus
  9. $HOME/.config/colorls
  10. $HOME/.config/dunst
  11. $HOME/.config/elinks
  12. $HOME/.config/feh
  13. $HOME/.config/git
  14. $HOME/.config/leafpad
  15. $HOME/.config/mpd
  16. $HOME/.config/msmtp
  17. $HOME/.config/mutt
  18. $HOME/.config/ncmpc
  19. $HOME/.config/ncmpcpp
  20. $HOME/.config/neofetch
  21. $HOME/.config/notmuch
  22. $HOME/.config/stalonetray
  23. $HOME/.config/steck
  24. $HOME/.config/sway
  25. $HOME/.config/sx
  26. $HOME/.config/sxhkd
  27. $HOME/.config/sxiv
  28. $HOME/.config/systemd
  29. $HOME/.config/terminator
  30. $HOME/.config/termite
  31. $HOME/.config/tig
  32. $HOME/.config/tmux
  33. $HOME/.config/htop"
  34. # Check if stow is already installed
  35. if [ "$(command -v stow)" ]; then
  36. echo "stow is already installed"
  37. else
  38. # Check which package manager to use based on distribution
  39. if [ -x "$(command -v apt-get)" ]; then
  40. # Debian-based system
  41. sudo apt-get update && sudo apt-get install -y stow
  42. elif [ -x "$(command -v pacman)" ]; then
  43. # Archlinux-based system
  44. sudo pacman -Syu --noconfirm && sudo pacman -S --noconfirm stow
  45. elif [ -x "$(command -v yum)" ]; then
  46. # Redhat-based system
  47. sudo yum update && sudo yum install -y stow
  48. else
  49. echo "Unable to determine package manager for this distribution"
  50. exit 1
  51. fi
  52. echo "stow has been installed successfully"
  53. fi
  54. # Check if the script is being run inside the specified Git repository
  55. if [ "$(git config --get remote.origin.url)" != "git@github.com:Awan/cfg.git" ]; then
  56. echo "This script must be run inside the https://github.com/Awan/cfg.git repository"
  57. exit 1
  58. else
  59. echo "The script is being run inside the https://github.com/Awan/cfg.git repository"
  60. fi
  61. # Check if backup directories exist, and if so, prompt user to backup before continuing
  62. for dir in $BACKUP_DIRS; do
  63. if [ -d "$dir" ]; then
  64. echo "Directory $dir already exists"
  65. read -p "Do you want to back up the existing directory? (y/n) " choice
  66. case "$choice" in
  67. y|Y|yes|YES ) echo "Backing up directory $dir..."
  68. mv "$dir" "$dir.bkp"
  69. echo "Directory $dir has been backed up to $dir.bkp";;
  70. n|N|no|NO ) echo "Skipping backup of directory $dir";;
  71. * ) echo "Invalid input, skipping backup of directory $dir";;
  72. esac
  73. fi
  74. done
  75. exit 0