-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgurgitate.rb
54 lines (42 loc) · 1.27 KB
/
gurgitate.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# -*- encoding : utf-8 internal_encoding: utf-8 -*-
#------------------------------------------------------------------------
# Mail filter invocation script
#------------------------------------------------------------------------
require "gurgitate-mail"
require 'optparse'
# change this on installation to taste
GLOBAL_RULES="/etc/gurgitate-rules"
GLOBAL_RULES_POST="/etc/gurgitate-rules-default"
commandline_files = []
mail_sender = nil
opts = OptionParser.new do |o|
o.on "-f FILE", "--file FILE", "Use FILE as a rules file" do |file|
commandline_files << file
end
o.on "-s SENDER", "--sender SENDER", "Use SENDER as sender" do |sender|
mail_sender = sender
end
o.on_tail "-h", "--help", "Show this message" do
puts opts
exit
end
end
mail_recipients = opts.parse(ARGV)
if mail_recipients.length == 0 then
mail_recipients = nil
end
gurgitate = Gurgitate::Gurgitate.new(STDIN, mail_recipients, mail_sender)
if commandline_files.length > 0
commandline_files.each do |file|
gurgitate.add_rules(file, :user => true)
end
else
gurgitate.add_rules(GLOBAL_RULES, :system => true)
gurgitate.add_rules(:default)
gurgitate.add_rules(GLOBAL_RULES_POST, :system => true)
end
begin
gurgitate.process
rescue CouldNotProcessMailError
exit 75
end