Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

230 lines
6.1 KiB

  1. #!/bin/bash
  2. alias dots="git --git-dir=\$HOME/.dotfiles.git/ --work-tree=\$HOME"
  3. username=$(whoami)
  4. prev=$(pwd)
  5. verbose=0
  6. while getopts "v" OPTION
  7. do
  8. case $OPTION in
  9. v) verbose=1
  10. ;;
  11. *) echo "Only available option is -v" ;;
  12. esac
  13. done
  14. mvie(){
  15. if [ -e "$1" ];then
  16. rm -rf "$2"
  17. mv "$1" "$2"
  18. fi
  19. }
  20. info(){
  21. printf "[\e[32mINFO\e[0m]:%s\n" "$1"
  22. }
  23. debug(){
  24. if [ $verbose ]; then
  25. printf "[\e[33mDEBUG\e[0m]:%s\n" "$1"
  26. fi
  27. }
  28. error(){
  29. printf "[\e[31mERROR\e[0m]:%s\n" "$1"
  30. }
  31. prompt(){
  32. printf "[\e[35mPROMPT\e[0m]: %s" "$1"
  33. read -r ans
  34. printf "%s" "$ans"
  35. }
  36. echo "Running backup of old dotfiles"
  37. IFS="
  38. "
  39. # Backup Previous Dots
  40. info "Backing up your old dotfiles"
  41. ## Backup eveything in the git tree
  42. mkdir "$HOME/dots_backup"
  43. for i in $(dots ls-files); do
  44. if [ -f "$i" ]; then
  45. debug "$i"
  46. mkdir -p "$HOME/dots_backup/$(echo "$i" | sed "s/\/[^\/]*$//g")"
  47. mv "$i" "$HOME/dots_backup/$(echo "$i" | sed "s/\/[^\/]*$//g")"
  48. fi
  49. rm -rf "$i"
  50. done
  51. ## Theme and Icon Folders
  52. mvie ~/.themes ~/.dotfiles_backup/themes
  53. ln -s ~/.dotfiles/local/share/themes ~/.themes
  54. mvie ~/.icons ~/.dotfiles_backup/icons
  55. ln -s ~/.dotfiles/local/share/icons ~/.icons
  56. info "Checking out dotfiles"
  57. dots checkout
  58. # Configuring for your username
  59. if [ ! "$username" = "yigit" ]; then
  60. info "Replacing the occurences of /home/yigit with /home/$username"
  61. echo "Setting up the dotfiles according to your username"
  62. dots ls-files | xargs -L 1 sed -i "s/\/home\/yigit/\/home\/$username/g"
  63. fi
  64. info "Setting up sudo so that you won't be prompted for a password for the next of the script"
  65. # Don't prompt for a password for the rest of the script
  66. sudo bash -c 'echo "%wheel ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopwd'
  67. eval "$(grep -h -- \
  68. "^\s*\(export \)\?\(CARGO_HOME\|GOPATH\|ANDROID_HOME\|FLUTTER_HOME\|LEIN_HOME\|NVM_DIR\|GNUPGHOME\|WEECHAT_HOME\|JUPYTER_CONFIG_DIR\|PYLINTHOME\|XDG_DATA_HOME\|XDG_CONFIG_HOME\|XDG_CACHE_HOME\|_Z_DATA)=" \
  69. "$HOME/.profile" 2>/dev/null)"
  70. info "Creating relevant directories"
  71. # Create necessary folders
  72. mkdir -p "$HOME/.local/share/ncmpcpp/lyrics"
  73. mkdir -p "$HOME/.local/share/calcurse"
  74. mkdir -p "$CARGO_HOME"
  75. mkdir -p "$GOPATH"
  76. mkdir -p "$ANDROID_HOME"
  77. mkdir -p "$FLUTTER_HOME"
  78. mkdir -p "$LEIN_HOME"
  79. mkdir -p "$NVM_DIR"
  80. mkdir -p "$GNUPGHOME"
  81. mkdir -p "$WEECHAT_HOME"
  82. mkdir -p "$JUPYTER_CONFIG_DIR"
  83. mkdir -p "$PYLINTHOME"
  84. mkdir -p "$HOME/.local/share/zsh"
  85. mkdir -p "$XDG_DATA_HOME/mail"
  86. mkdir -p "$XDG_DATA_HOME/icons"
  87. mkdir -p "$XDG_DATA_HOME/themes"
  88. mkdir -p "$XDG_DATA_HOME/fonts"
  89. mkdir -p "$HOME/.local/backgrounds"
  90. mkdir -p "$XDG_CONFIG_HOME/git"
  91. mkdir -p "$XDG_CACHE_HOME/surf"
  92. mkdir -p "$HOME/.ssh"
  93. chmod 700 "$GNUPGHOME"
  94. touch "$XDG_CONFIG_HOME/git/config"
  95. touch "$_Z_DATA"
  96. # Install packages
  97. deps=$(prompt -n "Would you like to install all the necessary packages, not doing so might break most of the functionality?(Y/n): ")
  98. if [ ! "$deps" = "n" ]; then
  99. echo "Running update"
  100. yay -S --needed --noconfirm "$(cat ~/pkg.list)" && exit 1
  101. fi
  102. cp ~/.config/config.env.default ~/.config/config.env
  103. # Downloading assets
  104. ##Fonts
  105. echo "Downloading assets"
  106. curl https://minio.yigitcolakoglu.com/dotfiles/tools/mc > "$HOME/.local/bin/mc"
  107. chmod +x "$HOME/.local/bin/mc"
  108. "$HOME/.local/bin/mc" alias set fr1nge https://minio.yigitcolakoglu.com "" ""
  109. mc cp -r fr1nge/dotfiles/fonts/ ~/.local/share/fonts/
  110. mc cp -r fr1nge/dotfiles/backgrounds/ ~/.local/backgrounds/
  111. git clone https://github.com/material-ocean/Gtk-Theme.git "$XDG_DATA_HOME/themes/material-ocean"
  112. git clone https://github.com/vinceliuice/Tela-icon-theme.git /tmp/tela
  113. fc-cache
  114. # Setup Crontab
  115. if [ ! -f "/var/spool/cron/$username" ]; then
  116. crontab "$HOME/.config/crontab"
  117. else
  118. echo -n "An existing cron file is detected, would you like to overwrite it?(Y/n): "
  119. read -r cron
  120. if [ ! "$cron" = "n" ]; then
  121. crontab -l >> "$HOME/.config/crontab"
  122. crontab "$HOME/.config/crontab"
  123. fi
  124. fi
  125. # Root Files and Directories
  126. if [ "$(grep artix < "$(uname -a)")" = "" ]; then
  127. sudo rc-update add quark
  128. else
  129. sudo systemctl enable quark
  130. sudo systemctl daemon-reload
  131. fi
  132. if [ "$username" = "yigit" ]; then
  133. ~/.dotfiles/arch-setup/fetch_keys.sh # Fetch keys (For personal use, this is not for you)
  134. mkdir -p "$XDG_DATA_HOME/mail/yigitcolakoglu@hotmail.com"
  135. git config --global user.email "yigitcolakoglu@hotmail.com"
  136. git config --global user.name "Yigit Colakoglu"
  137. fi
  138. # Setup for pam-gnupg
  139. cat << EOF | sudo tee -a /etc/pam.d/system-local-login
  140. session optional pam_env.so user_readenv=1
  141. auth optional pam_gnupg.so store-only
  142. session optional pam_gnupg.so
  143. EOF
  144. # Build and Install Everything
  145. ## Suckless utilities
  146. info "Installing suckless utilities"
  147. (cd ~/.local/src; ./build.sh > /dev/null 2> /dev/null)
  148. sudo groupadd nogroup
  149. ## Tela Icons
  150. info "Installing Icons"
  151. /tmp/tela/install.sh > /dev/null 2> /dev/null
  152. ## Start page
  153. info "Setting up start page"
  154. prev=$(pwd)
  155. cd ~/.local/share/startpage
  156. sudo npm install -g parcel-bundler
  157. npm install > /dev/null 2> /dev/null
  158. npm run build > /dev/null 2> /dev/null
  159. cd $prev
  160. # Vim and tmux plugins
  161. mkdir -p ~/.tmux/plugins
  162. vim +PlugInstall +qall
  163. cd ~/.config/coc/extensions
  164. yarn
  165. cd $prev
  166. # Install mconnect
  167. info "Installing mconnect"
  168. git clone https://github.com/theFr1nge/mconnect.git /tmp/mconnect.git > /dev/null 2> /dev/null
  169. cd /tmp/mconnect.git
  170. mkdir -p build
  171. cd build
  172. meson .. > /dev/null 2> /dev/null
  173. ninja > /dev/null 2> /dev/null
  174. sudo ninja install > /dev/null 2> /dev/null
  175. cd $prev
  176. mkdir -p ~/Downloads/mconnect
  177. ## Simcrop
  178. info "Installing simcrop"
  179. git clone https://github.com/theFr1nge/simcrop.git /tmp/simcrop > /dev/null 2> /dev/null
  180. cd /tmp/simcrop
  181. sudo make install > /dev/null 2> /dev/null
  182. cd $prev
  183. # Do a cleanup and delete some problematic files
  184. rm -rf ~/.fzf*
  185. rm -rf ~/.bash_profile
  186. rm -rf ~/.dotfiles/yarn.lock
  187. rm -rf ~/.dotfiles/.git/hooks/*
  188. rm -rf ~/install.sh
  189. rm -rf ~/README.md
  190. rm -rf ~/pkg.list
  191. dots update-index --assume-unchanged {pkg.list,install.sh,README.md}
  192. dots config --local status.showUntrackedFiles no
  193. sudo rm -rf /etc/urlview/system.urlview
  194. echo "I am now restarting your system so that the configurations changes apply"
  195. sleep 5
  196. sudo bash -c "rm -rf /etc/sudoers.d/nopwd; reboot"