-
Notifications
You must be signed in to change notification settings - Fork 1
/
intercity-server.rb
executable file
·66 lines (56 loc) · 1.4 KB
/
intercity-server.rb
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
#!/usr/bin/env ruby
require_relative "lib/intercity_server/installer"
class IntercityServerCli
def self.start
case ARGV[0]
when "help"
IntercityServerCli.new.usage
when "install"
IntercityServerCli.new.install
when "restart"
IntercityServerCli.new.restart
when "update"
IntercityServerCli.new.update
else
IntercityServerCli.new.usage
end
end
def usage
puts "Usage: \tintercity-server COMMAND"
puts ""
puts "Commands:"
puts " help - Show the commands available"
puts " install - Run the setup for installing intercity-server"
puts " restart - Restart your Intercity instance"
puts " update - Update your Intercity instance"
end
def install
if installed?
puts "Intercity is already installed."
puts "If you want to update your Intercity instance, run:"
puts " intercity-server update"
exit 1
end
IntercityServer::Installer.execute
end
def restart
ensure_installed
`/var/intercity/launcher restart app`
end
def update
ensure_installed
`/var/intercity/launcher rebuild app`
end
private
def installed?
Dir.exist?("/var/intercity")
end
def ensure_installed
return if installed?
puts "Intercity is not yet installed."
puts "To install Intercity run:"
puts " intercity-server install"
exit 1
end
end
IntercityServerCli.start