Skip to content

Instantly share code, notes, and snippets.

@btihen
Last active June 7, 2016 06:46
Show Gist options
  • Save btihen/ce6e2d4e911919e3a7f0 to your computer and use it in GitHub Desktop.
Save btihen/ce6e2d4e911919e3a7f0 to your computer and use it in GitHub Desktop.
brew-setup
# install XCode from the app store
# updates by Elliot -- https://gist.github.com/MittchoBaroco/bf6516e4b03ba6803808f046084feb4d
#
# Install xcode cmdline tools
sudo xcodebuild -license
sudo xcode-select --install
#
# NOTICE
# brew 'rbenv-gem-rehash' is DEPRECATED
# brew 'mysql' is not use anymore
cat <<"EOF" >> Brewfile
brew 'pow'
brew 'apg'
brew 'git'
brew 'tig'
brew 'nmap'
brew 'tmux'
brew 'wget'
brew 'curl'
brew 'rbenv'
brew 'ctags'
brew 'sqlite'
brew 'python'
brew 'ipcalc'
brew 'openssl'
brew 'python3'
brew 'qrencode'
brew 'postgresql'
brew 'ruby-build'
brew 'imagemagick'
brew 'rbenv-ctags'
brew 'rbenv-bundler'
brew 'rbenv-default-gems'
EOF
#
cat <<"EOF" >> .bash_profile
export PATH="/usr/local/bin:$HOME/.rbenv/bin:$PATH"
export RBENV_ROOT=/usr/local/var/rbenv
#eval "$(rbenv init -)"
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
export EDITOR=vim
EOF
source .bash_profile
#
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo export PATH='/usr/local/sbin:$PATH' >> ~/.bash_profile
#
# Open new terminal window
#
brew tap Homebrew/brewdler
#
brew doctor
#
brew brewdler
#
cat <<"EOF" >> ~/.gemrc
gem: --no-ri --no-rdoc
update: --no-ri --no-rdoc
install: --no-ri --no-rdoc
EOF
rbenv install 2.3.1
rbenv rehash
rbenv global 2.3.1
cat <<"EOF" >> ~/.rbenv/default-gems
rake
#rails
bundler
rubygems-bundler
EOF
#
ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh manager@od.las.ch 'sh -c "cat - >>~/.ssh/authorized_keys2"'
touch reset-password
chmod +x reset-password
cat <<"EOF" >> reset-password
#!/bin/bash
USERNAME=$1
PASSWORD=$2
if [ -z "$PASSWORD" ]; then
if [ -f "/usr/local/bin/apg" ]; then
PASSWORD=`apg -n50 -m10 -M NCL | grep -v "[1lI0O5SzZyY]" | head -n1`
fi
fi
echo
echo "USERNAME: $USERNAME"
if [ ! -z "$PASSWORD" ]; then
echo "PASSWORD: $PASSWORD"
fi
echo
echo "connecting to OD"
echo
if ssh manager@odm01.las.ch "./reset_passwd.sh $USERNAME $PASSWORD"; then
echo "SUCCESSFUL PASSWORD RESET!"
else
echo
echo "PASSWORD RESET FAILED - check username"
fi
echo
EOF
#
git config --global user.name "Your Name"
git config --global user.email yname@las.ch
git config --global core.editor vim
git config --global merge.tool vimdiff
# postgresql
initdb /usr/local/var/postgres -E utf8
mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
createdb yourLogin
#for instance: createdb ehebert
createuser -dl ubuntu
createuser -dl manager
createuser -dl root
createuser -dl observations
cat <<"EOF" >> updateRole.sql
ALTER ROLE ubuntu WITH SUPERUSER;
ALTER ROLE manager WITH SUPERUSER;
ALTER ROLE root WITH SUPERUSER;
ALTER ROLE observations WITH SUPERUSER;
EOF
#
psql -f updateRole.sql
rm updateRole.sql
# if you need to start a new project write this: rails new youAppName -d postgresql -T
#
# setup pow
#
mkdir -p ~/Library/Application\ Support/Pow/Hosts
ln -s ~/Library/Application\ Support/Pow/Hosts ~/.pow
sudo pow --install-system
sudo launchctl load -w /Library/LaunchDaemons/cx.pow.firewall.plist
################
# Notice always:
# 1. check the rbenv version
# 2. install bundler before rails with: gem install bundler
# 3. bundle install
# 4. configure database:
# A. database population
# - dropdb dbname
# - createdb dbname
# - psql -d dbname -f dbfilename.sql
# B. rails initial configuration (blank database)
# - db:create
# - db:migrate
# 5. rails server
################
### OLD STUFF ###
# install XCode from the app store
#
# Install xcode cmdline tools
sudo xcodebuild -license
sudo xcode-select --install
#
cat <<"EOF" >> Brewfile
brew 'pow'
brew 'apg'
brew 'git'
brew 'tig'
brew 'nmap'
brew 'tmux'
brew 'wget'
brew 'curl'
brew 'rbenv'
brew 'ctags'
brew 'mysql'
brew 'sqlite'
brew 'python'
brew 'ipcalc'
brew 'openssl'
brew 'python3'
brew 'qrencode'
brew 'postgresql'
brew 'ruby-build'
brew 'imagemagick'
brew 'rbenv-ctags'
brew 'rbenv-bundler'
brew 'rbenv-gem-rehash'
brew 'rbenv-default-gems'
EOF
#
cat <<"EOF" >> .bash_profile
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export EDITOR=vim
EOF
#
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
echo export PATH='/usr/local/sbin:$PATH' >> ~/.bash_profile
#
# Open new terminal window
#
brew tap Homebrew/brewdler
#
brew doctor
#
brew brewdler
#
cat <<"EOF" >> ~/.gemrc
gem: --no-ri --no-rdoc
update: --no-ri --no-rdoc
install: --no-ri --no-rdoc
EOF
rbenv install 2.2.1
rbenv rehash
rbenv global 2.2.1
cat <<"EOF" >> ~/.rbenv/default-gems
rake
#rails
bundler
rubygems-bundler
EOF
#
ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh manager@od.las.ch 'sh -c "cat - >>~/.ssh/authorized_keys2"'
touch reset-password
chmod +x reset-password
cat <<"EOF" >> reset-password
#!/bin/bash
USERNAME=$1
PASSWORD=$2
if [ -z "$PASSWORD" ]; then
if [ -f "/usr/local/bin/apg" ]; then
PASSWORD=`apg -n50 -m10 -M NCL | grep -v "[1lI0O5SzZyY]" | head -n1`
fi
fi
echo
echo "USERNAME: $USERNAME"
if [ ! -z "$PASSWORD" ]; then
echo "PASSWORD: $PASSWORD"
fi
echo
echo "connecting to OD"
echo
if ssh manager@odm01.las.ch "./reset_passwd.sh $USERNAME $PASSWORD"; then
echo "SUCCESSFUL PASSWORD RESET!"
else
echo
echo "PASSWORD RESET FAILED - check username"
fi
echo
EOF
#
git config --global user.name "Your Name"
git config --global user.email yname@las.ch
git config --global core.editor vim
git config --global merge.tool vimdiff
# postgresql
initdb /usr/local/var/postgres -E utf8
mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
createuser rails
createdb -Orails rails_development
rails new coolness -d postgresql -T
# mysql
mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
mysqladmin -u root password “newpassword”
mysql -u root -p
CREATE DATABASE rails_dev;
USE rails_dev;
CREATE USER 'rails_usr'@'localhost' IDENTIFIED BY 'Tr4ck-Stuf';
GRANT ALL ON rails_dev.* TO 'rails_usr'@'localhost';
FLUSH PRIVILEGES;
rails new coolness -d mysql -T
#
# setup pow
#
mkdir -p ~/Library/Application\ Support/Pow/Hosts
ln -s ~/Library/Application\ Support/Pow/Hosts ~/.pow
sudo pow --install-system
sudo launchctl load -w /Library/LaunchDaemons/cx.pow.firewall.plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment