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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/protobox/command/init.rb', line 6
def self.execute args
options = { verbose: false }
opts = help
argv = opts.parse(args)
if argv.first == 'help'
puts opts
exit
end
install_folder = Util::System.current_dir
git = Util::Platform.git
vagrant = Util::Platform.vagrant
puts "Protobox will now be installed at:"
puts install_folder
Util::Input.enter_or_abort
if !git
raise Errors::FatalError, 'GIT is required'
end
if !vagrant
raise Errors::FatalError, 'Vagrant is required'
end
if !Dir["#{install_folder}/.git/*"].empty?
raise Errors::FatalError, <<-MESSAGE
It appears something is already installed here. Please run this installer in an empty directory.
MESSAGE
end
if File.directory?(install_folder) and not File.executable?(install_folder)
raise Errors::FatalError, <<-MESSAGE
The installation folder, #{install_folder}, exists but is not readable. Please fix
the permissions and try again:
sudo chmod 755 #{install_folder}
MESSAGE
end
puts "Starting installation..."
if File.directory?(install_folder)
system "/bin/chmod g+rwx #{install_folder}"
else
system "/bin/mkdir #{install_folder}"
system "/bin/chmod g+rwx #{install_folder}"
end
puts "Downloading and installing protobox..."
Dir.chdir(install_folder) do
if git
system git, "init", "-q"
system git, "remote", "add", "origin", "https://github.com/protobox/protobox"
args = git, "fetch", "origin", "master:refs/remotes/origin/master", "-n"
args << "--depth=1" if ARGV.include? "--fast"
system *args
system git, "reset", "--hard", "origin/master"
else
raise Errors::FatalError, "GIT not found and is required to install"
end
end
puts "Configuring protobox..."
Dir.chdir(install_folder) do
system "/bin/cp data/config/common.yml-dist data/config/common.yml"
end
system vagrant, "plugin", "install", "vagrant-protobox"
puts "Installation successful! Type the following to make sure its working: "
puts "protobox help"
0
end
|