-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.rb
executable file
·79 lines (78 loc) · 2.76 KB
/
setup.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
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env ruby
$PACKAGE_FILES = Dir["AtomicDatabase/*.py"]
$DEST = "/opt/atomicdatabase/"
if ENV["USER"] != "root"
puts "Can't run this command without root priviledges, it is supposed to install things!"
exit 0
end
if ARGV.length >= 1 and ["install", "develop", "uninstall"].include? ARGV[0]
case ARGV[0]
when "install"
puts "Installing Atomic Database..."
unless File.directory? $DEST
puts "Creating installation directory at #{$DEST}..."
`mkdir #{$DEST}`
puts "Directory created."
else
puts "Installation directory found at #{$DEST}"
end
puts "Installing required packages with pip:"
File.foreach("requirements.txt").with_index do |line, line_num|
`pip3 install #{line}`
end
puts "Installing Atomic Database code files..."
$PACKAGE_FILES.each do |f|
`cp #{f} #{$DEST}`
puts " Copied #{f}"
end
`cp atomicdb #{$DEST}`
puts " Copied atomicdb"
puts "Creating executable in /usr/local/bin"
`ln -s #{$DEST}atomicdb /usr/local/bin/`
puts "Done!"
when "develop"
puts "Installing (Symlinked) Atomic Database..."
unless File.directory? $DEST
puts "Creating installation directory at #{$DEST}..."
`mkdir #{$DEST}`
puts "Directory created."
else
puts "Installation directory found at #{$DEST}"
end
puts "Installing required packages with pip:"
File.foreach("requirements.txt").with_index do |line, line_num|
`pip3 install #{line}`
end
puts "Installing Atomic Database code files..."
$PACKAGE_FILES.each do |f|
`ln -s #{Dir.pwd}/#{f} #{$DEST}`
puts " Linked #{f}"
end
puts "Linking excecutable in /usr/local/bin"
`ln -s #{Dir.pwd}/atomicdb /usr/local/bin/atomicdb`
puts "Done!"
when "uninstall"
puts "Uninstalling Atomic Database..."
if File.directory? $DEST
puts "Destroying directory at #{$DEST}..."
`rm -rf #{$DEST}`
puts "Directory destroyed."
else
puts "Installation directory not found at #{$DEST}. Are you sure Atomic Database is installed?"
end
puts "Removing executable in /usr/local/bin..."
`rm -rf /usr/local/bin/atomicdb`
puts "Done!"
end
else
puts "You need to supply setup.rb with a command to tell it what to do!\nAvailable commands:\n\n"
commands = [
{"name" => "install", "description" => "physically install Atomic Database (as atomicdb) to your computer"},
{"name" => "develop", "description" => "symlink Atomic Database so it runs as if it were `install`ed"},
{"name" => "uninstall", "description" => "undo all of the things develop or install did"}
]
commands.each do |command|
puts " #{command["name"].ljust(15)} -- #{command["description"]}"
end
puts "\nChoose one of these commands please."
end