diaspora-prosody-config 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -0
- data/diaspora-prosody-config.gemspec +1 -1
- data/lib/diaspora-prosody-config.rb +64 -11
- data/test/lib_dpc_test.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b407a1828f500d4286581d984e8087a60316346c
|
4
|
+
data.tar.gz: 363ee05249238782d2585bba1854b564611b5fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46678b6750009021721d722db8f5023cc56eac72bc3e76364a633bd7ad1eb96dd07a7ba1779649b6e5c2ff134beaec701a5fbec49bbd87633f35de3131f5143b
|
7
|
+
data.tar.gz: 86ac1a3c7252342388e9afdd312c1fc9b761b46d95b6f95ccb2acb9019f4fa3c2b963b7d1e0e49a7687117cce805b3f27943c6716131f8eca115abc2ebac29c2
|
data/Gemfile.lock
CHANGED
data/README.md
ADDED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'diaspora-prosody-config'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.6'
|
4
4
|
s.summary = 'Diaspora Configuration Wrapper For Prosodoy'
|
5
5
|
s.description = 'This gem maps configuration options from Diaspora to Prosody.'
|
6
6
|
s.license = 'GPL-3.0'
|
@@ -17,17 +17,29 @@
|
|
17
17
|
#
|
18
18
|
|
19
19
|
require 'fileutils'
|
20
|
+
require 'digest/md5'
|
20
21
|
|
21
22
|
module Prosody
|
22
|
-
|
23
|
-
|
24
|
-
).gem_dir.freeze
|
25
|
-
|
23
|
+
NAME = 'diaspora-prosody-config'.freeze
|
24
|
+
GEMDIR = Gem::Specification.find_by_name(NAME).gem_dir.freeze
|
26
25
|
WRAPPERCFG = "#{GEMDIR}/etc/prosody.cfg.lua".freeze
|
27
26
|
DIASPORACFG = "#{FileUtils.pwd}/config/prosody.cfg.lua".freeze
|
28
27
|
|
28
|
+
# Catch signal interrupt
|
29
|
+
# for a clean shutdown
|
30
|
+
Signal.trap("TERM") {
|
31
|
+
shutdown
|
32
|
+
exit
|
33
|
+
}
|
34
|
+
|
29
35
|
def self.start
|
30
|
-
check_sanity.nil?
|
36
|
+
if check_sanity.nil?
|
37
|
+
@prosody_pid = Process.spawn("#{find_binary} --config #{WRAPPERCFG}")
|
38
|
+
# Prosody was forked into background
|
39
|
+
# Let's wait till the Wrapper
|
40
|
+
# will be killed or prosody itself
|
41
|
+
Process.waitpid(@prosody_pid)
|
42
|
+
end
|
31
43
|
end
|
32
44
|
|
33
45
|
def self.update_configuration(opts = {})
|
@@ -42,6 +54,8 @@ module Prosody
|
|
42
54
|
config.gsub!(/\#\{#{k}\}/, "#{v}")
|
43
55
|
end
|
44
56
|
File.open(WRAPPERCFG, 'w') {|f| f.write(config) }
|
57
|
+
# check if prosody is available
|
58
|
+
check_sanity
|
45
59
|
end
|
46
60
|
|
47
61
|
def self.find_binary
|
@@ -49,23 +63,56 @@ module Prosody
|
|
49
63
|
prosodybin = "#{p}/prosody"
|
50
64
|
return prosodybin if File.exist?(prosodybin)
|
51
65
|
end
|
52
|
-
abort
|
66
|
+
abort <<-eos
|
67
|
+
FATAL:
|
68
|
+
*****************************************************************
|
69
|
+
#{NAME} wasn't able to find your prosody binary.
|
70
|
+
Have you installed prosody (http://prosody.im/download/start)?
|
71
|
+
|
72
|
+
If you run Prosody or any other XMPP server by yourself you can
|
73
|
+
disable #{NAME} by editing your diaspora.yml:
|
74
|
+
configuration:
|
75
|
+
chat:
|
76
|
+
server:
|
77
|
+
enabled: false
|
78
|
+
*****************************************************************
|
79
|
+
eos
|
53
80
|
end
|
54
81
|
|
55
82
|
def self.check_sanity
|
83
|
+
# check if configuration is matching
|
84
|
+
usrcfg = Digest::MD5.hexdigest(File.read(DIASPORACFG))
|
85
|
+
gemcfg = Digest::MD5.hexdigest(File.read("#{WRAPPERCFG}.tpl"))
|
86
|
+
unless usrcfg.eql?(gemcfg)
|
87
|
+
abort <<-eos
|
88
|
+
FATAL:
|
89
|
+
*****************************************************************
|
90
|
+
|
91
|
+
#{usrcfg} != #{gemcfg}
|
92
|
+
|
93
|
+
You modified #{DIASPORACFG}
|
94
|
+
Please run:
|
95
|
+
rails runner config/initializers/prosody.rb
|
96
|
+
|
97
|
+
Otherwise your configuration changes will not take effect!
|
98
|
+
*****************************************************************
|
99
|
+
eos
|
100
|
+
end
|
56
101
|
# check on bcrypt and warn
|
57
102
|
bcrypt_so = %x(find /usr/local/lib -name bcrypt.so) rescue ''
|
58
|
-
|
103
|
+
if bcrypt_so.empty?
|
104
|
+
warn("#{NAME}: bcrypt is required for diaspora authentication")
|
105
|
+
end
|
59
106
|
# check prosody version
|
60
|
-
about = %x(#{find_binary}ctl about)
|
107
|
+
about = %x(#{find_binary}ctl --config #{WRAPPERCFG} about)
|
61
108
|
version_string = begin
|
62
109
|
about.match(/prosody\s(\d+\.\d+\.\d+)/i).captures[0]
|
63
110
|
rescue
|
64
|
-
abort
|
111
|
+
abort "#{NAME}: #{about}"
|
65
112
|
end
|
66
113
|
version = Gem::Version.new(version_string)
|
67
114
|
if version < Gem::Version.new('0.9.0')
|
68
|
-
abort
|
115
|
+
abort "#{NAME}: Your're prosody version should be >= 0.9.0"
|
69
116
|
end
|
70
117
|
end
|
71
118
|
|
@@ -91,5 +138,11 @@ module Prosody
|
|
91
138
|
opts
|
92
139
|
end
|
93
140
|
|
94
|
-
|
141
|
+
def self.shutdown
|
142
|
+
unless @prosody_pid.nil?
|
143
|
+
Process.kill(9, @prosody_pid)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
private_class_method :find_binary, :check_sanity, :config_params, :shutdown
|
95
148
|
end
|
data/test/lib_dpc_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: diaspora-prosody-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Matt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pronto
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- Gemfile
|
93
93
|
- Gemfile.lock
|
94
94
|
- LICENSE
|
95
|
+
- README.md
|
95
96
|
- Rakefile
|
96
97
|
- diaspora-prosody-config.gemspec
|
97
98
|
- etc/prosody.cfg.lua.tpl
|