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.

118 lines
3.0 KiB

2 years ago
  1. #!/bin/sh
  2. DIR="$(realpath "$(dirname "$0")")"
  3. root_setup() {
  4. # script must start at home directory
  5. cd "$HOME" || exit 1;
  6. usertest() {
  7. if test "$(id -u)" -ne 0; then
  8. echo "You must run this script as root.";
  9. exit 1;
  10. fi
  11. }
  12. createuser() {
  13. printf 'full name: ' >&2
  14. read -r NAME
  15. printf 'login: ' >&2
  16. read -r LOGIN
  17. adduser -g "$NAME" "$LOGIN" || exit 1
  18. adduser "$LOGIN" video || exit 1
  19. adduser "$LOGIN" input || exit 1
  20. adduser "$LOGIN" wheel || exit 1
  21. adduser root wheel || exit 1
  22. }
  23. installdoas() {
  24. apk add doas
  25. echo "permit nopass :wheel" >> /etc/doas.d/doas.conf
  26. }
  27. usertest && createuser && installdoas
  28. }
  29. user_setup() {
  30. cd "$HOME" || exit 1;
  31. if ! (apk list | grep 'doas' 2>&1) > /dev/null; then
  32. echo "doas is not installed.";
  33. exit 1
  34. fi
  35. dev() {
  36. echo "Developer tools..."
  37. doas apk add git make python3 nodejs npm go cargo g++ gcc curl bash shadow || exit 1
  38. }
  39. sysinfo() {
  40. echo "Dylan Araps scripts"
  41. cd "$HOME" || exit 1;
  42. mkdir -p repos
  43. git clone https://github.com/dylanaraps/pfetch "$HOME/repos/pfetch"
  44. git clone https://github.com/dylanaraps/neofetch "$HOME/repos/neofetch"
  45. git clone https://github.com/dylanaraps/fff "$HOME/repos/fff"
  46. cd "$HOME/repos/pfetch" || exit 1;
  47. doas make install || exit 2;
  48. cd "$HOME" || exit 1;
  49. cd "$HOME/repos/neofetch" || exit 1;
  50. doas make install || exit 2;
  51. cd "$HOME" || exit 1;
  52. cd "$HOME/repos/fff" || exit 1;
  53. doas make install || exit 2;
  54. cd "$HOME" || exit 1;
  55. }
  56. dotfiles() {
  57. echo "Adding zsh and tmux configs"
  58. # zsh plugins
  59. doas apk add zsh tmux shellcheck fzf
  60. sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  61. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
  62. # dotfiles
  63. if ! test -d "$DIR/dots"; then
  64. echo "$DIR/dots folder not found.";
  65. exit 1;
  66. fi
  67. cp "$DIR/dots/zshrc" "$HOME/.zshrc"
  68. cp "$DIR/dots/tmux.conf" "$HOME/.tmux.conf"
  69. mkdir -p "$HOME/.local/bin" || exit 1
  70. cp -r "$DIR/scripts/." "$HOME/.local/bin/" || exit 1
  71. }
  72. neovim() {
  73. # install neovim
  74. doas apk add neovim tree-sitter tree-sitter-cli
  75. git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim || exit 1
  76. git clone https://git.junickim.me/junikimm717/nvim2023 ~/.config/nvim || exit 1
  77. nvim -c PackerSync -c 'sleep 10' -c qa --headless
  78. echo "sleeping to compile"
  79. nvim -c 'sleep 60' -c qa --headless
  80. }
  81. competitiveprogramming() {
  82. echo "CP..."
  83. git clone https://git.junickim.me/junikimm717/linuxcp "$HOME/cp"
  84. go install git.junickim.me/junikimm717/cpgo@latest
  85. }
  86. (dev && sysinfo && dotfiles && neovim) || exit 1
  87. }
  88. if test $# -eq 0; then
  89. echo "at least one argument: root or user" && exit 1
  90. fi
  91. case $1 in
  92. root|r)
  93. root_setup
  94. ;;
  95. user|u)
  96. user_setup
  97. ;;
  98. *)
  99. echo "Invalid option $1"
  100. exit 1
  101. ;;
  102. esac