setup.sh 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #!/bin/bash
  2. # Location: $HOME/dots
  3. # User Scope: user
  4. # Run as: ./setup.sh <arg>
  5. # Script to setup terminal environment
  6. if [ $# -ne 1 ]; then
  7. echo "::[Dots Setup Script]::"
  8. echo "Usage: setup.sh <prompt to use: seafly|parrot|powerline>"
  9. exit 1
  10. fi
  11. host=$(hostname)
  12. hostname="${host^^}"
  13. repo_directory="/opt/qconfig"
  14. main_user=$USER
  15. user_prompt="$1"
  16. # Set Permissions
  17. chmod 660 $(find ./ -type f)
  18. chmod 660 $(find "$HOME/.bashrc" -type f)
  19. chmod 770 $(find "$HOME/dots" -type d)
  20. function add_string_to_file() {
  21. # Checks if a string is in a file
  22. # adds it if it isn't in that file
  23. local file="$1"
  24. local string="$2"
  25. if ! grep -q "$string" "$file"; then
  26. echo "$string" >> "$file"
  27. fi
  28. }
  29. # Bashrc
  30. add_string_to_file "$HOME/.bashrc" "source $HOME/dots/default_aliases"
  31. add_string_to_file "$HOME/.bashrc" "source $HOME/dots/$user_prompt-prompt"
  32. # Bashrc for control
  33. if [ $main_user == "control" ]; then
  34. add_string_to_file "$HOME/.bashrc" "bash $HOME/dots/life.sh 1993-07-21 control"
  35. fi
  36. # NVIM
  37. mkdir -p "$HOME/.config/nvim/"
  38. cp "./nvim" "$HOME/.config/nvim/init.vim"
  39. # TMUX
  40. cp "./tmux.conf" "$HOME/.tmux.conf"
  41. # PATH VARS
  42. if [ -f "$HOME/.dots/user_paths" ]; then
  43. chmod 660 "$HOME/.dots/user_paths"
  44. add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_paths"
  45. fi
  46. if [ -f "$HOME/.dots/user_aliases" ]; then
  47. chmod 660 "$HOME/.dots/user_aliases"
  48. add_string_to_file "$HOME/.bashrc" "source $HOME/.dots/user_aliases"
  49. fi
  50. if [ -f "$repo_directory/user_paths" ]; then
  51. chmod 660 "$repo_directory/user_paths"
  52. add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_paths"
  53. fi
  54. if [ -f "$repo_directory/user_aliases" ]; then
  55. chmod 660 "$repo_directory/user_aliases"
  56. add_string_to_file "$HOME/.bashrc" "source $repo_directory/user_aliases"
  57. fi
  58. # Set System Aliases
  59. cp -f "/home/$main_user/dots/system_aliases" "/etc/system_aliases"
  60. add_string_to_file "/etc/bash.bashrc" "source /etc/system_aliases"
  61. # Source
  62. source "$HOME/.bashrc"