forked from qmee/environment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux
182 lines (156 loc) · 5.97 KB
/
linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
if [[ -f $HOME/.zshrc ]]; then source $HOME/.zshrc; fi
echo "Installing dev-tools"
sudo apt install build-essential
sudo apt install curl
sudo apt install git
sudo apt install docker.io
sudo apt install docker
sudo usermod -aG docker $USER
echo "installing homebrew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# Adding brew to current running env (It gets add into PATH via zsh)
eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv)
echo "update homebrew apps"
# Make sure we’re using the latest Homebrew
brew update --verbose
brew doctor
# Upgrade any already installed formulae
brew outdated
brew upgrade
if [[ -z $(brew list | grep wget) ]]; then
brew install wget
brew tap Homebrew/bundle
fi
wget -nv https://raw.githubusercontent.com/qmee/environment/master/BrewfileLinux -O $HOME/linuxenv/Brewfile
cd $HOME/linuxenv
brew bundle --verbose
# Remove outdated versions
brew cleanup
echo "configuring zsh"
if [ $SHELL != $(which zsh) ] && [[ -z $(sudo cat /etc/shells | grep $(which zsh)) ]]; then
echo "add homebrew zsh to shells"
sudo sh -c "echo $(which zsh) >> /etc/shells"
fi
if type brew &>/dev/null; then
echo "Setting zsh autocompletions"
FPATH=$(brew --prefix)/share/zsh-completions:$FPATH
autoload -Uz compinit
compinit
fi
echo "docker containers"
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# Starting Docker on boot
sudo systemctl enable docker
# Start Docker
sudo systemctl start docker
read -p "Do you want to configure Qmee Docker services now? [y,n] (Select 'y' ONLY if not using QM later)" -n1 -s CFG_DOCKER
if [[ "$CFG_DOCKER" == "y" ]]; then
wget -nv https://raw.githubusercontent.com/qmee/environment/master/docker-compose.yml -O $HOME/linuxenv/docker-compose.yml
cd $HOME/linuxenv
sudo docker-compose pull
sudo docker-compose up -d
sudo docker system prune --force --all
sudo docker volume prune --force
fi
echo "simulating pbcopy on Linux"
sudo apt-get install xclip -y
echo "#pbcopy & pbpaste aliases" >> ~/.zshrc
echo "alias pbcopy='xclip -selection clipboard'" >> ~/.zshrc
echo "alias pbpaste='xclip -selection clipboard -o'" >> ~/.zshrc
source ~/.zshrc
echo "checking for SSH key, generating one if it does not exist and add to github ..."
if [[ ! -f $HOME/.ssh/id_rsa.pub ]]; then
ssh-keygen -t rsa -b 4096
cat $HOME/.ssh/id_rsa.pub | pbcopy
xdg-open https://github.com/account/ssh
read -p "Press any key once you have pasted into your Github account..." -n1 -s
fi
echo "installing vs-code & extensions"
sudo apt install code
code --install-extension eamodio.gitlens
code --install-extension ms-python.python
code --install-extension rebornix.ruby
code --install-extension ms-azuretools.vscode-docker
code --install-extension mjmcloug.vscode-elixir
if [[ ! -f $HOME/.dotfiles/zshrc ]]; then
echo "install dotfiles"
git clone [email protected]:qmee/dotfiles_linux.git $HOME/.dotfiles
cd $HOME/.dotfiles
rake install
fi
echo "docker zsh completions"
if [[ ! -d $HOME/.zsh/completions ]]; then
cd $HOME/.zsh
mkdir completions
fi
wget -nv https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker -O $HOME/.zsh/completions/_docker
wget -nv https://raw.githubusercontent.com/docker/machine/master/contrib/completion/zsh/_docker-machine -O $HOME/.zsh/completions/_docker-machine
wget -nv https://raw.githubusercontent.com/docker/compose/master/contrib/completion/zsh/_docker-compose -O $HOME/.zsh/completions/_docker-compose
echo "Setting up Heroku"
sudo snap install --classic heroku
if [[ -z $(/snap/bin/heroku plugins | grep 'heroku-pg-extras') ]]; then
/snap/bin/heroku plugins:install heroku-pg-extras
heroku autocomplete
else
/snap/bin/heroku update
fi
echo "vim Vundle"
if [[ ! -d $HOME/.vim/bundle/Vundle.vim ]]; then
git clone https://github.com/VundleVim/Vundle.vim.git $HOME/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
else
vundle-update
fi
if [[ ! -f $HOME/.vim/bundle/command-t/ruby/command-t/ext/command-t/metadata.rb ]]; then
echo "build Command-T plugin"
cd $HOME/.vim/bundle/command-t
rake make
fi
if [[ ! -d $HOME/development ]]; then
echo "create development directory"
cd $HOME
mkdir development
fi
if [[ ! -d $HOME/development/snipmate-snippets ]]; then
echo "install snippets"
git clone git://github.com/scrooloose/snipmate-snippets.git $HOME/development/snipmate-snippets
sed -i -e 's/snipmate/snipmate.vim/g' $HOME/development/snipmate-snippets/Rakefile
cd $HOME/development/snipmate-snippets
rake deploy_local
fi
echo "latest ruby"
source $(brew --prefix chruby)/share/chruby/chruby.sh
source $(brew --prefix chruby)/share/chruby/auto.sh
cd $HOME/development
ruby_latest_version="$(curl -q -s https://raw.githubusercontent.com/postmodern/ruby-versions/master/ruby/stable.txt | tail -1)"
ruby_current_version="$(cat .ruby-version)"
if [[ $ruby_latest_version = $ruby_current_version ]]; then
echo "Latest ruby installed - Updating rubygems"
gem update --system --no-document
gem update bundler
gem clean
else
ruby-install "ruby $ruby_latest_version" -- --disable-install-rdoc
rm -rf $HOME/src
rm -rf $HOME/.rubies/ruby-$ruby_current_version
rm -rf $HOME/.gem/ruby/$ruby_current_version
echo "$ruby_latest_version" > .ruby-version
source $(brew --prefix chruby)/share/chruby/chruby.sh
source $(brew --prefix chruby)/share/chruby/auto.sh
cd $HOME
cd $HOME/development
chruby "$ruby_latest_version"
gem update --system --no-document
gem clean
gem install bundler --no-document
fi
read -p "Do you want to configure QM now? [y,n]" -n1 -s CFG_QM
if [[ "$CFG_QM" == "y" ]]; then
echo "Installing QM"
cd $HOME/development/
git clone [email protected]:qmee/qm.git
cd ./qm
./bin/qm setup
fi