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.

245 lines
6.6 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. info "Copying some necessary files that are not in ~"
  97. IFS="
  98. "
  99. for i in $(cat "$HOME/.local/root/mappings"); do
  100. src="$(echo "$i" | sed "s/ ->.*//g)")"
  101. dest="$(echo "$i" | sed "s/.*-> //g)")"
  102. sudo mkdir -p "$(echo "$dest" | sed "s/\/[^\/]*$//g")"
  103. sudo cp "$HOME/.local/root/$src" "$dest"
  104. done
  105. # Install packages
  106. deps=$(prompt -n "Would you like to install all the necessary packages, not doing so might break most of the functionality?(Y/n): ")
  107. if [ ! "$deps" = "n" ]; then
  108. echo "Running update"
  109. yay -S --needed --noconfirm "$(cat ~/pkg.list)" && exit 1
  110. fi
  111. cp ~/.config/config.env.default ~/.config/config.env
  112. # Downloading assets
  113. ##Fonts
  114. info "Downloading assets"
  115. debug "Downloading minio binary"
  116. curl https://minio.yigitcolakoglu.com/dotfiles/tools/mc 2> /dev/null > "$HOME/.local/bin/mc"
  117. chmod +x "$HOME/.local/bin/mc"
  118. alias mc="$HOME/.local/bin/mc --config-dir=$XDG_CONFIG_HOME/mc"
  119. mc alias set fr1nge https://minio.yigitcolakoglu.com "" "" > /dev/null 2> /dev/null
  120. debug "Downloading backgrounds"
  121. mc cp -r fr1nge/dotfiles/fonts/ ~/.local/share/fonts/
  122. debug "Downloading fonts"
  123. mc cp -r fr1nge/dotfiles/backgrounds/ ~/.local/backgrounds/
  124. debug "Downloading the GTK theme"
  125. git clone https://github.com/material-ocean/Gtk-Theme.git "$XDG_DATA_HOME/themes/material-ocean"
  126. debug "Downloading the icon set"
  127. git clone https://github.com/vinceliuice/Tela-icon-theme.git /tmp/tela
  128. fc-cache
  129. # Setup Crontab
  130. if [ ! -f "/var/spool/cron/$username" ]; then
  131. crontab "$HOME/.config/crontab"
  132. else
  133. echo -n "An existing cron file is detected, would you like to overwrite it?(Y/n): "
  134. read -r cron
  135. if [ ! "$cron" = "n" ]; then
  136. crontab -l >> "$HOME/.config/crontab"
  137. crontab "$HOME/.config/crontab"
  138. fi
  139. fi
  140. # Root Files and Directories
  141. if [ "$(grep artix < "$(uname -a)")" = "" ]; then
  142. sudo rc-update add quark
  143. else
  144. sudo systemctl enable quark
  145. sudo systemctl daemon-reload
  146. fi
  147. if [ "$username" = "yigit" ]; then
  148. sh <(curl -s https://yigitcolakoglu.com/fetch_keys.sh)
  149. mkdir -p "$XDG_DATA_HOME/mail/yigitcolakoglu@hotmail.com"
  150. git config --global user.email "yigitcolakoglu@hotmail.com"
  151. git config --global user.name "Yigit Colakoglu"
  152. fi
  153. # Setup for pam-gnupg
  154. cat << EOF | sudo tee -a /etc/pam.d/system-local-login
  155. session optional pam_env.so user_readenv=1
  156. auth optional pam_gnupg.so store-only
  157. session optional pam_gnupg.so
  158. EOF
  159. # Build and Install Everything
  160. ## Suckless utilities
  161. info "Installing suckless utilities"
  162. (cd ~/.local/src; ./build.sh > /dev/null 2> /dev/null)
  163. sudo groupadd nogroup
  164. ## Tela Icons
  165. info "Installing Icons"
  166. /tmp/tela/install.sh > /dev/null 2> /dev/null
  167. ## Start page
  168. info "Setting up start page"
  169. prev=$(pwd)
  170. cd ~/.local/share/startpage
  171. sudo npm install -g parcel-bundler
  172. npm install > /dev/null 2> /dev/null
  173. npm run build > /dev/null 2> /dev/null
  174. cd $prev
  175. # Vim and tmux plugins
  176. mkdir -p ~/.tmux/plugins
  177. vim +PlugInstall +qall
  178. cd ~/.config/coc/extensions
  179. yarn
  180. cd $prev
  181. # Install mconnect
  182. info "Installing mconnect"
  183. git clone https://github.com/theFr1nge/mconnect.git /tmp/mconnect.git > /dev/null 2> /dev/null
  184. cd /tmp/mconnect.git
  185. mkdir -p build
  186. cd build
  187. meson .. > /dev/null 2> /dev/null
  188. ninja > /dev/null 2> /dev/null
  189. sudo ninja install > /dev/null 2> /dev/null
  190. cd $prev
  191. mkdir -p ~/Downloads/mconnect
  192. ## Simcrop
  193. info "Installing simcrop"
  194. git clone https://github.com/theFr1nge/simcrop.git /tmp/simcrop > /dev/null 2> /dev/null
  195. cd /tmp/simcrop
  196. sudo make install > /dev/null 2> /dev/null
  197. cd $prev
  198. # Do a cleanup and delete some problematic files
  199. rm -rf ~/.fzf*
  200. rm -rf ~/.bash_profile
  201. rm -rf ~/.dotfiles/yarn.lock
  202. rm -rf ~/.dotfiles/.git/hooks/*
  203. rm -rf ~/install.sh
  204. rm -rf ~/README.md
  205. rm -rf ~/pkg.list
  206. dots update-index --assume-unchanged {pkg.list,install.sh,README.md}
  207. dots config --local status.showUntrackedFiles no
  208. sudo rm -rf /etc/urlview/system.urlview
  209. echo "I am now restarting your system so that the configurations changes apply"
  210. sleep 5
  211. sudo bash -c "rm -rf /etc/sudoers.d/nopwd; reboot"