-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmacos
More file actions
executable file
·89 lines (69 loc) · 2.89 KB
/
macos
File metadata and controls
executable file
·89 lines (69 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env ruby
require 'fileutils'
module Provision
def self.binary_installed?(binary)
system("command -v #{binary} >/dev/null 2>&1")
end
def self.brew(brew_package)
return if system("brew list #{brew_package} >/dev/null 2>&1")
run_command "brew install #{brew_package}"
end
def self.update_project(project_name, remote: 'github.com', org: 'f1sherman')
project_dir = File.join(Dir.home, 'projects', project_name)
if File.exist? project_dir
puts "\nUpdating #{project_name}\n"
run_command "cd #{project_dir} && git pull"
puts "\nDone updating #{project_name}\n"
else
puts "\nCloning #{project_name}\n"
run_command "git clone git@#{remote}:#{org}/#{project_name}.git #{project_dir}"
puts "\nDone cloning #{project_name}\n"
end
end
def self.run_command(command)
puts "$ #{command}"
success = system command
return if success
puts "\nReceived exit status #{$?.exitstatus}, quitting..."
exit 1
end
end
filevault_status = %x(fdesetup status)
unless filevault_status == "FileVault is On.\n"
puts 'It looks like FileVault is not turned on. Before doing anything else please enable FileVault and ensure that it has completed.'
exit
end
ssh_public_key = File.join(Dir.home, '.ssh', 'id_rsa.pub')
unless File.exist? ssh_public_key
puts %q(No ssh key found. You'll now have a chance to generate a key if you'd like. If you'd rather generate it manually or copy it from somewhere, answer "n" at this prompt and restart this script after you've added it.)
print "\nWould you like to generate an ssh key now (y/n)? "
exit unless STDIN.gets.chomp == "y"
require 'io/console'
print "\nEnter ssh passphrase:"
ssh_passphrase = STDIN.noecho(&:gets)
Provision.run_command %Q(ssh-keygen -N "#{ssh_passphrase}" -f ~/.ssh/id_rsa)
puts 'Your ssh key has been generated. Add the below public key to github and press any key to continue...'
puts File.read ssh_public_key
STDIN.getch
end
api_providers = ['openai', 'anthropic']
config_dir = File.join(Dir.home, '.config', 'api-keys')
FileUtils.mkdir_p(config_dir) unless Dir.exist?(config_dir)
api_providers.each do |provider|
key_path = File.join(config_dir, provider)
unless File.exist?(key_path)
print "\nEnter your #{provider.capitalize} API Key (hit ENTER for none): "
api_key = STDIN.gets.chomp
File.open(key_path, 'w') { |f| f.write(api_key) }
end
File.chmod(0600, key_path) if File.exist?(key_path)
end
Provision.run_command 'softwareupdate --all --install --force'
unless Provision.binary_installed? 'brew'
Provision.run_command '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
end
Provision.run_command 'brew upgrade'
Provision.brew 'ansible'
Provision.update_project 'new-machine-bootstrap'
Provision.run_command 'cd ~/projects/new-machine-bootstrap && bin/provision'
Provision.run_command 'brew cleanup'