Top Level Namespace
Defined Under Namespace
Modules: Mina
Instance Method Summary collapse
- #check_response ⇒ Object
- #check_symlink(destination) ⇒ Object
- #escape(str) ⇒ Object
- #monit_config(original_name, destination_name = nil) ⇒ Object
- #put(content, file) ⇒ Object
- #template(from, to = nil) ⇒ Object
Instance Method Details
#check_response ⇒ Object
23 24 25 |
# File 'lib/mina-stack/base.rb', line 23 def check_response 'then echo "-----> SUCCESS"; else echo "-----> FAILED"; fi' end |
#check_symlink(destination) ⇒ Object
19 20 21 |
# File 'lib/mina-stack/base.rb', line 19 def check_symlink(destination) %{if [[ -h "#{destination}" ]]; #{check_response}} end |
#escape(str) ⇒ Object
15 16 17 |
# File 'lib/mina-stack/base.rb', line 15 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
11 12 13 |
# File 'lib/mina-stack/base.rb', line 11 def put(content, file) queue %[echo #{escape content} > "#{file}"] end |
#template(from, to = nil) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/mina-stack/base.rb', line 4 def template(from, to=nil) queue %{echo "-----> Put #{from} file to #{to}"} to ||= "#{config_path}/#{from.chomp(".erb")}" erb = File.read(File.("../../templates/#{from}", __FILE__)) put ERB.new(erb).result(binding), to end |