This repository has been archived by the owner on Feb 9, 2021. It is now read-only.
forked from rvm/rvm-binary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·58 lines (50 loc) · 1.62 KB
/
run
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
#!/usr/bin/env ruby
require 'yaml'
distributions = YAML::load_file('config.yml')["distributions"]
if ARGV.nil? || ARGV.length == 0 || ARGV[0] == "all"
targets = distributions.keys
elsif %w( help --help -h ).include? ARGV[0]
puts "Usage: ./run [help|list|<image>|binaries|upload]"
exit
elsif %w( list --list -l ).include? ARGV[0]
puts distributions.keys
exit
elsif %w( binaries --binaries -b ).include? ARGV[0]
system "find binaries -type f | sort"
exit
elsif %w( du ).include? ARGV[0]
system "find binaries -type f | sort | xargs du -h"
exit
elsif %w( upload --upload -u ).include? ARGV[0]
system "rsync -av --rsh=ssh --progress binaries/ rvm@rvm.io:~/site/shared/public/binaries/"
exit
else
targets = ARGV
end
if ( targets - distributions.keys ).length > 0
$stderr.puts "Unknown command '#{ARGV*" "}'"
puts "Usage: ./run [image]"
exit 1
end
if targets.length == 1
puts "#### halting #{targets[0]}"
system "vagrant halt #{targets[0]} || vagrant halt --force #{targets[0]}"
elsif targets.length > 1
puts "### halting all"
system "vagrant halt || vagrant halt --force"
end
%w( log rvm-archives rvm-repos ).each do |dir|
Dir.mkdir "#{dir}/" unless Dir.exist? "#{dir}/"
end
targets.each do |target|
puts "#### starting #{target}"
File.delete "log/#{target}.log" if File.exist?("log/#{target}.log")
system "vagrant up #{target} --provision 2>&1 | tee log/#{target}.log"
puts "#### stopping #{target}"
system "vagrant halt #{target} 2>/dev/null || vagrant halt --force #{target}"
end
if targets.length > 1
puts "### halting all"
system "vagrant halt || vagrant halt --force"
puts "### halted all"
end