Top Level Namespace

Defined Under Namespace

Modules: Mina

Instance Method Summary collapse

Instance Method Details

#check_responseObject



22
23
24
# File 'lib/mina-stack/base.rb', line 22

def check_response
  'then echo "----->   SUCCESS"; else echo "----->   FAILED"; fi'
end


18
19
20
# File 'lib/mina-stack/base.rb', line 18

def check_symlink(destination)
  %{if [[ -h "#{destination}" ]]; #{check_response}}
end

#escape(str) ⇒ Object



14
15
16
# File 'lib/mina-stack/base.rb', line 14

def escape(str)
  Shellwords.escape(str)
end

#monit_config(original_name, destination_name = nil) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/recipes/monit.rb', line 44

def monit_config(original_name, destination_name = nil)
  destination_name ||= origin_name
  path ||= monit_config_path
  destination = "#{path}/#{destination_name}"
  template "monit/#{original_name}.erb", "#{config_path}/monit/#{original_name}"
  queue echo_cmd %{sudo ln -fs "#{config_path}/monit/#{original_name}" "#{destination}"}
  queue check_symlink destination
  # queue "sudo mv /tmp/monit_#{original_name} #{destination}"
  # queue "sudo chown root #{destination}"
  # queue "sudo chmod 600 #{destination}"
end

#put(content, file) ⇒ Object



10
11
12
# File 'lib/mina-stack/base.rb', line 10

def put(content, file)
  queue %[echo #{escape content} > "#{file}"]
end

#template(from, to = nil) ⇒ Object



3
4
5
6
7
8
# File 'lib/mina-stack/base.rb', line 3

def template(from, to=nil)
  queue %{echo "-----> Put #{from} file to #{to}"}
  to ||= "#{config_path}/#{from.chomp(".erb")}"
  erb = File.read(File.expand_path("../../templates/#{from}", __FILE__))
  put ERB.new(erb).result(binding), to
end