6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/vines/command/init.rb', line 6
def run(opts)
raise 'vines init <domain>' unless opts[:args].size == 1
domain = opts[:args].first
dir = File.expand_path(domain)
raise "Directory already initialized: #{domain}" if File.exists?(dir)
Dir.mkdir(dir)
%w[conf web].each do |sub|
FileUtils.cp_r(File.expand_path("../../../../#{sub}", __FILE__), dir)
end
users, log, pid = %w[data/users log pid].map do |sub|
File.join(dir, sub).tap {|subdir| FileUtils.makedirs(subdir) }
end
create_users(domain, users)
update_config(domain, File.join(dir, 'conf', 'config.rb'))
Command::Cert.new.create_cert(domain, File.join(dir, 'conf/certs'))
puts "Initialized server directory: #{domain}"
puts "Run 'cd #{domain} && vines start' to begin"
end
|