Last active
December 28, 2015 02:59
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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