Refactor install scripts (KISS)

This commit is contained in:
Henrik Lissner 2013-03-21 22:26:04 -04:00
parent 9373174c6a
commit a57e94a912
7 changed files with 90 additions and 112 deletions

View file

@ -5,20 +5,19 @@ RS=$(tput sgr0)
src=$(cd "$(dirname "$0")"; pwd) src=$(cd "$(dirname "$0")"; pwd)
if [ ! -d $src/install ]; then if [ ! -d $src/install ]; then
echo -e "$GREEN==> Cloning dotfiles repo" echo -e "$GREEN==> Cloning dotfiles repo$RS"
git clone https://github.com/hlissner/dotfiles.git ~/.dotfiles | sed "s/^/ /" git clone https://github.com/hlissner/dotfiles.git ~/.dotfiles | sed "s/^/ /"
src="~/.dotfiles" src="~/.dotfiles"
fi fi
{ $src/install/osx
$src/install/osx $src/install/zsh
$src/install/zsh $src/install/brew
$src/install/brew $src/install/git
$src/install/git $src/install/rvm
$src/install/rvm $src/install/tmux
$src/install/tmux
} | sed "s/^/ /"
echo "Done!" echo
echo "${GREEN}Done!$RS"
echo "And if you want to install vim, run:" echo "And if you want to install vim, run:"
echo " sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L)" echo " sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L)"

View file

@ -1,7 +1,7 @@
#!/bin/zsh #!/bin/zsh
if ! command-exists brew ; then if ! command-exists brew; then
echoh "==> Homebrew: Installing" echo "==> Homebrew: Installing"
# http://mxcl.github.com/homebrew/ # http://mxcl.github.com/homebrew/
ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) | indent ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go) | indent
@ -10,9 +10,13 @@ elif [ "$1" = "--force" ]; then
FORCE=1 FORCE=1
fi fi
echo "==> Homebrew: Updating"
# Make sure were using the latest Homebrew
brew update
if [ $FORCE ]; then if [ $FORCE ]; then
echoh "==> Homebrew: Installing essential brews" echo "==> Homebrew: Installing essential brews"
{
# Install GNU core utilities (those that come with OS X are outdated) # Install GNU core utilities (those that come with OS X are outdated)
brew install coreutils brew install coreutils
# echo "Dont forget to add $(brew --prefix coreutils)/libexec/gnubin to \$PATH." # echo "Dont forget to add $(brew --prefix coreutils)/libexec/gnubin to \$PATH."
@ -30,23 +34,17 @@ if [ $FORCE ]; then
brew tap josegonzalez/homebrew-php brew tap josegonzalez/homebrew-php
# Install everything else # Install everything else
brew install ack git rename tree python ruby node nginx memcached ctags macvim brew install ack git rename tree python node nginx memcached ctags macvim
brew install php54 --with-fpm --with-imap --with-mysql --with-pgsql --without-apache brew install php54 --with-fpm --with-imap --with-mysql --with-pgsql --without-apache
brew install php54-imagick php54-mcrypt php54-xdebug readline brew install php54-imagick php54-mcrypt php54-xdebug readline
} | indent
else else
echoh "==> Homebrew: Updating" echo "==> Homebrew: Upgrading"
{
# Make sure were using the latest Homebrew
brew update
# Upgrade any already-installed formulae # Upgrade any already-installed formulae
brew upgrade brew upgrade
} | indent
fi fi
echoh "==> Homebrew: Cleaning up" echo "==> Homebrew: Cleaning up"
# Remove outdated versions from the cellar # Remove outdated versions from the cellar
brew cleanup | indent brew cleanup
echoh "==> Homebrew: DONE!" echo "==> Homebrew: DONE!"

View file

@ -6,22 +6,20 @@ if ! command-exists git; then
exit exit
fi fi
echoh "==> Git: Installing" echo "==> Git: Installing"
brew install git | indent brew install git | indent
fi fi
if [ ! -e /usr/local/bin/branch ]; then if [ ! -e /usr/local/bin/branch ]; then
echoh "==> Git: Installing git-friendly" echo "==> Git: Installing git-friendly"
# https://github.com/jamiew/git-friendly # https://github.com/jamiew/git-friendly
bash < <(curl https://raw.github.com/jamiew/git-friendly/master/install.sh) bash < <(curl https://raw.github.com/jamiew/git-friendly/master/install.sh)
fi fi
# Create links # Create links
echoh "==> Git: Setting up symlinks" echo "==> Git: Setting up symlinks"
ln -sf ~/.dotfiles/gitignore ~/.gitignore
ln -sf ~/.dotfiles/gitconfig ~/.gitconfig
src=$(cd "$(dirname "$0")/.."; pwd) echo "==> Git: DONE!"
ln -sf $src/gitignore ~/.gitignore
ln -sf $src/gitconfig ~/.gitconfig
echoh "==> Git: DONE!"

View file

@ -2,15 +2,14 @@
sudo -v sudo -v
if ! command-exists "rvm"; then if ! command-exists rvm; then
# If RVM's not installed, install it and the rubies # If RVM's not installed, install it and the rubies
echoh "==> Rvm: Installing" echo "==> Rvm: Installing"
# https://rvm.io # https://rvm.io
curl -L https://get.rvm.io | bash -s stable --ruby | indent curl -L https://get.rvm.io | bash -s stable --ruby | indent
echoh "==> Rvm: Install rubies" echo "==> Rvm: Install rubies"
{
# Install rubies and update rubygems # Install rubies and update rubygems
rvm install 1.9.3 rvm install 1.9.3
rvm install 1.8.7-p371 rvm install 1.8.7-p371
@ -20,7 +19,6 @@ if ! command-exists "rvm"; then
# A few prerequisites # A few prerequisites
sudo gem install bluecloth capistrano bundler colorize sudo gem install bluecloth capistrano bundler colorize
} | indent
else else
# Otherwise, update it # Otherwise, update it
@ -32,21 +30,17 @@ else
# Update all rubies and rubygems # Update all rubies and rubygems
for v in 1.9.3 1.8.7; do for v in 1.9.3 1.8.7; do
echoh "==> Rvm: Updating ruby $v" echo "==> Rvm: Updating ruby $v"
{
rvm use $v rvm use $v
gem update --system gem update --system
gem update gem update
} | indent
done done
# Update system ruby # Update system ruby
echoh "==> Rvm: Updating system ruby" echo "==> Rvm: Updating system ruby"
{
rvm use system rvm use system
sudo gem update --system sudo gem update --system
sudo gem update sudo gem update
} | indent
fi fi
echoh "==> Rvm: DONE!" echo "==> Rvm: DONE!"

View file

@ -6,14 +6,13 @@ if ! command-exists brew; then
fi fi
if [ ! `command -v "tmux"` ]; then if [ ! `command -v "tmux"` ]; then
echoh "==> Tmux: Installing tmux & reattach-to-user-namespace" echo "==> Tmux: Installing tmux & reattach-to-user-namespace"
brew install tmux reattach-to-user-namespace libevent | indent brew install tmux reattach-to-user-namespace libevent | indent
else else
echoh "==> Tmux: already installed!" echo "==> Tmux: already installed!"
fi fi
echoh "==> Tmux: Setting up symlinks" echo "==> Tmux: Setting up symlinks"
src=$(cd "$(dirname "$0")/.."; pwd) ln -sf ~/.dotfiles/tmux.conf ~/.tmux.conf
ln -sf $src/tmux.conf ~/.tmux.conf
echoh "==> Tmux: DONE!" echo "==> Tmux: DONE!"

View file

@ -2,16 +2,16 @@
if ! command-exists "brew"; then if ! command-exists "brew"; then
echo "Homebrew is required!" echo "Homebrew is required!"
exit exit 1
fi fi
if ! command-exists "mvim"; then if ! command-exists "mvim"; then
echoh "==> Vim: Installing macvim" echo "==> Vim: Installing macvim"
brew install macvim --with-cscope --override-system-vim | indent brew install macvim --with-cscope --override-system-vim | indent
fi fi
if [ ! -e ~/.vimrc ]; then if [ ! -e ~/.vimrc ]; then
echoh "==> Vim: Installing vim rcfiles" echo "==> Vim: Installing vim rcfiles"
if [ -d ~/.vim ]; then if [ -d ~/.vim ]; then
rm -rf ~/.vim rm -rf ~/.vim
@ -22,21 +22,17 @@ if [ ! -e ~/.vimrc ]; then
sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) | indent sh <(curl https://raw.github.com/hlissner/mlvim/master/install.sh -L) | indent
fi fi
echoh "==> Vim: Updating..." echo "==> Vim: Updating..."
{ find ~/.vim/bundle/ -type d -name .git \
find ~/.vim/bundle/ -type d -name .git \ | xargs -n 1 dirname \
| xargs -n 1 dirname \ | while read line; do cd $line && echo -n "$(basename $line): " && git pull; done
| while read line; do cd $line && echo -n "$(basename $line): " && git pull; done
} | indent
YVM_DIR="~/.vim/bundle/YouCompleteMe" YVM_DIR="~/.vim/bundle/YouCompleteMe"
if [ -d $YVM_DIR ] && [ ! -e $YVM_DIR/python/ycm_core.so ]; then if [ -d $YVM_DIR ] && [ ! -e $YVM_DIR/python/ycm_core.so ]; then
echoh "==> Vim: Trying to compile YCM" echo "==> Vim: Trying to compile YCM"
{
brew install cmake brew install cmake
cd ~/.vim/bundle/YouCompleteMe cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer ./install.sh --clang-completer
} | indent
fi fi
echoh "==> Vim: DONE!" echo "==> Vim: DONE!"

View file

@ -1,27 +1,21 @@
#!/bin/bash #!/bin/bash
echoh() {
echo -e "\033[01;38;5;2m$1\033[39m"
}
if [ ! -d ~/.oh-my-zsh ]; then if [ ! -d ~/.oh-my-zsh ]; then
# https://github.com/robbyrussell/oh-my-zsh # https://github.com/robbyrussell/oh-my-zsh
echoh "==> ZSH: Installing oh-my-zsh" echo "==> ZSH: Installing oh-my-zsh"
curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
# Set new shell # Set new shell
echoh "==> ZSH: Changing shell" echo "==> ZSH: Changing shell"
chsh -s /bin/zsh chsh -s /bin/zsh
fi fi
# Create links # Create links
echoh "==> ZSH: Setting up symlinks" echo "==> ZSH: Setting up symlinks"
src=$(cd "$(dirname "$0")/.."; pwd)
[ -d ~/.zsh ] && rm ~/.zsh [ -d ~/.zsh ] && rm ~/.zsh
ln -sf $src/zsh ~/.zsh ln -sf ~/.dotfiles/zsh ~/.zsh
ln -sf $src/zshrc ~/.zshrc ln -sf ~/.dotfiles/zshrc ~/.zshrc
ln -sf $src/zshenv ~/.zshenv ln -sf ~/.dotfiles/zshenv ~/.zshenv
ln -sf $src/bashrc ~/.bashrc ln -sf ~/.dotfiles/bashrc ~/.bashrc
echoh "==> ZSH: DONE!" echo "==> ZSH: DONE!"