Class: Vines::Command::Init

Inherits:
Object
  • Object
show all
Defined in:
lib/vines/command/init.rb

Instance Method Summary collapse

Instance Method Details

#run(opts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/vines/command/init.rb', line 6

def run(opts)
  raise 'vines init <domain>' unless opts[:args].size == 1
  domain = opts[:args].first.downcase
  dir = File.expand_path(domain)
  raise "Directory already initialized: #{domain}" if File.exists?(dir)
  Dir.mkdir(dir)

  create_directories(dir)
  create_users(domain, dir)
  update_config(domain, dir)
  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