Class: SetupMailcvt
- Inherits:
-
Object
- Object
- SetupMailcvt
- Defined in:
- lib/setup_mailcvt.rb
Instance Method Summary collapse
Instance Method Details
#create_cron_job ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/setup_mailcvt.rb', line 14 def create_cron_job jobfile = File.join(@output, 'cronjobs') File.delete jobfile if File.exist?(jobfile) newmaildir = File.join(Dir.home, 'Maildir/new') File.open(jobfile, 'w') { |f| f.puts "*/6 * * * * #{get_run_path} #{newmaildir} #{@output}" } `crontab #{jobfile}` File.delete jobfile end |
#create_output_dir ⇒ Object
9 10 11 12 |
# File 'lib/setup_mailcvt.rb', line 9 def create_output_dir @output = File.join(Dir.home, 'mailcvt-output') Dir.mkdir(@output) unless Dir.exist?(@output) end |
#get_run_path ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/setup_mailcvt.rb', line 24 def get_run_path libdir = File.dirname(__FILE__) bindir = File.join(File.dirname(libdir), 'bin') path = File.join(bindir, 'lock-runmailcvt') raise "Cannot find #{path}." unless File.exist?(path) path end |
#setup ⇒ Object
4 5 6 7 |
# File 'lib/setup_mailcvt.rb', line 4 def setup create_output_dir create_cron_job end |