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.

253 lines
6.7 KiB

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