Skip to content

Instantly share code, notes, and snippets.

@wireframe
Last active December 28, 2015 02:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wireframe/7432366 to your computer and use it in GitHub Desktop.
Save wireframe/7432366 to your computer and use it in GitHub Desktop.
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
#!/usr/bin/env ruby
KITCHENPLAN_PATH = ENV.fetch("KITCHENPLAN_PATH", "/opt/kitchenplan")
KITCHENPLAN_REPO = ENV.fetch("KITCHENPLAN_REPO", "https://github.com/wireframe/kitchenplan.git")
# execute a shell command and raise an error if non-zero exit code is returned
def run_cmd(cmd, options = {})
puts "$ #{cmd}"
success = system(cmd)
fail "#{cmd} failed" unless success || options[:allow_failure]
end
# check if xcode command line tools are installed
def xcode_cli_installed?
xcode_path = `xcode-select -p`
xcode_cli_installed = $?.to_i == 0
end
run_cmd 'xcode-select --install' unless xcode_cli_installed?
if File.directory?(KITCHENPLAN_PATH)
puts "Updating existing kitchenplan installation..."
Dir.chdir KITCHENPLAN_PATH
run_cmd "git pull"
else
run_cmd "sudo mkdir -p /opt"
run_cmd "sudo chown -R #{ENV["USER"]} /opt"
run_cmd "git clone #{KITCHENPLAN_REPO} #{KITCHENPLAN_PATH}"
end
Dir.chdir KITCHENPLAN_PATH
run_cmd "./kitchenplan"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment