rmails 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +44 -0
  3. data/Vagrantfile +14 -0
  4. data/app/assets/javascripts/controls/stats.coffee.erb +11 -0
  5. data/app/assets/javascripts/lib/utils.coffee.erb +22 -0
  6. data/app/assets/stylesheets/application.sass +12 -0
  7. data/app/controllers/application_controller.rb +4 -0
  8. data/app/controllers/statistics_controller.rb +7 -0
  9. data/app/models/certificate_manager.rb +14 -5
  10. data/app/models/property.rb +13 -7
  11. data/app/models/property/amavis.rb +44 -0
  12. data/app/models/property/nginx.rb +2 -2
  13. data/app/models/property/spamassassin.rb +25 -0
  14. data/app/views/layouts/_nav.html.haml +1 -0
  15. data/app/views/server/_amavis.html.haml +16 -0
  16. data/app/views/server/_certificates.html.haml +9 -1
  17. data/app/views/server/index.html.haml +2 -0
  18. data/app/views/statistics/index.html.haml +11 -0
  19. data/bin/rmails +30 -4
  20. data/config/locales/server/en.yml +13 -6
  21. data/config/locales/server/help/amavis/cz.yml +14 -0
  22. data/config/locales/server/help/amavis/en.yml +14 -0
  23. data/config/locales/server/help/postfix/cz.yml +10 -0
  24. data/config/locales/server/help/postfix/en.yml +10 -0
  25. data/config/locales/server/help/rmails/cz.yml +6 -0
  26. data/config/locales/server/help/rmails/en.yml +6 -0
  27. data/config/locales/server/help/spamassassin/cz.yml +4 -0
  28. data/config/locales/server/help/spamassassin/en.yml +5 -0
  29. data/config/locales/server/key/amavis/cz.yml +14 -0
  30. data/config/locales/server/key/amavis/en.yml +14 -0
  31. data/config/locales/server/key/dspam/en.yml +7 -1
  32. data/config/locales/server/key/postfix/cz.yml +10 -0
  33. data/config/locales/server/key/postfix/en.yml +10 -0
  34. data/config/locales/server/key/rmails/cz.yml +6 -0
  35. data/config/locales/server/key/rmails/en.yml +6 -0
  36. data/config/locales/server/key/spamassassin/cz.yml +4 -0
  37. data/config/locales/server/key/spamassassin/en.yml +5 -0
  38. data/config/locales/views/admin_users/cz.yml +3 -2
  39. data/config/locales/views/admin_users/en.yml +24 -2
  40. data/config/locales/views/server/cz.yml +14 -0
  41. data/config/locales/views/server/en.yml +30 -0
  42. data/config/routes.rb +5 -1
  43. data/db/seeds.rb +18 -3
  44. data/lib/rmails/runner.rb +28 -0
  45. data/lib/rmails/version.rb +1 -1
  46. data/public/assets/application-63a99166ab81ea7342d72c2c0a8d1182.css +1 -0
  47. data/public/assets/application-63a99166ab81ea7342d72c2c0a8d1182.css.gz +0 -0
  48. data/public/assets/application-766444004d753128032ed7064f6c9126.js +19 -0
  49. data/public/assets/application-766444004d753128032ed7064f6c9126.js.gz +0 -0
  50. data/public/assets/application.css +1 -0
  51. data/public/assets/application.css.gz +0 -0
  52. data/public/assets/application.js +19 -0
  53. data/public/assets/application.js.gz +0 -0
  54. data/public/assets/arrow_bottom-97e39514fe3c51fc92d197d11dfc7061.gif +0 -0
  55. data/public/assets/arrow_bottom.gif +0 -0
  56. data/public/assets/arrow_right-50c28c8578105f07e646aea3f9dc4178.gif +0 -0
  57. data/public/assets/arrow_right.gif +0 -0
  58. data/public/assets/at-sign-76cd83c166e1021bd364adc180d23c5e.png +0 -0
  59. data/public/assets/at-sign.png +0 -0
  60. data/public/assets/checkerboard-53b0d336d3a119e5a584b6266e5eeb6f.gif +0 -0
  61. data/public/assets/checkerboard.gif +0 -0
  62. data/public/assets/chosen-sprite-0b638291e3ab1e89592983b5810b9b79.png +0 -0
  63. data/public/assets/chosen-sprite.png +0 -0
  64. data/public/assets/chosen-sprite@2x-8fa0fb1eb347c8dc10a5381b22383ac6.png +0 -0
  65. data/public/assets/chosen-sprite@2x.png +0 -0
  66. data/public/assets/glyphicons-halflings-d63e747535b6b5c589a12cad5d16a401.png +0 -0
  67. data/public/assets/glyphicons-halflings-white-6cccd17a7aed91dbc0157d343c68c0d9.png +0 -0
  68. data/public/assets/glyphicons-halflings-white.png +0 -0
  69. data/public/assets/glyphicons-halflings.png +0 -0
  70. data/public/assets/icon_draft-994cf7cb43047f55f594abdc21ccdbef.gif +0 -0
  71. data/public/assets/icon_draft.gif +0 -0
  72. data/public/assets/icon_layout-ad9a24c3bb67a4cd99934742c224353f.gif +0 -0
  73. data/public/assets/icon_layout.gif +0 -0
  74. data/public/assets/icon_move-f35c7ebf13ebbca913135cc9b6a6c852.gif +0 -0
  75. data/public/assets/icon_move.gif +0 -0
  76. data/public/assets/icon_regular-508bf97c5ce9079212dc6c82187c3d3e.gif +0 -0
  77. data/public/assets/icon_regular.gif +0 -0
  78. data/public/assets/icon_snippet-2cbf097041528692c375307fa6f7ab1b.gif +0 -0
  79. data/public/assets/icon_snippet.gif +0 -0
  80. data/public/assets/jquery.min-6c267bfd2b3f36e6edccb2e584934c1c.map +1 -0
  81. data/public/assets/jquery.min.map +1 -0
  82. data/public/assets/manifest.yml +37 -0
  83. data/public/assets/nav_arrow-06863c959673009ef5072a7190d621f4.png +0 -0
  84. data/public/assets/nav_arrow.png +0 -0
  85. data/public/assets/x-ed5e81fd388793b4a37adb6e1ab2ad5f.png +0 -0
  86. data/public/assets/x.png +0 -0
  87. data/rmails.gemspec +1 -1
  88. data/system/config/fields.yml +4 -1
  89. data/system/dist/nginx/rmails.erb +40 -17
  90. data/system/dist/rmails/thin.yml.erb +21 -0
  91. data/system/lib/dkim_key.rb +12 -5
  92. data/system/recipes/03_setup_postfix.rb +1 -1
  93. data/system/recipes/05_setup_nginx.rb +15 -1
  94. data/system/recipes/09_setup_awstats.rb +9 -5
  95. data/system/recipes/XX_start_services.rb +1 -1
  96. metadata +66 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2440631a5857579e9aab9f07dd5b8ce0027a579c
4
- data.tar.gz: 882d127197e2813e40602129b072af237b5e2402
3
+ metadata.gz: 6c194aed1961492447b6ceaf87b07a5318dc829e
4
+ data.tar.gz: b388574313b37e2627e38c73e77440814f5fe203
5
5
  SHA512:
6
- metadata.gz: 53d5407cce4b17e80f536aed61c300ee6e93a43eee859cc30d27d9140cd455439e0138bd6a40cc3c440e99df6db198b2b334c120d0ae6258706a79ab65622c12
7
- data.tar.gz: b53f5fc9ba0196c9c315e40d1d089200408cdd1724e81ac92be40b60a573e2647ecbfe2bc2739a5a60dfba51b77bd1164b1ef4111e06ecd889a34219aa7cb341
6
+ metadata.gz: 9ddcab0f7b55d43d07a924e074ef4a5743798432feac61940cccf8deb84c493c8b39292f3c3f3562c6ad5e2bd3cc6fa76782a1312feee09c19b75ec0e18123d9
7
+ data.tar.gz: 23f57e43f968dc120512f8e2ff86a82b75944d0e7961e3f5991a97ef8fb37b6e5fdf513939dd3f90672e66cd87f53449ce7f880ac27735ee0c725cc0798bcd2b
data/README.markdown CHANGED
@@ -1,9 +1,53 @@
1
1
  Rmails
2
2
  ============
3
3
 
4
+ A Ruby on Rails application which automates an installation and initial configuration of mail server which consists of freely available program components and which enables its additional configuration via interactive web interface.
5
+
6
+ For Debian based servers. CentOs, Fedora and Gentoo support will be added in near future.
7
+
8
+
9
+
10
+
11
+ Requirements
12
+ ------------
13
+
14
+ Tested with ruby 1.8.7 and 1.9.3.
15
+
16
+
17
+ Rubygems required.
18
+
19
+
20
+ Project Maturity
21
+ ----------------
22
+
23
+ It is not a mature project and small modifications in configuration may be needed. Application tests have not been created yet.
4
24
 
5
25
 
6
26
  Installation
7
27
  ------------
8
28
 
29
+ Via rubygems.org:
30
+
31
+ gem install rmails
32
+
33
+
34
+ Using git:
35
+
36
+ https://github.com/fanda/rmails.git
37
+
38
+
39
+ Getting Started
40
+ ---------------
41
+
42
+ Script rmails should be added, then
43
+
44
+ rmails --install
45
+
46
+
47
+ to install all necessary programs, make initial configuration and start system services.
48
+
49
+ Web application for administration can be started with
50
+
51
+ rmails --start-app
52
+
9
53
 
data/Vagrantfile CHANGED
@@ -8,12 +8,26 @@ Vagrant::Config.run do |config|
8
8
  c.vm.box = "ubuntu12"
9
9
  c.vm.forward_port 80, 8090
10
10
  c.vm.forward_port 3000, 4000
11
+ c.vm.forward_port 25, 1125
12
+ c.vm.forward_port 587, 11587
13
+ c.vm.forward_port 110, 11110
14
+ c.vm.forward_port 995, 11995
15
+ c.vm.forward_port 143, 11143
16
+ c.vm.forward_port 993, 11993
17
+
11
18
  end
12
19
 
13
20
  config.vm.define :debian do |c|
14
21
  c.vm.box = "debian32"
15
22
  c.vm.forward_port 80, 8091
16
23
  c.vm.forward_port 3000, 4001
24
+ c.vm.forward_port 25, 1125
25
+ c.vm.forward_port 587, 11587
26
+ c.vm.forward_port 110, 11110
27
+ c.vm.forward_port 995, 11995
28
+ c.vm.forward_port 143, 11143
29
+ c.vm.forward_port 993, 11993
30
+
17
31
  end
18
32
 
19
33
 
@@ -0,0 +1,11 @@
1
+ window.Stats = can.Control({
2
+
3
+ init: (el, opt) ->
4
+ @opt = opt
5
+ @ifr = $(el).find('iframe')
6
+ @ifr.contents().find('a[target="awstatshome"]').hide().find('img').hide()
7
+ @ifr.contents().find('body').css('background-color', '#e6e6e6')
8
+ return
9
+
10
+
11
+ })
@@ -46,3 +46,25 @@ String.prototype.model = () ->
46
46
  return can.capitalize( this.replace( /[-_]([a-z])/ig, (z,b) ->
47
47
  return b.toUpperCase()
48
48
  ))
49
+
50
+
51
+ # coffee script from this http://www.dyn-web.com/tutorials/iframes/height/demo.php
52
+ window.getDocHeight = (doc) ->
53
+ doc ||= document
54
+ body = doc.body
55
+ html = doc.documentElement
56
+ return Math.max(
57
+ body.scrollHeight, body.offsetHeight,
58
+ html.clientHeight, html.scrollHeight, html.offsetHeight
59
+ )
60
+
61
+ window.setIframeHeight = (el) ->
62
+ doc = if el.contentDocument
63
+ el.contentDocument
64
+ else
65
+ el.contentWindow.document
66
+ el.style.visibility = 'hidden'
67
+ el.style.height = "10px"
68
+ # IE opt. for bing/msn needs a bit added or scrollbar appears
69
+ el.style.height = window.getDocHeight( doc ) + 4 + "px"
70
+ el.style.visibility = 'visible'
@@ -154,3 +154,15 @@ header
154
154
  #new_admin_user
155
155
  button[type="submit"], input[type="submit"]
156
156
  margin-left: 11em
157
+
158
+ #stats
159
+ width: 100%
160
+ height: 100%
161
+ iframe
162
+ border: none
163
+ width: 100%
164
+ height: 10em
165
+ background: transparent
166
+ .aws_data
167
+ a[target="awstatshome"]
168
+ display: none
@@ -17,4 +17,8 @@ class ApplicationController < ActionController::Base
17
17
  )
18
18
  end
19
19
 
20
+ def after_sign_in_path_for(resource_or_scope)
21
+ domains_path
22
+ end
23
+
20
24
  end
@@ -0,0 +1,7 @@
1
+ class StatisticsController < ApplicationController
2
+
3
+ def index
4
+ render
5
+ end
6
+
7
+ end
@@ -27,12 +27,21 @@ class CertificateManager
27
27
  @i.shell_manager.sh "openssl req -new -newkey rsa:4096 -x509 -days 3650 -nodes -out /etc/ssl/certs/https.pem -keyout /etc/ssl/private/https.pem -subj /C=/ST=/L=/O=/OU=/CN=#{params[:name]||Property.find_by_key('mydomain').value}/emailAddress=#{params[:email]}"
28
28
  end
29
29
 
30
- def dkim_cert_gen(domain, keyname=domain)
31
- @i.shell_manager.sh("opendkim-genkey -r -d #{keyname} -D /etc/ssl/dkim")
32
- @i.shell_manager.chown 'opendkim', 'opendkim', "/etc/ssl/dkim/#{keyname}.private"
30
+ def dkim_cert_gen(domain, selector)
31
+ @i.shell_manager.sh("opendkim-genkey -r -s #{selector} -d #{domain} -D /etc/ssl/dkim")
32
+ @i.shell_manager.chown 'opendkim', 'opendkim', "/etc/ssl/dkim/#{selector}.private"
33
33
 
34
- key_table = "default._domainkey.#{keyname} #{domain}:default:/etc/ssl/dkim/#{keyname}.private"
35
- signing_table = "#{domain} default._domainkey.#{keyname}"
34
+ @i.chown 'opendkim', 'opendkim', "/etc/ssl/dkim/#{selector}.private"
35
+ @i.chown 'opendkim', 'rmails', "/etc/ssl/dkim/#{selector}.txt"
36
+ @i.chmod 0660, "/etc/ssl/dkim/#{selector}.txt"
37
+
38
+ # correct bad dns record
39
+ edit "/etc/ssl/dkim/#{selector}.txt" do
40
+ replace ';=rsa;', ";k=rsa;"
41
+ end
42
+
43
+ key_table = "#{selector}._domainkey.#{domain} #{domain}:#{selector}:/etc/ssl/dkim/#{selector}.private"
44
+ signing_table = "*@#{domain} #{selector}._domainkey.#{domain}"
36
45
 
37
46
  @i.edit :file => '/etc/opendkim/KeyTable' do
38
47
  append key_table
@@ -25,7 +25,12 @@ class Property < ActiveRecord::Base
25
25
  p.service = DSPAM
26
26
  when :nginx
27
27
  p.service = NGINX
28
+ when :amavis
29
+ p.service = AMAVIS
30
+ when :spamassassin
31
+ p.service = SPAMASSASSIN
28
32
  else
33
+ p.service = APPLICATION
29
34
  end
30
35
  p.save
31
36
  end
@@ -91,13 +96,14 @@ class Property < ActiveRecord::Base
91
96
 
92
97
  protected
93
98
 
94
- APPLICATION = 0
99
+ APPLICATION = 0
95
100
 
96
- POSTFIX = 1
97
- DOVECOT = 2
98
- NGINX = 3
99
- DSPAM = 4
100
- AMAVIS = 5
101
- AWSTATS = 6
101
+ POSTFIX = 1
102
+ DOVECOT = 2
103
+ NGINX = 3
104
+ DSPAM = 4
105
+ AMAVIS = 5
106
+ AWSTATS = 6
107
+ SPAMASSASSIN = 7
102
108
 
103
109
  end
@@ -0,0 +1,44 @@
1
+ class Property::Amavis< Property
2
+
3
+ def self.service; AMAVIS ;end
4
+
5
+ default_scope where(:service => self.service)
6
+
7
+
8
+ def self.binary_template(a, locals)
9
+ a.edit :file => "#{etc_amavis}/50-user" do
10
+ locals.each do |key, value|
11
+ value = value == true or value == '1' ? '1' : '0'
12
+ delete /^\$#{key}.*;.*$/
13
+ append "$#{key} = #{value};"
14
+ end
15
+ end
16
+ end
17
+
18
+ def self.number_variable_template(a, locals)
19
+ a.edit :file => "#{etc_amavis}/50-user" do
20
+ locals.each do |key, value|
21
+ delete /^\$#{key}.*;.*$/
22
+ append "$#{key} = #{value};"
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.string_variable_template(a, locals)
28
+ a.edit :file => "#{etc_amavis}/50-user" do
29
+ locals.each do |key, value|
30
+ delete /^\$#{key}.*;.*$/
31
+ append "$#{key} = '#{value}';"
32
+ end
33
+ end
34
+ end
35
+
36
+
37
+ protected
38
+
39
+ def self.etc_amavis
40
+ '/etc/amavis/conf.d'
41
+ end
42
+
43
+
44
+ end
@@ -4,7 +4,7 @@ class Property::Nginx < Property
4
4
 
5
5
  default_scope where(:service => self.service)
6
6
 
7
- def self.render_thin_site_template(a, site, key_value_string)
7
+ def self.render_rmails_site_template(a, site, key_value_string)
8
8
  # example key_value_string= 'hostnames=rmails.com www.rmails.com;a=b;c=d'
9
9
  locals = Hash[ key_value_string.split(';').map {|it| it.split('=', 2) } ]
10
10
  site_path = "#{etc_nginx}/#{sites_available}/#{site}"
@@ -12,7 +12,7 @@ class Property::Nginx < Property
12
12
  :file => "#{dist}nginx/rmails.erb",
13
13
  :to => site_path,
14
14
  :mode => 0664,
15
- :locals => locals
15
+ :locals => {:rails_root => Rails.root}.merge(locals)
16
16
  )
17
17
  end
18
18
 
@@ -0,0 +1,25 @@
1
+ class Property::Spamassassin< Property
2
+
3
+ def self.service; SPAMASSASSIN ;end
4
+
5
+ default_scope where(:service => self.service)
6
+
7
+
8
+ def self.preference_template(a, locals)
9
+ a.edit :file => "#{etc_sa}/local.cf" do
10
+ locals.each do |key, value|
11
+ delete /^#{key}.*$/
12
+ append "#{key} #{value}"
13
+ end
14
+ end
15
+ end
16
+
17
+
18
+ protected
19
+
20
+ def self.etc_sa
21
+ '/etc/spamassassin'
22
+ end
23
+
24
+
25
+ end
@@ -1,3 +1,4 @@
1
1
  %li= link_to t("navigation.domains"), domains_path, :class => current_page?(domains_path) ? 'active' : ''
2
2
  %li= link_to t("navigation.server_settings"), server_path, :class => current_page?(server_path) ? 'active' : ''
3
3
  %li= link_to t("navigation.admins"), admin_users_path, :class => current_page?(admin_users_path) ? 'active' : ''
4
+ %li= link_to t("navigation.statistics"), statistics_path, :class => current_page?(statistics_path) ? 'active' : ''
@@ -0,0 +1,16 @@
1
+ = field_set_tag t('server.amavis_preferences') do
2
+ = property_input form, @properties['max_servers']
3
+ = property_input form, @properties['mydomain']
4
+ = property_input form, @properties['sa_tag_level_deflt']
5
+ = property_input form, @properties['sa_tag2_level_deflt']
6
+ = property_input form, @properties['sa_spam_subject_tag']
7
+ = property_input form, @properties['sa_tag_level_deflt']
8
+ = property_input form, @properties['sa_tag2_level_deflt']
9
+ = property_input form, @properties['sa_kill_level_deflt']
10
+ = property_input form, @properties['sa_dsn_cutoff_level']
11
+ = property_input form, @properties['sa_mail_body_size_limit']
12
+ = property_input form, @properties['sa_local_tests_only']
13
+
14
+ = field_set_tag t('server.sa_preferences') do
15
+ = property_input form, @properties['required_score']
16
+
@@ -1,10 +1,18 @@
1
1
  = field_set_tag t('server.dkim') do
2
2
  -#= property_input form, @properties['dkim_cert']
3
3
 
4
+ %h5=t '.dkim_dns_records'
5
+ %pre
6
+ = `cat /etc/ssl/dkim/default.txt`
7
+
8
+
4
9
  = field_set_tag t('server.https') do
5
10
  -#= property_input form, @properties['https_cert']
6
-
11
+ %button.btn#regenerate_cert_https{:disabled => true}
12
+ =t '.regenerate_cert_https'
7
13
 
8
14
  = field_set_tag t('server.smtpd') do
9
15
  -#= property_input form, @properties['smtpd_cert']
16
+ %button.btn#regenerate_cert_smtpd{:disabled => true}
17
+ =t '.regenerate_cert_smtpd'
10
18
 
@@ -29,6 +29,8 @@
29
29
  %h2=t('.filtering')
30
30
  = render :partial => 'postfix_test', :locals => {:form => f }
31
31
  = render :partial => 'dspam', :locals => {:form => f }
32
+ = render :partial => 'amavis', :locals => {:form => f }
33
+
32
34
  #certificates.tab-pane
33
35
  %h2=t('.certificates')
34
36
  = render :partial => 'certificates', :locals => {:form => f }
@@ -0,0 +1,11 @@
1
+ - content_for :title do
2
+ &rarr;
3
+ = t('.title')
4
+ - content_for :script do
5
+ :javascript
6
+ $(document).ready(function() { new window.Stats('#stats'); });
7
+
8
+
9
+
10
+ #stats
11
+ %iframe{:src => '/s/awstats.mail.rmails.com.html', :name => 'stats', :onload => 'window.setIframeHeight(this);'}
data/bin/rmails CHANGED
@@ -1,29 +1,55 @@
1
1
  #!/usr/bin/env ruby
2
- #/ Usage: rmails --install
2
+ #/ Usage: rmails action
3
+ #/
4
+ #/ Actions:
5
+ #/ --install
3
6
  #/ Install all compoments of the system.
4
7
  #/ You must be root to run this.
5
- # ** Tip: use #/ lines to define the --help usage message.
8
+ #/ --start-app
9
+ #/ Starts server of configuration app.
10
+ #/ You may have to be root to run this.
11
+ #/ --stop-app
12
+ #/ Stops server of configuration app.
13
+ #/ You may have to be root to run this.
14
+
6
15
 
7
16
  $stderr.sync = true
8
17
 
9
18
  require 'optparse'
10
19
  require File.expand_path('../../config/application', __FILE__)
11
20
  require 'rmails/installer'
21
+ require 'rmails/runner'
12
22
 
13
23
  # default options
14
24
  install = false
25
+ start = false
26
+ stop = false
15
27
 
16
28
  # parse arguments
17
29
  file = __FILE__
18
30
  ARGV.options do |opts|
19
31
  opts.on("--install") { |install| }
32
+ opts.on("--start-app") { |start| }
33
+ opts.on("--stop-app") { |stop| }
20
34
  opts.on_tail("-h", "--help") { exec "grep ^#/<'#{file}'|cut -c4-" }
21
35
  opts.parse!
22
36
  end
23
37
 
38
+
39
+ if not(install or start or stop) or(start and stop)
40
+ exec "grep ^#/<'#{file}'|cut -c4-"
41
+
24
42
  if install
25
43
  setup = Rmails::Installer.new
26
44
  setup.run
27
- else
28
- exec "grep ^#/<'#{file}'|cut -c4-"
45
+
46
+ elsif start
47
+ app = Rmails::Runner.new
48
+ app.start
49
+ end
50
+
51
+ elsif stop
52
+ app = Rmails::Runner.new
53
+ app.stop
29
54
  end
55
+