hhvacation 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +24 -0
- data/README.md +42 -0
- data/bin/hhvacation-ruby +43 -0
- metadata +97 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Copyright (c) 2010, Moritz Heidkamp
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are
|
|
6
|
+
met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer.
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
documentation and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
16
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
17
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
18
|
+
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
19
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
20
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
21
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
22
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# hhvacation
|
|
2
|
+
|
|
3
|
+
This is a drop-in replacement for the apparently no longer maintained
|
|
4
|
+
hhvacation program included in the
|
|
5
|
+
[GNU Hosting Helper](http://hostingsoftware.net/) suite. It only
|
|
6
|
+
operates on so called "virtual" vacation responders (i.e. they are
|
|
7
|
+
kept in a MySQL database).
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
Change your Postfix' master.cf to include a line like:
|
|
12
|
+
|
|
13
|
+
vacation unix - n n - - pipe flags=DRhu user=vacation argv=/usr/bin/hhvacation-ruby /etc/hhvacation.yml
|
|
14
|
+
|
|
15
|
+
The actual settings may vary depending on your setup. The argument
|
|
16
|
+
passed to the hhvacation-ruby program which is installed by this gem
|
|
17
|
+
must point to a YAML formatted config file. It must contain the
|
|
18
|
+
database connection information (see below for an example). Unless
|
|
19
|
+
configured otherwise, mails are delivered via the default method of
|
|
20
|
+
the `mail` gem (SMTP on localhost port 25 for version 2.2.5).
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## Example config
|
|
24
|
+
|
|
25
|
+
database:
|
|
26
|
+
host: localhost
|
|
27
|
+
user: root
|
|
28
|
+
password: s3cr3t
|
|
29
|
+
database: mail
|
|
30
|
+
|
|
31
|
+
mail:
|
|
32
|
+
method: sendmail
|
|
33
|
+
location: /usr/local/bin/sendmail
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
The `method` setting in the `mail` section may contain whatever method
|
|
37
|
+
is available in the `mail` gem. All further keys are directly passed
|
|
38
|
+
as settings for the method.
|
|
39
|
+
|
|
40
|
+
## Copyright
|
|
41
|
+
|
|
42
|
+
Copyright (c) 2010 Moritz Heidkamp. See LICENSE for details.
|
data/bin/hhvacation-ruby
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'rubygems'
|
|
3
|
+
require 'mail'
|
|
4
|
+
require 'mysql'
|
|
5
|
+
require 'yaml'
|
|
6
|
+
|
|
7
|
+
unless ARGV[0]
|
|
8
|
+
$stderr.puts "usage: #{$0} CONFIG_FILE"
|
|
9
|
+
exit 1
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
config = YAML.load_file(ARGV[0])
|
|
13
|
+
mysql = Mysql.real_connect(config['database']['host'],
|
|
14
|
+
config['database']['user'],
|
|
15
|
+
config['database']['password'],
|
|
16
|
+
config['database']['database'])
|
|
17
|
+
|
|
18
|
+
mail_config = {
|
|
19
|
+
:method => config['mail']['method'],
|
|
20
|
+
:settings => config['mail'].inject({ }) { |m,(k,v)| m[k.to_sym] = v if k != 'method'; m }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
mail = Mail.new($stdin.read)
|
|
24
|
+
recipients = [mail.to, mail.cc, mail.bcc].compact.flatten.map { |r| "'#{mysql.quote(r)}'" }.join(', ')
|
|
25
|
+
|
|
26
|
+
exit if recipients.empty?
|
|
27
|
+
|
|
28
|
+
mysql.query("SELECT email, subject, message, cache FROM vacation WHERE email IN (#{recipients})") do |res|
|
|
29
|
+
res.each_hash do |row|
|
|
30
|
+
next if row['cache'].split(',').include? mail.from.first
|
|
31
|
+
|
|
32
|
+
reply = Mail.new :from => row['email'],
|
|
33
|
+
:to => [mail.reply_to, mail.from].compact.flatten.first,
|
|
34
|
+
:subject => row['subject'],
|
|
35
|
+
:body => row['message']
|
|
36
|
+
|
|
37
|
+
reply.delivery_method(mail_config[:method].to_sym, mail_config[:settings]) if mail_config[:method]
|
|
38
|
+
reply.deliver!
|
|
39
|
+
|
|
40
|
+
mysql.query(%[UPDATE vacation SET cache = CONCAT(cache, ',', '%s') WHERE email = '%s'] %
|
|
41
|
+
[mysql.quote(mail.from.first), mysql.quote(row['email'])])
|
|
42
|
+
end
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hhvacation
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 29
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.0.1
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Moritz Heidkamp
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2010-08-13 00:00:00 +02:00
|
|
19
|
+
default_executable: hhvacation-ruby
|
|
20
|
+
dependencies:
|
|
21
|
+
- !ruby/object:Gem::Dependency
|
|
22
|
+
name: mail
|
|
23
|
+
prerelease: false
|
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
hash: 3
|
|
30
|
+
segments:
|
|
31
|
+
- 0
|
|
32
|
+
version: "0"
|
|
33
|
+
type: :runtime
|
|
34
|
+
version_requirements: *id001
|
|
35
|
+
- !ruby/object:Gem::Dependency
|
|
36
|
+
name: mysql
|
|
37
|
+
prerelease: false
|
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
hash: 3
|
|
44
|
+
segments:
|
|
45
|
+
- 0
|
|
46
|
+
version: "0"
|
|
47
|
+
type: :runtime
|
|
48
|
+
version_requirements: *id002
|
|
49
|
+
description: This is a drop-in replacement for the apparently no longer maintained hhvacation program included in the GNU Hosting Helper (http://hostingsoftware.net/) suite. It only operates on so called "virtual" vacation responds (i.e. they are kept in a MySQL database).
|
|
50
|
+
email: moritz@twoticketsplease.de
|
|
51
|
+
executables:
|
|
52
|
+
- hhvacation-ruby
|
|
53
|
+
extensions: []
|
|
54
|
+
|
|
55
|
+
extra_rdoc_files:
|
|
56
|
+
- LICENSE
|
|
57
|
+
- README.md
|
|
58
|
+
files:
|
|
59
|
+
- LICENSE
|
|
60
|
+
- README.md
|
|
61
|
+
- bin/hhvacation-ruby
|
|
62
|
+
has_rdoc: true
|
|
63
|
+
homepage: http://github.com/DerGuteMoritz/hhvacation
|
|
64
|
+
licenses: []
|
|
65
|
+
|
|
66
|
+
post_install_message:
|
|
67
|
+
rdoc_options:
|
|
68
|
+
- --charset=UTF-8
|
|
69
|
+
require_paths:
|
|
70
|
+
- lib
|
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
|
+
none: false
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
hash: 3
|
|
77
|
+
segments:
|
|
78
|
+
- 0
|
|
79
|
+
version: "0"
|
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ">="
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
hash: 3
|
|
86
|
+
segments:
|
|
87
|
+
- 0
|
|
88
|
+
version: "0"
|
|
89
|
+
requirements: []
|
|
90
|
+
|
|
91
|
+
rubyforge_project:
|
|
92
|
+
rubygems_version: 1.3.7
|
|
93
|
+
signing_key:
|
|
94
|
+
specification_version: 3
|
|
95
|
+
summary: A drop-in replacement for gnuhh hhvacation
|
|
96
|
+
test_files: []
|
|
97
|
+
|