installation scripts for servers.
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.

105 lines
2.7 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #!/bin/sh
  2. DIR="$(realpath "$(dirname "$0")")"
  3. # script must start at home directory
  4. cd "$HOME" || exit 1;
  5. usertest() {
  6. if test "$(id -u)" -eq 0; then
  7. echo "You cannot run this script as root.";
  8. exit 1;
  9. fi
  10. if ! (getent passwd junikim 2>&1) > /dev/null; then
  11. echo "User junikim must exist.";
  12. exit 1
  13. fi
  14. if ! (apk list | grep 'doas' 2>&1) > /dev/null; then
  15. echo "doas is not installed.";
  16. exit 1
  17. fi
  18. }
  19. dev() {
  20. echo "Developer tools..."
  21. doas apk add git make python3 nodejs npm neovim curl bash
  22. }
  23. sysinfo() {
  24. echo "Dylan Araps scripts"
  25. cd "$HOME" || exit 1;
  26. mkdir -p repos
  27. git clone https://github.com/dylanaraps/pfetch "$HOME/repos/pfetch"
  28. git clone https://github.com/dylanaraps/neofetch "$HOME/repos/neofetch"
  29. git clone https://github.com/dylanaraps/fff "$HOME/repos/fff"
  30. cd "$HOME/repos/pfetch" || exit 1;
  31. doas make install || exit 2;
  32. cd "$HOME" || exit 1;
  33. cd "$HOME/repos/neofetch" || exit 1;
  34. doas make install || exit 2;
  35. cd "$HOME" || exit 1;
  36. cd "$HOME/repos/fff" || exit 1;
  37. doas make install || exit 2;
  38. cd "$HOME" || exit 1;
  39. }
  40. shell() {
  41. echo "zsh installation and configuration as login shell"
  42. doas apk add zsh
  43. # set user permissions
  44. awk -F ':' -v OFS=':' '{
  45. if ($1 == "junikim") {
  46. print $1,$2,$3,$4,$5,$6,"/bin/zsh"
  47. } else {
  48. print $1,$2,$3,$4,$5,$6,$7
  49. }}' /etc/passwd > passwd.tmp
  50. doas mv passwd.tmp /etc/passwd
  51. # add starship and oh my zsh
  52. doas apk add starship
  53. }
  54. # neovim must be installed.
  55. plugins() {
  56. # install vim-plug, oh-my-zsh, and zsh-syntax-highlighting
  57. sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
  58. https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
  59. sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  60. git clone https://github.com/zsh-users/zsh-syntax-highlighting.git "$HOME/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
  61. }
  62. dotfiles() {
  63. echo "Adding vim and zsh configs"
  64. if ! test -d "$DIR/dotfiles"; then
  65. echo "$DIR/dotfiles folder not found.";
  66. exit 1;
  67. fi
  68. mkdir -p "$HOME/.config/nvim"
  69. cp "$DIR/dotfiles/.zshrc" "$HOME/.zshrc"
  70. cp "$DIR/dotfiles/init.vim" "$HOME/.config/nvim/init.vim"
  71. nvim --headless +PlugInstall +qa
  72. }
  73. competitiveprogramming() {
  74. echo "CP Compilers..."
  75. doas apk add g++
  76. doas apk add clang-dev
  77. cd "$HOME" || exit 1;
  78. git clone https://git.junickim.me/junikimm717/linuxcp "$HOME/cp"
  79. }
  80. (usertest && dev && sysinfo && shell && plugins && dotfiles) || exit 1
  81. cat <<EOF
  82. Stuff you should do now:
  83. - run :PlugInstall
  84. - add coc extensions
  85. - add in the competitive programming scripts (if you intend) by running the
  86. competitiveprogramming function
  87. EOF