Skip to content

Instantly share code, notes, and snippets.

@drydevelopment
Created April 28, 2011 18:59
Show Gist options
  • Save drydevelopment/947040 to your computer and use it in GitHub Desktop.
Save drydevelopment/947040 to your computer and use it in GitHub Desktop.
install_everything(){
install_homebrew
install_git
install_imagemagick
install_memcached
install_sphinx
install_rvm
# install_mysql # Install from http://dev.mysql.com/downloads/mysql/5.1.html
# install_passenger
install_big_red
}
install_homebrew(){
if([ -d /usr/local/Cellar ]); then
echo "\nHomebrew already installed\n" && return
else
echo "\nInstalling homebrew...\n"
ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
fi
}
install_git(){
if([ -d /usr/local/Cellar/git ]); then
echo "\nGit already installed\n" && return
else
echo "\nInstalling git...\n"
brew install git
fi
}
install_imagemagick(){
if([ -d /usr/local/Cellar/imagemagick ]); then
echo "\nImagemagick already installed\n" && return
else
echo "\nInstalling imagemagick...\n"
brew install imagemagick
fi
}
install_memcached(){
if([ -d /usr/local/Cellar/memcached ]); then
echo "\nMemcached already installed\n" && return
else
echo "\nInstalling memcached...\n"
brew install memcached
fi
}
install_sphinx(){
if([ -d /usr/local/Cellar/sphinx ]); then
echo "\nSphinx already installed\n" && return
else
echo "\nInstalling sphinx...\n"
brew install sphinx
fi
}
install_big_red(){
if([ -f ~/Sites/within3/big_red/public/favicon.ico ]); then
echo "\nBig Red already installed\n" && return
else
echo "\nInstalling Big Red...\n"
clone_big_red
setup_big_red
setup_big_red_host
fi
}
install_rvm() {
if([ -d ~/.rvm ]); then
echo "\nRVM already installed\n" && return
else
echo "\nInstalling RVM...\n"
curl -s https://rvm.beginrescueend.com/install/rvm | bash
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.profile
source $HOME/.rvm/scripts/rvm
rvm install ree-1.8.7-2011.03
rvm --default use ree-1.8.7-2011.03
fi
}
# ========================================
clone_big_red(){
echo "- Cloning git@github.com:/Within3/big_red.git..."
mkdir -p ~/Sites/within3
(cd ~/Sites/within3 && git clone git@github.com:/Within3/big_red.git)
}
setup_big_red(){
(cd ~/Sites/within3/ &&
source ~/.rvm/scripts/rvm &&
echo "- Installing bundler" && gem install bundler &&
echo "- bundle install" && bundle install &&
echo "- Create database.yml" && cp config/database.yml{.sample,} &&
ruby -ryaml -e "y=YAML.load_file('config/database.yml'); y['development']['password'] = '$(cat /tmp/msqlpwd)'; File.open('config/database.yml', 'w') { |o| YAML.dump(y, o) }" &&
rm /tmp/msqlpwd &&
echo "- Installing reindexd needs admin permissions." && sudo rake w3:reindexd:deploy &&
echo "- rake w3:db:setup" && rake w3:db:setup &&
echo "- rake w3:indexes:reset" && rake w3:indexes:reset)
}
setup_big_red_host(){
[ -f /etc/apache2/vhosts/httpd.within3.conf ]
(cd /etc/apache2 &&
sudo mkdir /etc/apache2/vhosts &&
sudo echo "Include /private/etc/apache2/vhosts/*.conf" >> /etc/apache2/httpd.conf &&
sudo cat <<-EOS > /etc/apache2/vhosts/httpd.within3.conf &&
<VirtualHost *:80>
ServerName my.within3.dev
DocumentRoot "~/Sites/within3/big_red/public"
RackEnv development
<Directory "~/Sites/within3/big_red/public">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
EOS
sudo apachectl restart &&
open "http://my.within3.dev")
}
# ========================================
# NEEDS WORK
# ========================================
install_mysql(){
if([ -d /usr/local/Cellar/mysql ]); then
echo "\nMySQL already installed\n" && return
else
echo "\nInstalling mysql...\n"
brew install mysql
#setup_mysql - DON'T RUN
fi
}
setup_mysql(){
read -s -p "Please enter a password for your root MySQL account: " password
echo $password > /tmp/msqlpwd &&
(unset TMPDIR &&
mysql_install_db &&
cp /usr/local/Cellar/mysql/5.5.10/com.mysql.mysqld.plist ~/Library/LaunchAgents &&
launchctl load -w ~/Library/LaunchAgents/com.mysql.mysqld.plist &&
mysql.server start &&
/usr/local/bin/mysql/5.5.10/bin/mysqladmin -u root password $password &&
/usr/local/bin/mysql/5.5.10/bin/mysqladmin -u root -h $(hostname) password $password)
}
install_passenger(){
if([ "$(gem list passenger | grep passenger)" ]); then
echo "\nPassenger already installed\n" && return
else
echo "\nInstalling passenger...\n"
(source ~/.rvm/scripts/rvm &&
rvm ree@w3-upgrade exec gem install passenger &&
rvm ree@w3-upgrade exec sudo passenger-install-apache2-module &&
rvm ree@w3-upgrade exec sudo passenger-install-apache2-module --snippet >> /etc/apache2/httpd.conf)
fi
}
# ========================================
install_everything
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment