Module: Escualo::Artifact
- Defined in:
- lib/escualo/artifact.rb
Class Method Summary collapse
- .configure_monit(ssh, options) ⇒ Object
- .configure_upstart(ssh, options) ⇒ Object
- .create_codechange_script(ssh, name) ⇒ Object
- .create_init_script(ssh, options) ⇒ Object
- .create_push_infra(ssh, options) ⇒ Object
- .create_scripts_dir(ssh, name) ⇒ Object
- .destroy(ssh, name) ⇒ Object
- .list(ssh) ⇒ Object
- .present?(ssh, name) ⇒ Boolean
- .setup(ssh) ⇒ Object
Class Method Details
.configure_monit(ssh, options) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/escualo/artifact.rb', line 56 def self.configure_monit(ssh, ) name = [:name] ssh.exec! 'mkdir -p /etc/monit/conf.d/' ssh.upload_template! "/etc/monit/conf.d/escualo-#{name}", 'monit.conf', ssh.exec! 'monit reload' end |
.configure_upstart(ssh, options) ⇒ Object
68 69 70 |
# File 'lib/escualo/artifact.rb', line 68 def self.configure_upstart(ssh, ) ssh.upload_template! "/etc/init/#{[:name]}.conf", 'upstart.conf', end |
.create_codechange_script(ssh, name) ⇒ Object
63 64 65 66 |
# File 'lib/escualo/artifact.rb', line 63 def self.create_codechange_script(ssh, name) ssh.upload_template! "/var/scripts/#{name}/codechange", 'codechange.sh', name: name ssh.exec! "chmod +x /var/scripts/#{name}/codechange" end |
.create_init_script(ssh, options) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/escualo/artifact.rb', line 28 def self.create_init_script(ssh, ) ssh.upload_template! "/var/scripts/#{[:name]}/init", 'init.sh', ssh.exec! "chmod +x /var/scripts/#{[:name]}/init" end |
.create_push_infra(ssh, options) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/escualo/artifact.rb', line 39 def self.create_push_infra(ssh, ) name = [:name] ssh.exec! %Q{\ cd /var && \ mkdir -p www && \ mkdir -p repo && \ cd repo && \ rm -rf #{name}.git && \ mkdir #{name}.git && \ cd #{name}.git && \ git init --bare } hook_file = "/var/repo/#{name}.git/hooks/post-receive" ssh.upload_template! hook_file, 'post-receive.sh', ssh.exec! "chmod +x #{hook_file}" end |
.create_scripts_dir(ssh, name) ⇒ Object
24 25 26 |
# File 'lib/escualo/artifact.rb', line 24 def self.create_scripts_dir(ssh, name) ssh.exec! "mkdir -p /var/scripts/#{name}" end |
.destroy(ssh, name) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/escualo/artifact.rb', line 10 def self.destroy(ssh, name) raise 'name must not be blank' if name.blank? raise 'name must not contains wildcards' if name.include?('*') ssh.exec! "rm -rf /var/scripts/#{name}" ssh.exec! "rm -rf /var/repo/#{name}.git" ssh.exec! "rm -f /etc/monit/conf.d/escualo-#{name}" ssh.exec! "rm -f /etc/init/#{name}.conf" end |
.list(ssh) ⇒ Object
35 36 37 |
# File 'lib/escualo/artifact.rb', line 35 def self.list(ssh) ssh.exec!('ls /var/repo/').captures(/(.*)\.git/).map { $1 } end |
.present?(ssh, name) ⇒ Boolean
20 21 22 |
# File 'lib/escualo/artifact.rb', line 20 def self.present?(ssh, name) list(ssh).include? name end |
.setup(ssh) ⇒ Object
3 4 5 6 7 8 |
# File 'lib/escualo/artifact.rb', line 3 def self.setup(ssh) ssh.exec! %q{ mkdir -p/var/repo/ && \ mkdir -p /var/scripts/ } end |