setup.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. #!/bin/bash
  2. set -e
  3. echo 'setup zsh'
  4. if [ ! -d "$HOME/.oh-my-zsh" ]
  5. then
  6. git clone https://github.com/ohmyzsh/ohmyzsh.git $HOME/.oh-my-zsh
  7. fi
  8. if [ ! -f "$HOME/.zshrc" ]
  9. then
  10. cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
  11. echo 'source $HOME/.profile' >> $HOME/.zshrc
  12. fi
  13. echo 'setup nodejs'
  14. if [ ! -d "$HOME/.nvm" ]
  15. then
  16. git clone https://github.com/nvm-sh/nvm.git $HOME/.nvm
  17. cat >> $HOME/.profile <<EOF
  18. export NVM_DIR="\$HOME/.nvm"
  19. [ -s "\$NVM_DIR/nvm.sh" ] && \. "\$NVM_DIR/nvm.sh"
  20. [ -s "\$NVM_DIR/bash_completion" ] && \. "\$NVM_DIR/bash_completion"
  21. EOF
  22. echo 'export PATH=$HOME/.yarn/bin:$PATH' >> $HOME/.profile
  23. fi
  24. cd $HOME/.nvm
  25. git checkout v0.39.2
  26. . $HOME/.nvm/nvm.sh
  27. if ! [ -x "$(command -v yarn)" ]
  28. then
  29. nvm install node
  30. nvm use node
  31. npm install yarn -g
  32. fi
  33. mkdir -p $HOME/.local/bin $HOME/local $HOME/downloads
  34. echo 'setup php'
  35. if [ ! -f "$HOME/downloads/composer" ]
  36. then
  37. wget -O $HOME/downloads/composer https://getcomposer.org/installer
  38. fi
  39. if [ ! -f "$HOME/.local/bin/composer" ]
  40. then
  41. cd $HOME/downloads
  42. php composer
  43. mv composer.phar $HOME/.local/bin/composer
  44. fi
  45. echo 'setup ssh'
  46. if [ ! -d $HOME/.ssh ]
  47. then
  48. mkdir $HOME/.ssh
  49. chmod 700 $HOME/.ssh
  50. cat /tmp/$USER.pub > $HOME/.ssh/authorized_keys
  51. fi
  52. echo 'setup workspace folder'
  53. if [ ! -L $HOME/www ]
  54. then
  55. ln -sf /workspace/www/$USER $HOME/www
  56. fi
  57. echo 'setup tmp folder'
  58. if [ ! -L $HOME/tmp ]
  59. then
  60. ln -sf /workspace/tmp/$USER $HOME/tmp
  61. fi
  62. echo 'setup tmux'
  63. if [ ! -f $HOME/.tmux.conf ]
  64. then
  65. echo 'set-option -g history-limit 102400' > $HOME/.tmux.conf
  66. echo 'set-option -g default-shell "/bin/zsh"' >> $HOME/.tmux.conf
  67. fi
  68. echo 'setup git'
  69. git config --global core.quotepath false
  70. git config --global http.version HTTP/1.1
  71. git config --global pull.rebase false
  72. echo "done."
  73. exit 0