Created
September 22, 2011 06:36
-
-
Save jamesottaway/1234192 to your computer and use it in GitHub Desktop.
Bootstrapping Personal Babushka Deps
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
dep 'babushka deps cloned' do | |
requires 'github has my public key' | |
setup { | |
set :babushka_deps_dir, '~/.babushka/deps'.to_fancypath | |
define_var :github_username, :message => 'What is your GitHub username?' | |
define_var :babushka_deps_repo_name, :message => 'What is your Babushka deps repo called?', :default => 'babushka-deps' | |
set :babushka_deps_repo, "[email protected]:#{var :github_username}/#{var :babushka_deps_repo_name}.git" | |
} | |
met? { var(:babushka_deps_dir).directory? && shell("(cd #{var :babushka_deps_dir} && git remote -v)")[var :babushka_deps_repo] } | |
meet { shell "git clone #{var :babushka_deps_repo} #{var :babushka_deps_dir}" } | |
end | |
dep 'bootstap' do | |
requires 'babushka deps cloned' | |
end |
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
dep 'github has my public key' do | |
requires 'ssh keys' | |
define_var :github_username, :message => 'What is your GitHub username?' | |
define_var :github_password, :message => 'What is your GitHub password?' | |
met? { raw_shell('ssh -T [email protected] 2>&1').stdout['successfully authenticated'] } | |
prepare { | |
set :hostname, shell('hostname') | |
set :public_key, shell('cat ~/.ssh/id_rsa.pub') | |
set :github_api, 'https://api.github.com' | |
} | |
meet { | |
auth = "#{var :github_username}:#{var :github_password}" | |
args = "{\"title\": \"#{var :hostname}\", \"key\": \"#{var :public_key}\"}" | |
shell "curl -u '#{auth}' -d '#{args}' #{var :github_api}/user/keys" | |
} | |
end |
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
dep 'ssh keys' do | |
setup { define_var :ssh_dir, :message => 'Where do your SSH keys live? ', :default => '~/.ssh' } | |
met? { (var(:ssh_dir) / 'id_rsa.pub').exists? && (var(:ssh_dir) / 'id_rsa').exists? } | |
prepare { define_var :ssh_password, :message => 'What passphrase do you want to encrypt your SSH keys with?' } | |
meet { shell "ssh-keygen -t rsa -N #{var :ssh_password} -f #{var :ssh_dir}/id_rsa" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment