Module: Capistrano::Ops::Logrotate::Helpers
- Defined in:
- lib/capistrano/ops/logrotate/helpers.rb
Instance Method Summary collapse
- #config_template ⇒ Object
- #delete_files ⇒ Object
- #logrotate_disabled ⇒ Object
- #logrotate_enabled ⇒ Object
- #make_basepath ⇒ Object
- #schedule_template ⇒ Object
- #whenever(type) ⇒ Object
Instance Method Details
#config_template ⇒ Object
7 8 9 10 11 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 7 def config_template return nil unless File.exist?(File.(logrotate_config_file_template, __dir__)) ERB.new(File.read(File.(logrotate_config_file_template, __dir__))).result(binding) end |
#delete_files ⇒ Object
31 32 33 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 31 def delete_files puts capture "rm -rfv #{logrotate_basepath}" end |
#logrotate_disabled ⇒ Object
23 24 25 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 23 def logrotate_disabled !(test("[ -f #{logrotate_config_file_path} ]") && test("[ -f #{logrotate_schedule_file_path} ]")) end |
#logrotate_enabled ⇒ Object
19 20 21 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 19 def logrotate_enabled test("[ -f #{logrotate_config_file_path} ]") && test("[ -f #{logrotate_schedule_file_path} ]") end |
#make_basepath ⇒ Object
27 28 29 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 27 def make_basepath puts capture "mkdir -pv #{logrotate_basepath}" end |
#schedule_template ⇒ Object
13 14 15 16 17 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 13 def schedule_template return nil unless File.exist?(File.(logrotate_schedule_file_template, __dir__)) ERB.new(File.read(File.(logrotate_schedule_file_template, __dir__))).result(binding) end |
#whenever(type) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/capistrano/ops/logrotate/helpers.rb', line 35 def whenever(type) case type when 'clear' puts capture :bundle, :exec, :whenever, '--clear-crontab', "-f #{logrotate_schedule_file_path} #{fetch(:whenever_identifier)}_logrotate" when 'update' puts capture :bundle, :exec, :whenever, '--update-crontab', "-f #{logrotate_schedule_file_path}", "-i #{fetch(:whenever_identifier)}_logrotate" else puts 'type not found' end end |