Class: Traquitana::Deployer
- Inherits:
-
Object
- Object
- Traquitana::Deployer
- Defined in:
- lib/deployer.rb
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Deployer
constructor
A new instance of Deployer.
- #run ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Deployer
Returns a new instance of Deployer.
3 4 5 6 7 8 |
# File 'lib/deployer.rb', line 3 def initialize( = nil) @config = Traquitana::Config.instance @verbose = !.nil? && [:verbose] @config.filename = file() @config.target = [:target] if [:target] end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/deployer.rb', line 10 def run STDOUT.puts "\e[1mRunning Traquitana version #{VERSION}\e[0m\n\n" unless File.exist?(@config.filename) warn "\e[31mNo config file (#{@config.filename}) found." warn "Did you run \e[1mtraq setup\e[0;31m ?" warn "Run it and check the configuration before deploying.\e[0m" exit 1 end @config.load @options = @config.password.size > 1 ? { password: @config.password } : {} @server = @config.server.to_s.size > 0 ? @config.server : "none" @shell = @config.shell ? "#{@config.shell} " : "" @network = Traquitana::SSH.new(@config.host, @config.user, @options) @packager = Traquitana::Packager.new @packager.verbose = @verbose all_list_file, all_list_zip = @packager.pack if !File.exist?(all_list_file) || !File.exist?(all_list_zip) warn "\e[31mCould not create the needed files.\e[0m" exit 2 end # check if the traq destination and config directories exists @network.execute(["mkdir -p #{@config.directory}/traq"],@verbose) @updater = Traquitana::Bar.new STDOUT.puts "Sending files ..." @network.send_files([["#{File.dirname(File.(__FILE__))}/../config/proc.sh","#{@config.directory}/traq/proc.sh"], ["#{File.dirname(File.(__FILE__))}/../config/#{@server}.sh","#{@config.directory}/traq/server.sh"], [all_list_file,"#{@config.directory}/traq/#{File.basename(all_list_file)}"], [all_list_zip ,"#{@config.directory}/traq/#{File.basename(all_list_zip)}"]],@updater) STDOUT.puts "\e[32mAll files sent.\e[0m\n\n" @network.execute(["chmod +x #{@config.directory}/traq/proc.sh"],@verbose) @network.execute(["chmod +x #{@config.directory}/traq/server.sh"],@verbose) cmd = "#{@config.directory}/traq/proc.sh #{@config.directory}/traq #{@packager.id} #{@verbose}" cmd = "#{@shell} \"#{cmd}\"" if @shell STDOUT.puts "Running remote update commands, please wait ..." STDOUT.puts @network.execute([cmd],@verbose).join # clean up File.unlink(all_list_file) File.unlink(all_list_zip) STDOUT.puts "\e[32mAll done. Have fun.\e[0m\n" end |